view release on metacpan or search on metacpan
share/ext-all-debug-w-comments.js view on Meta::CPAN
* @property
* @type Function
*/
emptyFn : function(){},
/**
* URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images.
* In older versions of IE, this defaults to "http://extjs.com/s.gif" and you should change this to a URL on your server.
* For other browsers it uses an inline data URL.
* @type String
*/
BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
'http:/' + '/www.extjs.com/s.gif' :
'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
extendX : function(supr, fn){
return Ext.extend(supr, fn(supr.prototype));
},
/**
* Returns the current HTML document object as an {@link Ext.Element}.
* @return Ext.Element The document
*/
getDoc : function(){
return Ext.get(document);
},
/**
* Utility method for validating that a value is numeric, returning the specified default value if it is not.
* @param {Mixed} value Should be a number, but any type will be handled appropriately
* @param {Number} defaultValue The value to return if the original value is non-numeric
* @return {Number} Value, if numeric, else defaultValue
*/
num : function(v, defaultValue){
v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
return isNaN(v) ? defaultValue : v;
},
/**
* <p>Utility method for returning a default value if the passed value is empty.</p>
* <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
* <li>null</li>
* <li>undefined</li>
* <li>an empty array</li>
* <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
* </ul></div>
* @param {Mixed} value The value to test
* @param {Mixed} defaultValue The value to return if the original value is empty
* @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
* @return {Mixed} value, if non-empty, else defaultValue
*/
value : function(v, defaultValue, allowBlank){
return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
},
/**
* Escapes the passed string for use in a regular expression
* @param {String} str
* @return {String}
*/
escapeRe : function(s) {
return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
},
sequence : function(o, name, fn, scope){
o[name] = o[name].createSequence(fn, scope);
},
/**
* Applies event listeners to elements by selectors when the document is ready.
* The event name is specified with an <tt>@</tt> suffix.
* <pre><code>
Ext.addBehaviors({
// add a listener for click on all anchors in element with id foo
'#foo a@click' : function(e, t){
// do something
},
// add the same listener to multiple selectors (separated by comma BEFORE the @)
'#foo a, #bar span.some-class@mouseover' : function(){
// do something
}
});
* </code></pre>
* @param {Object} obj The list of behaviors to apply
*/
addBehaviors : function(o){
if(!Ext.isReady){
Ext.onReady(function(){
Ext.addBehaviors(o);
});
} else {
var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
parts,
b,
s;
for (b in o) {
if ((parts = b.split('@'))[1]) { // for Object prototype breakers
s = parts[0];
if(!cache[s]){
cache[s] = Ext.select(s);
}
cache[s].on(parts[1], o[b]);
}
}
cache = null;
}
},
/**
* Utility method for getting the width of the browser scrollbar. This can differ depending on
* operating system settings, such as the theme or font size.
* @param {Boolean} force (optional) true to force a recalculation of the value.
* @return {Number} The width of the scrollbar.
*/
getScrollBarWidth: function(force){
if(!Ext.isReady){
return 0;
}
if(force === true || scrollWidth === null){
share/ext-all-debug-w-comments.js view on Meta::CPAN
callback : function(cb, scope, args, delay){
if(typeof cb == 'function'){
if(delay){
cb.defer(delay, scope, args || []);
}else{
cb.apply(scope, args || []);
}
}
}
};
}());
/**
* @class Function
* These functions are available on every Function object (any JavaScript function).
*/
Ext.apply(Function.prototype, {
/**
* Create a combined function call sequence of the original function + the passed function.
* The resulting function returns the results of the original function.
* The passed fcn is called with the parameters of the original function. Example usage:
* <pre><code>
var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
var sayGoodbye = sayHi.createSequence(function(name){
alert('Bye, ' + name);
});
sayGoodbye('Fred'); // both alerts show
</code></pre>
* @param {Function} fcn The function to sequence
* @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
* <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
* @return {Function} The new function
*/
createSequence : function(fcn, scope){
var method = this;
return (typeof fcn != 'function') ?
this :
function(){
var retval = method.apply(this || window, arguments);
fcn.apply(scope || this || window, arguments);
return retval;
};
}
});
/**
* @class String
* These functions are available as static methods on the JavaScript String object.
*/
Ext.applyIf(String, {
/**
* Escapes the passed string for ' and \
* @param {String} string The string to escape
* @return {String} The escaped string
* @static
*/
escape : function(string) {
return string.replace(/('|\\)/g, "\\$1");
},
/**
* Pads the left side of a string with a specified character. This is especially useful
* for normalizing number and date strings. Example usage:
* <pre><code>
var s = String.leftPad('123', 5, '0');
// s now contains the string: '00123'
* </code></pre>
* @param {String} string The original string
* @param {Number} size The total length of the output string
* @param {String} char (optional) The character with which to pad the original string (defaults to empty string " ")
* @return {String} The padded string
* @static
*/
leftPad : function (val, size, ch) {
var result = String(val);
if(!ch) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result;
}
});
/**
* Utility function that allows you to easily switch a string between two alternating values. The passed value
* is compared to the current string, and if they are equal, the other value that was passed in is returned. If
* they are already different, the first value passed in is returned. Note that this method returns the new value
* but does not change the current string.
* <pre><code>
// alternate sort directions
sort = sort.toggle('ASC', 'DESC');
// instead of conditional logic:
sort = (sort == 'ASC' ? 'DESC' : 'ASC');
</code></pre>
* @param {String} value The value to compare to the current string
* @param {String} other The new value to use if the string already equals the first value passed in
* @return {String} The new value
*/
String.prototype.toggle = function(value, other){
return this == value ? other : value;
};
/**
* Trims whitespace from either end of a string, leaving spaces within the string intact. Example:
* <pre><code>
var s = ' foo bar ';
alert('-' + s + '-'); //alerts "- foo bar -"
alert('-' + s.trim() + '-'); //alerts "-foo bar-"
</code></pre>
* @return {String} The trimmed string
*/
String.prototype.trim = function(){
var re = /^\s+|\s+$/g;
return function(){ return this.replace(re, ""); };
share/ext-all-debug-w-comments.js view on Meta::CPAN
* supported will provide results equivalent to their PHP versions.
*
* The following is a list of all currently supported formats:
* <pre>
Format Description Example returned values
------ ----------------------------------------------------------------------- -----------------------
d Day of the month, 2 digits with leading zeros 01 to 31
D A short textual representation of the day of the week Mon to Sun
j Day of the month without leading zeros 1 to 31
l A full textual representation of the day of the week Sunday to Saturday
N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday)
z The day of the year (starting from 0) 0 to 364 (365 in leap years)
W ISO-8601 week number of year, weeks starting on Monday 01 to 53
F A full textual representation of a month, such as January or March January to December
m Numeric representation of a month, with leading zeros 01 to 12
M A short textual representation of a month Jan to Dec
n Numeric representation of a month, without leading zeros 1 to 12
t Number of days in the given month 28 to 31
L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004
belongs to the previous or next year, that year is used instead)
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y A two digit representation of a year Examples: 99 or 03
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
g 12-hour format of an hour without leading zeros 1 to 12
G 24-hour format of an hour without leading zeros 0 to 23
h 12-hour format of an hour with leading zeros 01 to 12
H 24-hour format of an hour with leading zeros 00 to 23
i Minutes, with leading zeros 00 to 59
s Seconds, with leading zeros 00 to 59
u Decimal fraction of a second Examples:
(minimum 1 digit, arbitrary number of digits allowed) 001 (i.e. 0.001s) or
100 (i.e. 0.100s) or
999 (i.e. 0.999s) or
999876543210 (i.e. 0.999876543210s)
O Difference to Greenwich time (GMT) in hours and minutes Example: +1030
P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00
T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ...
Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400
c ISO 8601 date
Notes: Examples:
1) If unspecified, the month / day defaults to the current month / day, 1991 or
the time defaults to midnight, while the timezone defaults to the 1992-10 or
browser's timezone. If a time is specified, it must include both hours 1993-09-20 or
and minutes. The "T" delimiter, seconds, milliseconds and timezone 1994-08-19T16:20+01:00 or
are optional. 1995-07-18T17:21:28-02:00 or
2) The decimal fraction of a second, if specified, must contain at 1996-06-17T18:22:29.98765+03:00 or
least 1 digit (there is no limit to the maximum number 1997-05-16T19:23:30,12345-0400 or
of digits allowed), and may be delimited by either a '.' or a ',' 1998-04-15T20:24:31.2468Z or
Refer to the examples on the right for the various levels of 1999-03-14T20:24:32Z or
date-time granularity which are supported, or see 2000-02-13T21:25:33
http://www.w3.org/TR/NOTE-datetime for more info. 2001-01-12 22:26:34
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463
M$ Microsoft AJAX serialized dates \/Date(1238606590509)\/ (i.e. UTC milliseconds since epoch) or
\/Date(1238606590509+0800)\/
</pre>
*
* Example usage (note that you must escape format specifiers with '\\' to render them as character literals):
* <pre><code>
// Sample date:
// 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'
var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
document.write(dt.format('Y-m-d')); // 2007-01-10
document.write(dt.format('F j, Y, g:i a')); // January 10, 2007, 3:05 pm
document.write(dt.format('l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM
</code></pre>
*
* Here are some standard date/time patterns that you might find helpful. They
* are not part of the source of Date.js, but to use them you can simply copy this
* block of code into any script that is included after Date.js and they will also become
* globally available on the Date object. Feel free to add or remove patterns as needed in your code.
* <pre><code>
Date.patterns = {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
};
</code></pre>
*
* Example usage:
* <pre><code>
var dt = new Date();
document.write(dt.format(Date.patterns.ShortDate));
</code></pre>
* <p>Developer-written, custom formats may be used by supplying both a formatting and a parsing function
* which perform to specialized requirements. The functions are stored in {@link #parseFunctions} and {@link #formatFunctions}.</p>
*/
/*
* Most of the date-formatting functions below are the excellent work of Baron Schwartz.
* (see http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/)
* They generate precompiled functions from format patterns instead of parsing and
* processing each pattern every time a date is formatted. These functions are available
* on every Date object.
*/
(function() {
/**
* Global flag which determines if strict date parsing should be used.
* Strict date parsing will not roll-over invalid dates, which is the
* default behaviour of javascript Date objects.
* (see {@link #parseDate} for more information)
* Defaults to <tt>false</tt>.
* @static
* @type Boolean
*/
Date.useStrict = false;
// create private copy of Ext's String.format() method
// - to remove unnecessary dependency
// - to resolve namespace conflict with M$-Ajax's implementation
function xf(format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/\{(\d+)\}/g, function(m, i) {
return args[i];
});
}
// private
Date.formatCodeToRegex = function(character, currentGroup) {
// Note: currentGroup - position in regex result array (see notes for Date.parseCodes below)
var p = Date.parseCodes[character];
if (p) {
p = typeof p == 'function'? p() : p;
Date.parseCodes[character] = p; // reassign function result to prevent repeated execution
}
return p ? Ext.applyIf({
c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
}, p) : {
g:0,
c:null,
s:Ext.escapeRe(character) // treat unrecognised characters as literals
};
};
// private shorthand for Date.formatCodeToRegex since we'll be using it fairly often
var $f = Date.formatCodeToRegex;
Ext.apply(Date, {
/**
* <p>An object hash in which each property is a date parsing function. The property name is the
* format string which that function parses.</p>
* <p>This object is automatically populated with date parsing functions as
* date formats are requested for Ext standard formatting strings.</p>
* <p>Custom parsing functions may be inserted into this object, keyed by a name which from then on
* may be used as a format string to {@link #parseDate}.<p>
* <p>Example:</p><pre><code>
Date.parseFunctions['x-date-format'] = myDateParser;
</code></pre>
* <p>A parsing function should return a Date object, and is passed the following parameters:<div class="mdetail-params"><ul>
* <li><code>date</code> : String<div class="sub-desc">The date string to parse.</div></li>
* <li><code>strict</code> : Boolean<div class="sub-desc">True to validate date strings while parsing
* (i.e. prevent javascript Date "rollover") (The default must be false).
* Invalid date strings should return null when parsed.</div></li>
* </ul></div></p>
* <p>To enable Dates to also be <i>formatted</i> according to that format, a corresponding
* formatting function must be placed into the {@link #formatFunctions} property.
* @property parseFunctions
* @static
* @type Object
*/
parseFunctions: {
"M$": function(input, strict) {
// note: the timezone offset is ignored since the M$ Ajax server sends
// a UTC milliseconds-since-Unix-epoch value (negative values are allowed)
var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
var r = (input || '').match(re);
return r? new Date(((r[1] || '') + r[2]) * 1) : null;
}
},
parseRegexes: [],
/**
* <p>An object hash in which each property is a date formatting function. The property name is the
* format string which corresponds to the produced formatted date string.</p>
* <p>This object is automatically populated with date formatting functions as
* date formats are requested for Ext standard formatting strings.</p>
* <p>Custom formatting functions may be inserted into this object, keyed by a name which from then on
* may be used as a format string to {@link #format}. Example:</p><pre><code>
Date.formatFunctions['x-date-format'] = myDateFormatter;
</code></pre>
* <p>A formatting function should return a string representation of the passed Date object, and is passed the following parameters:<div class="mdetail-params"><ul>
* <li><code>date</code> : Date<div class="sub-desc">The Date to format.</div></li>
* </ul></div></p>
* <p>To enable date strings to also be <i>parsed</i> according to that format, a corresponding
* parsing function must be placed into the {@link #parseFunctions} property.
* @property formatFunctions
* @static
* @type Object
*/
formatFunctions: {
"M$": function() {
share/ext-all-debug-w-comments.js view on Meta::CPAN
var dt = new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);
return y == dt.getFullYear() &&
m == dt.getMonth() + 1 &&
d == dt.getDate() &&
h == dt.getHours() &&
i == dt.getMinutes() &&
s == dt.getSeconds() &&
ms == dt.getMilliseconds();
},
/**
* Parses the passed string using the specified date format.
* Note that this function expects normal calendar dates, meaning that months are 1-based (i.e. 1 = January).
* The {@link #defaults} hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond)
* which cannot be found in the passed string. If a corresponding default date value has not been specified in the {@link #defaults} hash,
* the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.
* Keep in mind that the input date string must precisely match the specified format string
* in order for the parse operation to be successful (failed parse operations return a null value).
* <p>Example:</p><pre><code>
//dt = Fri May 25 2007 (current date)
var dt = new Date();
//dt = Thu May 25 2006 (today's month/day in 2006)
dt = Date.parseDate("2006", "Y");
//dt = Sun Jan 15 2006 (all date parts specified)
dt = Date.parseDate("2006-01-15", "Y-m-d");
//dt = Sun Jan 15 2006 15:20:01
dt = Date.parseDate("2006-01-15 3:20:01 PM", "Y-m-d g:i:s A");
// attempt to parse Sun Feb 29 2006 03:20:01 in strict mode
dt = Date.parseDate("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
</code></pre>
* @param {String} input The raw date string.
* @param {String} format The expected date string format.
* @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date "rollover")
(defaults to false). Invalid date strings will return null when parsed.
* @return {Date} The parsed Date.
* @static
*/
parseDate : function(input, format, strict) {
var p = Date.parseFunctions;
if (p[format] == null) {
Date.createParser(format);
}
return p[format](input, Ext.isDefined(strict) ? strict : Date.useStrict);
},
// private
getFormatCode : function(character) {
var f = Date.formatCodes[character];
if (f) {
f = typeof f == 'function'? f() : f;
Date.formatCodes[character] = f; // reassign function result to prevent repeated execution
}
// note: unknown characters are treated as literals
return f || ("'" + String.escape(character) + "'");
},
// private
createFormat : function(format) {
var code = [],
special = false,
ch = '';
for (var i = 0; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
} else if (special) {
special = false;
code.push("'" + String.escape(ch) + "'");
} else {
code.push(Date.getFormatCode(ch));
}
}
Date.formatFunctions[format] = new Function("return " + code.join('+'));
},
// private
createParser : function() {
var code = [
"var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
"def = Date.defaults,",
"results = String(input).match(Date.parseRegexes[{0}]);", // either null, or an array of matched strings
"if(results){",
"{1}",
"if(u != null){", // i.e. unix time is defined
"v = new Date(u * 1000);", // give top priority to UNIX time
"}else{",
// create Date object representing midnight of the current day;
// this will provide us with our date defaults
// (note: clearTime() handles Daylight Saving Time automatically)
"dt = (new Date()).clearTime();",
// date calculations (note: these calculations create a dependency on Ext.num())
"y = Ext.num(y, Ext.num(def.y, dt.getFullYear()));",
"m = Ext.num(m, Ext.num(def.m - 1, dt.getMonth()));",
"d = Ext.num(d, Ext.num(def.d, dt.getDate()));",
// time calculations (note: these calculations create a dependency on Ext.num())
"h = Ext.num(h, Ext.num(def.h, dt.getHours()));",
"i = Ext.num(i, Ext.num(def.i, dt.getMinutes()));",
"s = Ext.num(s, Ext.num(def.s, dt.getSeconds()));",
"ms = Ext.num(ms, Ext.num(def.ms, dt.getMilliseconds()));",
"if(z >= 0 && y >= 0){",
// both the year and zero-based day of year are defined and >= 0.
// these 2 values alone provide sufficient info to create a full date object
// create Date object representing January 1st for the given year
// handle years < 100 appropriately
"v = new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
// then add day of year, checking for Date "rollover" if necessary
"v = !strict? v : (strict === true && (z <= 364 || (v.isLeapYear() && z <= 365))? v.add(Date.DAY, z) : null);",
"}else if(strict === true && !Date.isValid(y, m + 1, d, h, i, s, ms)){", // check for Date "rollover"
"v = null;", // invalid date, so return null
"}else{",
// plain old Date object
// handle years < 100 properly
"v = new Date(y < 100 ? 100 : y, m, d, h, i, s, ms).add(Date.YEAR, y < 100 ? y - 100 : 0);",
"}",
"}",
"}",
"if(v){",
// favour UTC offset over GMT offset
"if(zz != null){",
// reset to UTC, then add offset
"v = v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
"}else if(o){",
// reset to GMT, then add offset
"v = v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
"}",
"}",
"return v;"
].join('\n');
return function(format) {
var regexNum = Date.parseRegexes.length,
currentGroup = 1,
calc = [],
regex = [],
special = false,
ch = "",
i = 0,
obj,
last;
for (; i < format.length; ++i) {
ch = format.charAt(i);
if (!special && ch == "\\") {
special = true;
} else if (special) {
special = false;
regex.push(String.escape(ch));
} else {
obj = $f(ch, currentGroup);
currentGroup += obj.g;
regex.push(obj.s);
if (obj.g && obj.c) {
if (obj.calcLast) {
last = obj.c;
} else {
calc.push(obj.c);
}
}
}
}
if (last) {
calc.push(last);
}
Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join('')));
};
}(),
// private
parseCodes : {
/*
* Notes:
* g = {Number} calculation group (0 or 1. only group 1 contributes to date calculations.)
* c = {String} calculation method (required for group 1. null for group 0. {0} = currentGroup - position in regex result array)
* s = {String} regex pattern. all matches are stored in results[], and are accessible by the calculation mapped to 'c'
*/
d: {
g:1,
c:"d = parseInt(results[{0}], 10);\n",
s:"(\\d{2})" // day of month with leading zeroes (01 - 31)
},
j: {
g:1,
c:"d = parseInt(results[{0}], 10);\n",
s:"(\\d{1,2})" // day of month without leading zeroes (1 - 31)
},
D: function() {
for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i); // get localised short day names
return {
g:0,
c:null,
s:"(?:" + a.join("|") +")"
};
},
l: function() {
return {
g:0,
c:null,
s:"(?:" + Date.dayNames.join("|") + ")"
};
},
N: {
g:0,
c:null,
s:"[1-7]" // ISO-8601 day number (1 (monday) - 7 (sunday))
share/ext-all-debug-w-comments.js view on Meta::CPAN
* The passed function will be called with each object in the collection.
* If the function returns true, the value is included otherwise it is filtered.
* @param {Function} fn The function to be called, it will receive the args o (the object), k (the key)
* @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to this MixedCollection.
* @return {MixedCollection} The new filtered collection
*/
filterBy : function(fn, scope){
var r = new Ext.util.MixedCollection();
r.getKey = this.getKey;
var k = this.keys, it = this.items;
for(var i = 0, len = it.length; i < len; i++){
if(fn.call(scope||this, it[i], k[i])){
r.add(k[i], it[i]);
}
}
return r;
},
/**
* Finds the index of the first matching object in this collection by a specific property/value.
* @param {String} property The name of a property on your objects.
* @param {String/RegExp} value A string that the property values
* should start with or a RegExp to test against the property.
* @param {Number} start (optional) The index to start searching at (defaults to 0).
* @param {Boolean} anyMatch (optional) True to match any part of the string, not just the beginning.
* @param {Boolean} caseSensitive (optional) True for case sensitive comparison.
* @return {Number} The matched index or -1
*/
findIndex : function(property, value, start, anyMatch, caseSensitive){
if(Ext.isEmpty(value, false)){
return -1;
}
value = this.createValueMatcher(value, anyMatch, caseSensitive);
return this.findIndexBy(function(o){
return o && value.test(o[property]);
}, null, start);
},
/**
* Find the index of the first matching object in this collection by a function.
* If the function returns <i>true</i> it is considered a match.
* @param {Function} fn The function to be called, it will receive the args o (the object), k (the key).
* @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to this MixedCollection.
* @param {Number} start (optional) The index to start searching at (defaults to 0).
* @return {Number} The matched index or -1
*/
findIndexBy : function(fn, scope, start){
var k = this.keys, it = this.items;
for(var i = (start||0), len = it.length; i < len; i++){
if(fn.call(scope||this, it[i], k[i])){
return i;
}
}
return -1;
},
/**
* Returns a regular expression based on the given value and matching options. This is used internally for finding and filtering,
* and by Ext.data.Store#filter
* @private
* @param {String} value The value to create the regex for. This is escaped using Ext.escapeRe
* @param {Boolean} anyMatch True to allow any match - no regex start/end line anchors will be added. Defaults to false
* @param {Boolean} caseSensitive True to make the regex case sensitive (adds 'i' switch to regex). Defaults to false.
* @param {Boolean} exactMatch True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.
*/
createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {
if (!value.exec) { // not a regex
var er = Ext.escapeRe;
value = String(value);
if (anyMatch === true) {
value = er(value);
} else {
value = '^' + er(value);
if (exactMatch === true) {
value += '$';
}
}
value = new RegExp(value, caseSensitive ? '' : 'i');
}
return value;
},
/**
* Creates a shallow copy of this collection
* @return {MixedCollection}
*/
clone : function(){
var r = new Ext.util.MixedCollection();
var k = this.keys, it = this.items;
for(var i = 0, len = it.length; i < len; i++){
r.add(k[i], it[i]);
}
r.getKey = this.getKey;
return r;
}
});
/**
* This method calls {@link #item item()}.
* Returns the item associated with the passed key OR index. Key has priority
* over index. This is the equivalent of calling {@link #key} first, then if
* nothing matched calling {@link #itemAt}.
* @param {String/Number} key The key or index of the item.
* @return {Object} If the item is found, returns the item. If the item was
* not found, returns <tt>undefined</tt>. If an item was found, but is a Class,
* returns <tt>null</tt>.
*/
Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
/**
* @class Ext.AbstractManager
* @extends Object
* Base Manager class - extended by ComponentMgr and PluginMgr
*/
Ext.AbstractManager = Ext.extend(Object, {
typeName: 'type',
constructor: function(config) {
Ext.apply(this, config || {});
/**
* Contains all of the items currently managed
* @property all
* @type Ext.util.MixedCollection
*/
this.all = new Ext.util.MixedCollection();
this.types = {};
},
share/ext-all-debug-w-comments.js view on Meta::CPAN
var me = this,
len,
t = me.tpls[id],
vs,
buf = [];
if ((t.test && !t.test.call(me, values, parent, xindex, xcount)) ||
(t.exec && t.exec.call(me, values, parent, xindex, xcount))) {
return '';
}
vs = t.target ? t.target.call(me, values, parent) : values;
len = vs.length;
parent = t.target ? values : parent;
if(t.target && Ext.isArray(vs)){
for(var i = 0, len = vs.length; i < len; i++){
buf[buf.length] = t.compiled.call(me, vs[i], parent, i+1, len);
}
return buf.join('');
}
return t.compiled.call(me, vs, parent, xindex, xcount);
},
// private
compileTpl : function(tpl){
var fm = Ext.util.Format,
useF = this.disableFormats !== true,
sep = Ext.isGecko ? "+" : ",",
body;
function fn(m, name, format, args, math){
if(name.substr(0, 4) == 'xtpl'){
return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
}
var v;
if(name === '.'){
v = 'values';
}else if(name === '#'){
v = 'xindex';
}else if(name.indexOf('.') != -1){
v = name;
}else{
v = "values['" + name + "']";
}
if(math){
v = '(' + v + math + ')';
}
if (format && useF) {
args = args ? ',' + args : "";
if(format.substr(0, 5) != "this."){
format = "fm." + format + '(';
}else{
format = 'this.call("'+ format.substr(5) + '", ';
args = ", values";
}
} else {
args= ''; format = "("+v+" === undefined ? '' : ";
}
return "'"+ sep + format + v + args + ")"+sep+"'";
}
function codeFn(m, code){
// Single quotes get escaped when the template is compiled, however we want to undo this when running code.
return "'" + sep + '(' + code.replace(/\\'/g, "'") + ')' + sep + "'";
}
// branched to use + in gecko and [].join() in others
if(Ext.isGecko){
body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
"';};";
}else{
body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
body.push(tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn));
body.push("'].join('');};");
body = body.join('');
}
eval(body);
return this;
},
/**
* Returns an HTML fragment of this template with the specified values applied.
* @param {Object} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @return {String} The HTML fragment
*/
applyTemplate : function(values){
return this.master.compiled.call(this, values, {}, 1, 1);
},
/**
* Compile the template to a function for optimized performance. Recommended if the template will be used frequently.
* @return {Function} The compiled function
*/
compile : function(){return this;}
/**
* @property re
* @hide
*/
/**
* @property disableFormats
* @hide
*/
/**
* @method set
* @hide
*/
});
/**
* Alias for {@link #applyTemplate}
* Returns an HTML fragment of this template with the specified values applied.
* @param {Object/Array} values The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
* @return {String} The HTML fragment
* @member Ext.XTemplate
* @method apply
*/
Ext.XTemplate.prototype.apply = Ext.XTemplate.prototype.applyTemplate;
/**
* Creates a template from the passed element's value (<i>display:none</i> textarea, preferred) or innerHTML.
* @param {String/HTMLElement} el A DOM element or its id
share/ext-all-debug-w-comments.js view on Meta::CPAN
* @return {Number} height The height in pixels
*/
getHeight : function(text){
return this.getSize(text).height;
}
};
instance.bind(bindTo);
return instance;
};
Ext.Element.addMethods({
/**
* Returns the width in pixels of the passed text, or the width of the text in this Element.
* @param {String} text The text to measure. Defaults to the innerHTML of the element.
* @param {Number} min (Optional) The minumum value to return.
* @param {Number} max (Optional) The maximum value to return.
* @return {Number} The text width in pixels.
* @member Ext.Element getTextWidth
*/
getTextWidth : function(text, min, max){
return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
}
});
/**
* @class Ext.util.Cookies
* Utility class for managing and interacting with cookies.
* @singleton
*/
Ext.util.Cookies = {
/**
* Create a cookie with the specified name and value. Additional settings
* for the cookie may be optionally specified (for example: expiration,
* access restriction, SSL).
* @param {String} name The name of the cookie to set.
* @param {Mixed} value The value to set for the cookie.
* @param {Object} expires (Optional) Specify an expiration date the
* cookie is to persist until. Note that the specified Date object will
* be converted to Greenwich Mean Time (GMT).
* @param {String} path (Optional) Setting a path on the cookie restricts
* access to pages that match that path. Defaults to all pages (<tt>'/'</tt>).
* @param {String} domain (Optional) Setting a domain restricts access to
* pages on a given domain (typically used to allow cookie access across
* subdomains). For example, "extjs.com" will create a cookie that can be
* accessed from any subdomain of extjs.com, including www.extjs.com,
* support.extjs.com, etc.
* @param {Boolean} secure (Optional) Specify true to indicate that the cookie
* should only be accessible via SSL on a page using the HTTPS protocol.
* Defaults to <tt>false</tt>. Note that this will only work if the page
* calling this code uses the HTTPS protocol, otherwise the cookie will be
* created with default options.
*/
set : function(name, value){
var argv = arguments;
var argc = arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : '/';
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secu...
},
/**
* Retrieves cookies that are accessible by the current page. If a cookie
* does not exist, <code>get()</code> returns <tt>null</tt>. The following
* example retrieves the cookie called "valid" and stores the String value
* in the variable <tt>validStatus</tt>.
* <pre><code>
* var validStatus = Ext.util.Cookies.get("valid");
* </code></pre>
* @param {String} name The name of the cookie to get
* @return {Mixed} Returns the cookie value for the specified name;
* null if the cookie name does not exist.
*/
get : function(name){
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
var j = 0;
while(i < clen){
j = i + alen;
if(document.cookie.substring(i, j) == arg){
return Ext.util.Cookies.getCookieVal(j);
}
i = document.cookie.indexOf(" ", i) + 1;
if(i === 0){
break;
}
}
return null;
},
/**
* Removes a cookie with the provided name from the browser
* if found by setting its expiration date to sometime in the past.
* @param {String} name The name of the cookie to remove
*/
clear : function(name){
if(Ext.util.Cookies.get(name)){
document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
},
/**
* @private
*/
getCookieVal : function(offset){
var endstr = document.cookie.indexOf(";", offset);
if(endstr == -1){
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}
};/**
* Framework-wide error-handler. Developers can override this method to provide
* custom exception-handling. Framework errors will often extend from the base
* Ext.Error class.
* @param {Object/Error} e The thrown exception object.
* @member Ext
*/
Ext.handleError = function(e) {
throw e;
};
/**
* @class Ext.Error
* @extends Error
* <p>A base error class. Future implementations are intended to provide more
* robust error handling throughout the framework (<b>in the debug build only</b>)
* to check for common errors and problems. The messages issued by this class
* will aid error checking. Error checks will be automatically removed in the
* production build so that performance is not negatively impacted.</p>
* <p>Some sample messages currently implemented:</p><pre>
"DataProxy attempted to execute an API-action but found an undefined
url / function. Please review your Proxy url/api-configuration."
* </pre><pre>
"Could not locate your "root" property in your server response.
Please review your JsonReader config to ensure the config-property
"root" matches the property your server-response. See the JsonReader
docs for additional assistance."
* </pre>
* <p>An example of the code used for generating error messages:</p><pre><code>
try {
generateError({
foo: 'bar'
});
}
catch (e) {
console.error(e);
}
function generateError(data) {
throw new Ext.Error('foo-error', data);
}
* </code></pre>
* @param {String} message
*/
Ext.Error = function(message) {
// Try to read the message from Ext.Error.lang
this.message = (this.lang[message]) ? this.lang[message] : message;
};
Ext.Error.prototype = new Error();
Ext.apply(Ext.Error.prototype, {
// protected. Extensions place their error-strings here.
lang: {},
name: 'Ext.Error',
/**
* getName
* @return {String}
*/
getName : function() {
share/ext-all-debug-w-comments.js view on Meta::CPAN
*/
/**
* @cfg {Boolean} allowBlur
* True to {@link #completeEdit complete the editing process} if in edit mode when the
* field is blurred. Defaults to <tt>true</tt>.
*/
allowBlur: true,
/**
* @cfg {Boolean/String} autoSize
* True for the editor to automatically adopt the size of the underlying field, "width" to adopt the width only,
* or "height" to adopt the height only, "none" to always use the field dimensions. (defaults to false)
*/
/**
* @cfg {Boolean} revertInvalid
* True to automatically revert the field value and cancel the edit when the user completes an edit and the field
* validation fails (defaults to true)
*/
/**
* @cfg {Boolean} ignoreNoChange
* True to skip the edit completion process (no save, no events fired) if the user completes an edit and
* the value has not changed (defaults to false). Applies only to string values - edits for other data types
* will never be ignored.
*/
/**
* @cfg {Boolean} hideEl
* False to keep the bound element visible while the editor is displayed (defaults to true)
*/
/**
* @cfg {Mixed} value
* The data value of the underlying field (defaults to "")
*/
value : "",
/**
* @cfg {String} alignment
* The position to align to (see {@link Ext.Element#alignTo} for more details, defaults to "c-c?").
*/
alignment: "c-c?",
/**
* @cfg {Array} offsets
* The offsets to use when aligning (see {@link Ext.Element#alignTo} for more details. Defaults to <tt>[0, 0]</tt>.
*/
offsets: [0, 0],
/**
* @cfg {Boolean/String} shadow "sides" for sides/bottom only, "frame" for 4-way shadow, and "drop"
* for bottom-right shadow (defaults to "frame")
*/
shadow : "frame",
/**
* @cfg {Boolean} constrain True to constrain the editor to the viewport
*/
constrain : false,
/**
* @cfg {Boolean} swallowKeys Handle the keydown/keypress events so they don't propagate (defaults to true)
*/
swallowKeys : true,
/**
* @cfg {Boolean} completeOnEnter True to complete the edit when the enter key is pressed. Defaults to <tt>true</tt>.
*/
completeOnEnter : true,
/**
* @cfg {Boolean} cancelOnEsc True to cancel the edit when the escape key is pressed. Defaults to <tt>true</tt>.
*/
cancelOnEsc : true,
/**
* @cfg {Boolean} updateEl True to update the innerHTML of the bound element when the update completes (defaults to false)
*/
updateEl : false,
initComponent : function(){
Ext.Editor.superclass.initComponent.call(this);
this.addEvents(
/**
* @event beforestartedit
* Fires when editing is initiated, but before the value changes. Editing can be canceled by returning
* false from the handler of this event.
* @param {Editor} this
* @param {Ext.Element} boundEl The underlying element bound to this editor
* @param {Mixed} value The field value being set
*/
"beforestartedit",
/**
* @event startedit
* Fires when this editor is displayed
* @param {Ext.Element} boundEl The underlying element bound to this editor
* @param {Mixed} value The starting field value
*/
"startedit",
/**
* @event beforecomplete
* Fires after a change has been made to the field, but before the change is reflected in the underlying
* field. Saving the change to the field can be canceled by returning false from the handler of this event.
* Note that if the value has not changed and ignoreNoChange = true, the editing will still end but this
* event will not fire since no edit actually occurred.
* @param {Editor} this
* @param {Mixed} value The current field value
* @param {Mixed} startValue The original field value
*/
"beforecomplete",
/**
* @event complete
* Fires after editing is complete and any changed value has been written to the underlying field.
* @param {Editor} this
* @param {Mixed} value The current field value
* @param {Mixed} startValue The original field value
*/
"complete",
/**
* @event canceledit
* Fires after editing has been canceled and the editor's value has been reset.
* @param {Editor} this
* @param {Mixed} value The user-entered field value that was discarded
* @param {Mixed} startValue The original field value that was set back into the editor after cancel
*/
"canceledit",
/**
* @event specialkey
* Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
* {@link Ext.EventObject#getKey} to determine which key was pressed.
* @param {Ext.form.Field} this
* @param {Ext.EventObject} e The event object
*/
share/ext-all-debug-w-comments.js view on Meta::CPAN
* An array of textual day names which can be overriden for localization support (defaults to Date.dayNames)
*/
dayNames : Date.dayNames,
/**
* @cfg {String} nextText
* The next month navigation button tooltip (defaults to <code>'Next Month (Control+Right)'</code>)
*/
nextText : 'Next Month (Control+Right)',
/**
* @cfg {String} prevText
* The previous month navigation button tooltip (defaults to <code>'Previous Month (Control+Left)'</code>)
*/
prevText : 'Previous Month (Control+Left)',
/**
* @cfg {String} monthYearText
* The header month selector tooltip (defaults to <code>'Choose a month (Control+Up/Down to move years)'</code>)
*/
monthYearText : 'Choose a month (Control+Up/Down to move years)',
/**
* @cfg {Number} startDay
* Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
*/
startDay : 0,
/**
* @cfg {Boolean} showToday
* False to hide the footer area containing the Today button and disable the keyboard handler for spacebar
* that selects the current date (defaults to <code>true</code>).
*/
showToday : true,
/**
* @cfg {Date} minDate
* Minimum allowable date (JavaScript date object, defaults to null)
*/
/**
* @cfg {Date} maxDate
* Maximum allowable date (JavaScript date object, defaults to null)
*/
/**
* @cfg {Array} disabledDays
* An array of days to disable, 0-based. For example, [0, 6] disables Sunday and Saturday (defaults to null).
*/
/**
* @cfg {RegExp} disabledDatesRE
* JavaScript regular expression used to disable a pattern of dates (defaults to null). The {@link #disabledDates}
* config will generate this regex internally, but if you specify disabledDatesRE it will take precedence over the
* disabledDates value.
*/
/**
* @cfg {Array} disabledDates
* An array of 'dates' to disable, as strings. These strings will be used to build a dynamic regular
* expression so they are very powerful. Some examples:
* <ul>
* <li>['03/08/2003', '09/16/2003'] would disable those exact dates</li>
* <li>['03/08', '09/16'] would disable those days for every year</li>
* <li>['^03/08'] would only match the beginning (useful if you are using short years)</li>
* <li>['03/../2006'] would disable every day in March 2006</li>
* <li>['^03'] would disable every day in every March</li>
* </ul>
* Note that the format of the dates included in the array should exactly match the {@link #format} config.
* In order to support regular expressions, if you are using a date format that has '.' in it, you will have to
* escape the dot when restricting dates. For example: ['03\\.08\\.03'].
*/
// private
// Set by other components to stop the picker focus being updated when the value changes.
focusOnSelect: true,
// default value used to initialise each date in the DatePicker
// (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
initHour: 12, // 24-hour format
// private
initComponent : function(){
Ext.DatePicker.superclass.initComponent.call(this);
this.value = this.value ?
this.value.clearTime(true) : new Date().clearTime();
this.addEvents(
/**
* @event select
* Fires when a date is selected
* @param {DatePicker} this DatePicker
* @param {Date} date The selected date
*/
'select'
);
if(this.handler){
this.on('select', this.handler, this.scope || this);
}
this.initDisabledDays();
},
// private
initDisabledDays : function(){
if(!this.disabledDatesRE && this.disabledDates){
var dd = this.disabledDates,
len = dd.length - 1,
re = '(?:';
Ext.each(dd, function(d, i){
re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
if(i != len){
re += '|';
}
}, this);
this.disabledDatesRE = new RegExp(re + ')');
}
},
/**
* Replaces any existing disabled dates with new values and refreshes the DatePicker.
* @param {Array/RegExp} disabledDates An array of date strings (see the {@link #disabledDates} config
* for details on supported values), or a JavaScript regular expression used to disable a pattern of dates.
*/
setDisabledDates : function(dd){
if(Ext.isArray(dd)){
this.disabledDates = dd;
this.disabledDatesRE = null;
}else{
this.disabledDatesRE = dd;
}
this.initDisabledDays();
this.update(this.value, true);
},
/**
* Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.
* @param {Array} disabledDays An array of disabled day indexes. See the {@link #disabledDays} config
* for details on supported values.
*/
setDisabledDays : function(dd){
this.disabledDays = dd;
this.update(this.value, true);
},
/**
* Replaces any existing {@link #minDate} with the new value and refreshes the DatePicker.
* @param {Date} value The minimum date that can be selected
*/
setMinDate : function(dt){
this.minDate = dt;
this.update(this.value, true);
},
/**
* Replaces any existing {@link #maxDate} with the new value and refreshes the DatePicker.
* @param {Date} value The maximum date that can be selected
*/
setMaxDate : function(dt){
this.maxDate = dt;
this.update(this.value, true);
},
/**
* Sets the value of the date field
* @param {Date} value The date to set
*/
setValue : function(value){
this.value = value.clearTime(true);
this.update(this.value);
},
share/ext-all-debug-w-comments.js view on Meta::CPAN
Ext.destroy(this.el);
this.el = null;
}
});
/**
* @class Ext.Window
* @extends Ext.Panel
* <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
* {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
* restored to their prior size, and can be {@link #minimize}d.</p>
* <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
* grouping, activation, to front, to back and other application-specific behavior.</p>
* <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
* specify {@link Ext.Component#renderTo renderTo}.</p>
* <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
* destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
* re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
* @constructor
* @param {Object} config The config object
* @xtype window
*/
Ext.Window = Ext.extend(Ext.Panel, {
/**
* @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).
*/
/**
* @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 {String/Element} animateTarget
* Id or element from which the window should animate while opening (defaults to null with no animation).
*/
/**
* @cfg {String} resizeHandles
* A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
*/
/**
* @cfg {Ext.WindowGroup} manager
* A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
*/
/**
* @cfg {String/Number/Component} defaultButton
* <p>Specifies a Component to receive focus when this Window is focussed.</p>
* <p>This may be one of:</p><div class="mdetail-params"><ul>
* <li>The index of a footer Button.</li>
* <li>The id of a Component.</li>
* <li>A Component.</li>
* </ul></div>
*/
/**
* @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 {Boolean} collapsed
* True to render the window collapsed, false to render it expanded (defaults to false). Note that if
* {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
* will always be expanded when shown.
*/
/**
* @cfg {Boolean} maximized
* True to initially display the window in a maximized state. (Defaults to false).
*/
/**
* @cfg {String} baseCls
* The base CSS class to apply to this panel's element (defaults to 'x-window').
*/
baseCls : 'x-window',
/**
* @cfg {Boolean} resizable
* True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
*/
resizable : 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} closable
* <p>True to display the 'close' tool button and allow the user to close the window, false to
* hide the button and disallow closing the window (defaults to true).</p>
* <p>By default, when close is requested by either clicking the close button in the header
* or pressing ESC when the Window has focus, the {@link #close} method will be called. This
* will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
* it may not be reused.</p>
* <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
* {@link #closeAction} to 'hide'.
*/
closable : true,
/**
* @cfg {String} closeAction
* <p>The action to take when the close header tool is clicked:
* <div class="mdetail-params"><ul>
* <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
* {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
* it and all descendant Components. The window will <b>not</b> be available to be
* redisplayed via the {@link #show} method.
* </div></li>
* <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
* {@link #hide} the window by setting visibility to hidden and applying negative offsets.
* The window will be available to be redisplayed via the {@link #show} method.
* </div></li>
* </ul></div>
* <p><b>Note:</b> This setting does not affect the {@link #close} method
* which will always {@link Ext.Component#destroy destroy} the window. To
* programatically <i>hide</i> a window, call {@link #hide}.</p>
*/
share/ext-all-debug-w-comments.js view on Meta::CPAN
constructor : function(){
/**
* @event statechange
* Fires when a state change occurs.
* @param {Provider} this This state provider
* @param {String} key The state key which was changed
* @param {String} value The encoded value for the state
*/
this.addEvents("statechange");
this.state = {};
Ext.state.Provider.superclass.constructor.call(this);
},
/**
* Returns the current value for a key
* @param {String} name The key name
* @param {Mixed} defaultValue A default value to return if the key's value is not found
* @return {Mixed} The state data
*/
get : function(name, defaultValue){
return typeof this.state[name] == "undefined" ?
defaultValue : this.state[name];
},
/**
* Clears a value from the state
* @param {String} name The key name
*/
clear : function(name){
delete this.state[name];
this.fireEvent("statechange", this, name, null);
},
/**
* Sets the value for a key
* @param {String} name The key name
* @param {Mixed} value The value to set
*/
set : function(name, value){
this.state[name] = value;
this.fireEvent("statechange", this, name, value);
},
/**
* Decodes a string previously encoded with {@link #encodeValue}.
* @param {String} value The value to decode
* @return {Mixed} The decoded value
*/
decodeValue : function(cookie){
/**
* a -> Array
* n -> Number
* d -> Date
* b -> Boolean
* s -> String
* o -> Object
* -> Empty (null)
*/
var re = /^(a|n|d|b|s|o|e)\:(.*)$/,
matches = re.exec(unescape(cookie)),
all,
type,
v,
kv;
if(!matches || !matches[1]){
return; // non state cookie
}
type = matches[1];
v = matches[2];
switch(type){
case 'e':
return null;
case 'n':
return parseFloat(v);
case 'd':
return new Date(Date.parse(v));
case 'b':
return (v == '1');
case 'a':
all = [];
if(v != ''){
Ext.each(v.split('^'), function(val){
all.push(this.decodeValue(val));
}, this);
}
return all;
case 'o':
all = {};
if(v != ''){
Ext.each(v.split('^'), function(val){
kv = val.split('=');
all[kv[0]] = this.decodeValue(kv[1]);
}, this);
}
return all;
default:
return v;
}
},
/**
* Encodes a value including type information. Decode with {@link #decodeValue}.
* @param {Mixed} value The value to encode
* @return {String} The encoded value
*/
encodeValue : function(v){
var enc,
flat = '',
i = 0,
len,
key;
if(v == null){
return 'e:1';
}else if(typeof v == 'number'){
enc = 'n:' + v;
}else if(typeof v == 'boolean'){
enc = 'b:' + (v ? '1' : '0');
}else if(Ext.isDate(v)){
enc = 'd:' + v.toGMTString();
}else if(Ext.isArray(v)){
for(len = v.length; i < len; i++){
flat += this.encodeValue(v[i]);
if(i != len - 1){
flat += '^';
}
}
enc = 'a:' + flat;
}else if(typeof v == 'object'){
for(key in v){
if(typeof v[key] != 'function' && v[key] !== undefined){
flat += key + '=' + this.encodeValue(v[key]) + '^';
}
}
enc = 'o:' + flat.substring(0, flat.length-1);
}else{
enc = 's:' + v;
}
return escape(enc);
}
});
/**
* @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>
* @singleton
*/
Ext.state.Manager = function(){
var provider = new Ext.state.Provider();
return {
/**
* Configures the default state provider for your application
* @param {Provider} stateProvider The state provider to set
*/
setProvider : function(stateProvider){
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 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){
provider.set(key, value);
},
/**
* Clears a value from the state
* @param {String} name The key name
*/
clear : function(key){
provider.clear(key);
},
/**
* Gets the currently configured state provider
* @return {Provider} The state provider
*/
share/ext-all-debug-w-comments.js view on Meta::CPAN
/**
* @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
*/
decimalSeparator : ".",
/**
* @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
*/
decimalPrecision : 2,
/**
* @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
*/
allowNegative : true,
/**
* @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
*/
minValue : Number.NEGATIVE_INFINITY,
/**
* @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
*/
maxValue : Number.MAX_VALUE,
/**
* @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
*/
minText : "The minimum value for this field is {0}",
/**
* @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
*/
maxText : "The maximum value for this field is {0}",
/**
* @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
* if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
*/
nanText : "{0} is not a valid number",
/**
* @cfg {String} baseChars The base set of characters to evaluate as valid numbers (defaults to '0123456789').
*/
baseChars : "0123456789",
/**
* @cfg {Boolean} autoStripChars True to automatically strip not allowed characters from the field. Defaults to <tt>false</tt>
*/
autoStripChars: false,
// private
initEvents : function() {
var allowed = this.baseChars + '';
if (this.allowDecimals) {
allowed += this.decimalSeparator;
}
if (this.allowNegative) {
allowed += '-';
}
allowed = Ext.escapeRe(allowed);
this.maskRe = new RegExp('[' + allowed + ']');
if (this.autoStripChars) {
this.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi');
}
Ext.form.NumberField.superclass.initEvents.call(this);
},
/**
* Runs all of NumberFields validations and returns an array of any errors. Note that this first
* runs TextField's validations, so the returned array is an amalgamation of all field errors.
* The additional validations run test that the value is a number, and that it is within the
* configured min and max values.
* @param {Mixed} value The value to get errors for (defaults to the current field value)
* @return {Array} All validation errors for this field
*/
getErrors: function(value) {
var errors = Ext.form.NumberField.superclass.getErrors.apply(this, arguments);
value = Ext.isDefined(value) ? value : this.processValue(this.getRawValue());
if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid
return errors;
}
value = String(value).replace(this.decimalSeparator, ".");
if(isNaN(value)){
errors.push(String.format(this.nanText, value));
}
var num = this.parseValue(value);
if (num < this.minValue) {
errors.push(String.format(this.minText, this.minValue));
}
if (num > this.maxValue) {
errors.push(String.format(this.maxText, this.maxValue));
}
return errors;
},
getValue : function() {
return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
},
setValue : function(v) {
v = Ext.isNumber(v) ? v : parseFloat(String(v).replace(this.decimalSeparator, "."));
v = this.fixPrecision(v);
v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
return Ext.form.NumberField.superclass.setValue.call(this, v);
},
/**
* Replaces any existing {@link #minValue} with the new value.
* @param {Number} value The minimum value
*/
setMinValue : function(value) {
share/ext-all-debug-w-comments.js view on Meta::CPAN
* The error text to display when the date in the field is invalid (defaults to
* <tt>'{value} is not a valid date - it must be in the format {format}'</tt>).
*/
invalidText : "{0} is not a valid date - it must be in the format {1}",
/**
* @cfg {String} triggerClass
* An additional CSS class used to style the trigger button. The trigger will always get the
* class <tt>'x-form-trigger'</tt> and <tt>triggerClass</tt> will be <b>appended</b> if specified
* (defaults to <tt>'x-form-date-trigger'</tt> which displays a calendar icon).
*/
triggerClass : 'x-form-date-trigger',
/**
* @cfg {Boolean} showToday
* <tt>false</tt> to hide the footer area of the DatePicker containing the Today button and disable
* the keyboard handler for spacebar that selects the current date (defaults to <tt>true</tt>).
*/
showToday : true,
/**
* @cfg {Number} startDay
* Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
*/
startDay : 0,
/**
* @cfg {Date/String} minValue
* The minimum allowed date. Can be either a Javascript date object or a string date in a
* valid format (defaults to null).
*/
/**
* @cfg {Date/String} maxValue
* The maximum allowed date. Can be either a Javascript date object or a string date in a
* valid format (defaults to null).
*/
/**
* @cfg {Array} disabledDays
* An array of days to disable, 0 based (defaults to null). Some examples:<pre><code>
// disable Sunday and Saturday:
disabledDays: [0, 6]
// disable weekdays:
disabledDays: [1,2,3,4,5]
* </code></pre>
*/
/**
* @cfg {Array} disabledDates
* An array of "dates" to disable, as strings. These strings will be used to build a dynamic regular
* expression so they are very powerful. Some examples:<pre><code>
// disable these exact dates:
disabledDates: ["03/08/2003", "09/16/2003"]
// disable these days for every year:
disabledDates: ["03/08", "09/16"]
// only match the beginning (useful if you are using short years):
disabledDates: ["^03/08"]
// disable every day in March 2006:
disabledDates: ["03/../2006"]
// disable every day in every March:
disabledDates: ["^03"]
* </code></pre>
* Note that the format of the dates included in the array should exactly match the {@link #format} config.
* In order to support regular expressions, if you are using a {@link #format date format} that has "." in
* it, you will have to escape the dot when restricting dates. For example: <tt>["03\\.08\\.03"]</tt>.
*/
/**
* @cfg {String/Object} autoCreate
* A {@link Ext.DomHelper DomHelper element specification object}, or <tt>true</tt> for the default element
* specification object:<pre><code>
* autoCreate: {tag: "input", type: "text", size: "10", autocomplete: "off"}
* </code></pre>
*/
// private
defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
// in the absence of a time value, a default value of 12 noon will be used
// (note: 12 noon was chosen because it steers well clear of all DST timezone changes)
initTime: '12', // 24 hour format
initTimeFormat: 'H',
// PUBLIC -- to be documented
safeParse : function(value, format) {
if (Date.formatContainsHourInfo(format)) {
// if parse format contains hour information, no DST adjustment is necessary
return Date.parseDate(value, format);
} else {
// set time to 12 noon, then clear the time
var parsedDate = Date.parseDate(value + ' ' + this.initTime, format + ' ' + this.initTimeFormat);
if (parsedDate) {
return parsedDate.clearTime();
}
}
},
initComponent : function(){
Ext.form.DateField.superclass.initComponent.call(this);
this.addEvents(
/**
* @event select
* Fires when a date is selected via the date picker.
* @param {Ext.form.DateField} this
* @param {Date} date The date that was selected
*/
'select'
);
if(Ext.isString(this.minValue)){
this.minValue = this.parseDate(this.minValue);
}
if(Ext.isString(this.maxValue)){
this.maxValue = this.parseDate(this.maxValue);
}
this.disabledDatesRE = null;
this.initDisabledDays();
},
initEvents: function() {
Ext.form.DateField.superclass.initEvents.call(this);
this.keyNav = new Ext.KeyNav(this.el, {
"down": function(e) {
this.onTriggerClick();
},
scope: this,
forceKeyDown: true
});
},
// private
initDisabledDays : function(){
if(this.disabledDates){
var dd = this.disabledDates,
len = dd.length - 1,
re = "(?:";
Ext.each(dd, function(d, i){
re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
if(i != len){
re += '|';
}
}, this);
this.disabledDatesRE = new RegExp(re + ')');
}
},
/**
* Replaces any existing disabled dates with new values and refreshes the DatePicker.
* @param {Array} disabledDates An array of date strings (see the <tt>{@link #disabledDates}</tt> config
* for details on supported values) used to disable a pattern of dates.
*/
setDisabledDates : function(dd){
this.disabledDates = dd;
this.initDisabledDays();
if(this.menu){
this.menu.picker.setDisabledDates(this.disabledDatesRE);
}
},
/**
* Replaces any existing disabled days (by index, 0-6) with new values and refreshes the DatePicker.
* @param {Array} disabledDays An array of disabled day indexes. See the <tt>{@link #disabledDays}</tt>
* config for details on supported values.
*/
setDisabledDays : function(dd){
this.disabledDays = dd;
if(this.menu){
this.menu.picker.setDisabledDays(dd);
}
},
/**
* Replaces any existing <tt>{@link #minValue}</tt> with the new value and refreshes the DatePicker.
* @param {Date} value The minimum date that can be selected
*/
setMinValue : function(dt){
this.minValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
if(this.menu){
this.menu.picker.setMinDate(this.minValue);
}
},
/**
* Replaces any existing <tt>{@link #maxValue}</tt> with the new value and refreshes the DatePicker.
* @param {Date} value The maximum date that can be selected
*/
setMaxValue : function(dt){
this.maxValue = (Ext.isString(dt) ? this.parseDate(dt) : dt);
if(this.menu){
this.menu.picker.setMaxDate(this.maxValue);
}
},
/**
* Runs all of NumberFields validations and returns an array of any errors. Note that this first
* runs TextField's validations, so the returned array is an amalgamation of all field errors.
* The additional validation checks are testing that the date format is valid, that the chosen
* date is within the min and max date constraints set, that the date chosen is not in the disabledDates
share/ext-all-debug-w-comments.js view on Meta::CPAN
this.applyEmptyText();
},
// private
refreshRow : function(record){
if(this.ds.getCount()==1){
this.refresh();
}else{
this.isUpdating = true;
Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);
this.isUpdating = false;
}
},
// private
beforeMenuShow : function(){
var item, items = this.hmenu.items, disabled = this.cm.config[this.hdCtxIndex].groupable === false;
if((item = items.get('groupBy'))){
item.setDisabled(disabled);
}
if((item = items.get('showGroups'))){
item.setDisabled(disabled);
item.setChecked(this.canGroup(), true);
}
},
// private
renderUI : function(){
var markup = Ext.grid.GroupingView.superclass.renderUI.call(this);
if(this.enableGroupingMenu && this.hmenu){
this.hmenu.add('-',{
itemId:'groupBy',
text: this.groupByText,
handler: this.onGroupByClick,
scope: this,
iconCls:'x-group-by-icon'
});
if(this.enableNoGroups){
this.hmenu.add({
itemId:'showGroups',
text: this.showGroupsText,
checked: true,
checkHandler: this.onShowGroupsClick,
scope: this
});
}
this.hmenu.on('beforeshow', this.beforeMenuShow, this);
}
return markup;
},
processEvent: function(name, e){
Ext.grid.GroupingView.superclass.processEvent.call(this, name, e);
var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
if(hd){
// group value is at the end of the string
var field = this.getGroupField(),
prefix = this.getPrefix(field),
groupValue = hd.id.substring(prefix.length),
emptyRe = new RegExp('gp-' + Ext.escapeRe(field) + '--hd');
// remove trailing '-hd'
groupValue = groupValue.substr(0, groupValue.length - 3);
// also need to check for empty groups
if(groupValue || emptyRe.test(hd.id)){
this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
}
if(name == 'mousedown' && e.button == 0){
this.toggleGroup(hd.parentNode);
}
}
},
// private
onGroupByClick : function(){
var grid = this.grid;
this.enableGrouping = true;
grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
grid.fireEvent('groupchange', grid, grid.store.getGroupState());
this.beforeMenuShow(); // Make sure the checkboxes get properly set when changing groups
this.refresh();
},
// private
onShowGroupsClick : function(mi, checked){
this.enableGrouping = checked;
if(checked){
this.onGroupByClick();
}else{
this.grid.store.clearGrouping();
this.grid.fireEvent('groupchange', this, null);
}
},
/**
* Toggle the group that contains the specific row.
* @param {Number} rowIndex The row inside the group
* @param {Boolean} expanded (optional)
*/
toggleRowIndex : function(rowIndex, expanded){
if(!this.canGroup()){
return;
}
var row = this.getRow(rowIndex);
if(row){
this.toggleGroup(this.findGroup(row), expanded);
}
},
/**
* Toggles the specified group if no value is passed, otherwise sets the expanded state of the group to the value passed.
* @param {String} groupId The groupId assigned to the group (see getGroupId)
* @param {Boolean} expanded (optional)
*/
toggleGroup : function(group, expanded){
var gel = Ext.get(group),
id = Ext.util.Format.htmlEncode(gel.id);