if ((typeof(console) == 'undefined') || (typeof(console.log) == 'undefined')) {
return; // alerT?
}
- console.log(s);
+ console.log(s);
},
/**
* Takes an object and converts it to an encoded URL. e.g. Roo.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
* @return {String} The HTML fragment
*/
applyTemplate : function(values){
+ Roo.log(["applyTemplate", values]);
try {
if(this.compiled){
var ls = this.listeners, scope, len = ls.length;
if(len > 0){
this.firing = true;
- var args = Array.prototype.slice.call(arguments, 0);
+
for(var i = 0; i < len; i++){
- var l = ls[i];
- if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
+ var args = Array.prototype.slice.call(arguments, 0);
+ var l = ls[i];
+ args.push(l.options);
+ if(l.fireFn.apply(l.scope||this.obj||window, args) === false){
this.firing = false;
return false;
}
if(!this._mask){
this._mask = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask"}, true);
}
+
this.addClass("x-masked");
this._mask.setDisplayed(true);
if(typeof msg == 'string'){
if(!this._maskMsg){
- this._maskMsg = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask-msg", cn:{tag:'div'}}, true);
+ this._maskMsg = Roo.DomHelper.append(this.dom, {
+ cls: "roo-el-mask-msg",
+ cn: [
+ {
+ tag: 'i',
+ cls: 'fa fa-spinner fa-spin'
+ },
+ {
+ tag: 'div'
+ }
+ ]
+ }, true);
}
var mm = this._maskMsg;
mm.dom.className = msgCls ? "roo-el-mask-msg " + msgCls : "roo-el-mask-msg";
- if (mm.dom.firstChild) { // weird IE issue?
- mm.dom.firstChild.innerHTML = msg;
+ if (mm.dom.lastChild) { // weird IE issue?
+ mm.dom.lastChild.innerHTML = msg;
}
mm.setDisplayed(true);
mm.center(this);
* @class Roo.data.Connection
* @extends Roo.util.Observable
* The class encapsulates a connection to the page's originating domain, allowing requests to be made
- * either to a configured URL, or to a URL specified at request time.<br><br>
- * <p>
+ * either to a configured URL, or to a URL specified at request time.
+ *
* Requests made by this class are asynchronous, and will return immediately. No data from
* the server will be available to the statement immediately following the {@link #request} call.
- * To process returned data, use a callback in the request options object, or an event listener.</p><br>
- * <p>
+ * To process returned data, use a callback in the request options object, or an event listener.
+ *
* Note: If you are doing a file upload, you will not get a normal response object sent back to
* your callback or event handler. Since the upload is handled via in IFRAME, there is no XMLHttpRequest.
* The response object is created using the innerHTML of the IFRAME's document as the responseText
- * property and, if present, the IFRAME's XML document as the responseXML property.</p><br>
+ * property and, if present, the IFRAME's XML document as the responseXML property.
+ *
* This means that a valid XML or HTML document must be returned. If JSON data is required, it is suggested
* that it be placed either inside a <textarea> in an HTML document and retrieved from the responseText
* using a regex, or inside a CDATA section in an XML document and retrieved from the responseXML using
url = url || form.action;
var enctype = form.getAttribute("enctype");
+
+ if (o.formData) {
+ return this.doFormDataUpload(o,p,url);
+ }
+
if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
return this.doFormUpload(o, p, url);
}
url += (url.indexOf('?') != -1 ? '&' : '?') + p;
p = '';
}
+ Roo.lib.Ajax.useDefaultHeader = typeof(o.headers) == 'undefined' || typeof(o.headers['Content-Type']) == 'undefined';
this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
+ Roo.lib.Ajax.useDefaultHeader == true;
return this.transId;
}else{
Roo.callback(o.callback, o.scope, [o, null, null]);
form.removeChild(hiddens[i]);
}
}
+ },
+ // this is a 'formdata version???'
+
+
+ doFormDataUpload : function(o, ps, url)
+ {
+ var form = Roo.getDom(o.form);
+ form.enctype = form.encoding = 'multipart/form-data';
+ var formData = o.formData === true ? new FormData(form) : o.formData;
+
+ var cb = {
+ success: this.handleResponse,
+ failure: this.handleFailure,
+ scope: this,
+ argument: {options: o},
+ timeout : o.timeout || this.timeout
+ };
+
+ if(typeof o.autoAbort == 'boolean'){ // options gets top priority
+ if(o.autoAbort){
+ this.abort();
+ }
+ }else if(this.autoAbort !== false){
+ this.abort();
+ }
+
+ //Roo.lib.Ajax.defaultPostHeader = null;
+ Roo.lib.Ajax.useDefaultHeader = false;
+ this.transId = Roo.lib.Ajax.request( "POST", url, cb, o.formData, o);
+ Roo.lib.Ajax.useDefaultHeader = true;
+
+
}
+
});
/*
* Based on:
* eventually this should probably emulate php's number_format
* @param {Number/String} value The numeric value to format
* @param {Number} decimals number of decimal places
+ * @param {String} delimiter for thousands (default comma)
* @return {String} The formatted currency string
*/
- number : function(v, decimals, thousandsDelimiter = ',')
+ number : function(v, decimals, thousandsDelimiter)
{
// multiply and round.
decimals = typeof(decimals) == 'undefined' ? 2 : decimals;
+ thousandsDelimiter = typeof(thousandsDelimiter) == 'undefined' ? ',' : thousandsDelimiter;
+
var mul = Math.pow(10, decimals);
var zero = String(mul).substring(1);
v = (Math.round((v-0)*mul))/mul;
var r = /(\d+)(\d{3})/;
// add comma's
- while (r.test(whole)) {
- whole = whole.replace(r, '$1' + thousandsDelimiter + '$2');
- }
+ if(thousandsDelimiter.length != 0) {
+ whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsDelimiter );
+ }
var sub = ps[1] ?
// has decimals..
break;
default:
- if (obj.disabled) {
+ if (obj.disabled || obj.region == '#disabled') {
return;
}
break;
msg: msg,
width:450,
progress:true,
+ buttons : false,
closable:false,
modal: false
//
(function() {
+ /**
+ * eval:var:escape
+ * eval:var:unescape
+ * eval:var:replace
+ */
+
+ /**
+ * Helpers
+ */
+
+ var escape = function (html, encode) {
+ return html
+ .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
+ .replace(/</g, '<')
+ .replace(/>/g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+ }
+
+ var unescape = function (html) {
+ // explicitly match decimal, hex, and named HTML entities
+ return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
+ n = n.toLowerCase();
+ if (n === 'colon') { return ':'; }
+ if (n.charAt(0) === '#') {
+ return n.charAt(1) === 'x'
+ ? String.fromCharCode(parseInt(n.substring(2), 16))
+ : String.fromCharCode(+n.substring(1));
+ }
+ return '';
+ });
+ }
+
+ var replace = function (regex, opt) {
+ regex = regex.source;
+ opt = opt || '';
+ return function self(name, val) {
+ if (!name) { return new RegExp(regex, opt); }
+ val = val.source || val;
+ val = val.replace(/(^|[^\[])\^/g, '$1');
+ regex = regex.replace(name, val);
+ return self;
+ };
+ }
+
+
+ /**
+ * eval:var:noop
+ */
+ var noop = function () {}
+ noop.exec = noop;
+
+ /**
+ * eval:var:merge
+ */
+ var merge = function (obj) {
+ var i = 1
+ , target
+ , key;
+
+ for (; i < arguments.length; i++) {
+ target = arguments[i];
+ for (key in target) {
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
+ obj[key] = target[key];
+ }
+ }
+ }
+
+ return obj;
+ }
+
+
/**
* Block-Level Grammar
*/
+
+
+
var block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
* Block Lexer
*/
- function Lexer(options) {
+ var Lexer = function (options) {
this.tokens = [];
this.tokens.links = {};
this.options = options || marked.defaults;
* Inline Lexer & Compiler
*/
- function InlineLexer(links, options) {
+ var InlineLexer = function (links, options) {
this.options = options || marked.defaults;
this.links = links;
this.rules = inline.normal;
* Renderer
*/
- function Renderer(options) {
+ /**
+ * eval:var:Renderer
+ */
+
+ var Renderer = function (options) {
this.options = options || {};
}
/**
* Parsing & Compiling
*/
+ /**
+ * eval:var:Parser
+ */
- function Parser(options) {
+ var Parser= function (options) {
this.tokens = [];
this.token = null;
this.options = options || marked.defaults;
}
}
};
-
- /**
- * Helpers
- */
-
- function escape(html, encode) {
- return html
- .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''');
- }
-
- function unescape(html) {
- // explicitly match decimal, hex, and named HTML entities
- return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
- n = n.toLowerCase();
- if (n === 'colon') { return ':'; }
- if (n.charAt(0) === '#') {
- return n.charAt(1) === 'x'
- ? String.fromCharCode(parseInt(n.substring(2), 16))
- : String.fromCharCode(+n.substring(1));
- }
- return '';
- });
- }
-
- function replace(regex, opt) {
- regex = regex.source;
- opt = opt || '';
- return function self(name, val) {
- if (!name) { return new RegExp(regex, opt); }
- val = val.source || val;
- val = val.replace(/(^|[^\[])\^/g, '$1');
- regex = regex.replace(name, val);
- return self;
- };
- }
-
- function noop() {}
- noop.exec = noop;
-
- function merge(obj) {
- var i = 1
- , target
- , key;
-
- for (; i < arguments.length; i++) {
- target = arguments[i];
- for (key in target) {
- if (Object.prototype.hasOwnProperty.call(target, key)) {
- obj[key] = target[key];
- }
- }
- }
-
- return obj;
- }
-
+
/**
* Marked
*/
-
- function marked(src, opt, callback) {
+ /**
+ * eval:var:marked
+ */
+ var marked = function (src, opt, callback) {
if (callback || typeof opt === 'function') {
if (!callback) {
callback = opt;
}
pending = tokens.length;
-
+ /**
+ * eval:var:done
+ */
var done = function(err) {
if (err) {
opt.highlight = highlight;
if (id) {
this.initTarget(id, sGroup, config);
}
- if (config.listeners || config.events) {
- Roo.dd.DragDrop.superclass.constructor.call(this, {
+ if (config && (config.listeners || config.events)) {
+ Roo.dd.DragDrop.superclass.constructor.call(this, {
listeners : config.listeners || {},
events : config.events || {}
});