isIE = ua.indexOf("msie") > -1,
isIE7 = ua.indexOf("msie 7") > -1,
isIE11 = /trident.*rv\:11\./.test(ua),
+ isEdge = ua.indexOf("edge") > -1,
isGecko = !isSafari && ua.indexOf("gecko") > -1,
isBorderBox = isIE && !isStrict,
isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
isLinux = (ua.indexOf("linux") != -1),
isSecure = window.location.href.toLowerCase().indexOf("https") === 0,
isIOS = /iphone|ipad/.test(ua),
+ isAndroid = /android/.test(ua),
isTouch = (function() {
try {
if (ua.indexOf('chrome') != -1 && ua.indexOf('android') == -1) {
/** @type Boolean */
isIE11 : isIE11,
/** @type Boolean */
+ isEdge : isEdge,
+ /** @type Boolean */
isGecko : isGecko,
/** @type Boolean */
isBorderBox : isBorderBox,
/** @type Boolean */
isIOS : isIOS,
/** @type Boolean */
+ isAndroid : isAndroid,
+ /** @type Boolean */
isTouch : isTouch,
/**
return Roo.util.Format.htmlEncode(args[i]);
});
}
+
+
});
/**
String.prototype.toggle = function(value, other){
return this == value ? other : value;
-};/*
+};
+
+
+/**
+ * Remove invalid unicode characters from a string
+ *
+ * @return {String} The clean string
+ */
+String.prototype.unicodeClean = function () {
+ return this.replace(/[\s\S]/g,
+ function(character) {
+ if (character.charCodeAt()< 256) {
+ return character;
+ }
+ try {
+ encodeURIComponent(character);
+ } catch(e) {
+ return '';
+ }
+ return character;
+ }
+ );
+};
+
+/*
* Based on:
* Ext JS Library 1.1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
if(o.buffer){
h = createBuffered(h, o);
}
+
fn._handlers = fn._handlers || [];
var cls = [
Roo.isIE ? "roo-ie"
+ : Roo.isIE11 ? "roo-ie11"
+ : Roo.isEdge ? "roo-edge"
: Roo.isGecko ? "roo-gecko"
: Roo.isOpera ? "roo-opera"
: Roo.isSafari ? "roo-safari" : ""];
var p = Roo.fly(this.dom.parentNode, '_internal');
return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
},
+
+ /**
+ * Looks at the scrollable parent element
+ */
+ findScrollableParent : function()
+ {
+ var overflowRegex = /(auto|scroll)/;
+
+ if(this.getStyle('position') === 'fixed'){
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ }
+
+ var excludeStaticParent = this.getStyle('position') === "absolute";
+
+ for (var parent = this; (parent = Roo.get(parent.dom.parentNode));){
+
+ if (excludeStaticParent && parent.getStyle('position') === "static") {
+ continue;
+ }
+
+ if (overflowRegex.test(parent.getStyle('overflow') + parent.getStyle('overflow-x') + parent.getStyle('overflow-y'))){
+ return parent;
+ }
+
+ if(parent.dom.nodeName.toLowerCase() == 'body'){
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ }
+ }
+
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ },
/**
* Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).
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);
* 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)
+ 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 ps = v.split('.');
var whole = ps[0];
-
var r = /(\d+)(\d{3})/;
// add comma's
- while (r.test(whole)) {
- whole = whole.replace(r, '$1' + ',' + '$2');
- }
+ if(thousandsDelimiter.length != 0) {
+ whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsDelimiter );
+ }
var sub = ps[1] ?
// has decimals..
* @param {String/HTMLElement/Element} container (optional) The element this component should be rendered into. If it is being applied to existing markup, this should be left off.
*/
render : function(container, position){
- if(!this.rendered && this.fireEvent("beforerender", this) !== false){
- if(!container && this.el){
- this.el = Roo.get(this.el);
- container = this.el.dom.parentNode;
- this.allowDomMove = false;
- }
- this.container = Roo.get(container);
- this.rendered = true;
- if(position !== undefined){
- if(typeof position == 'number'){
- position = this.container.dom.childNodes[position];
- }else{
- position = Roo.getDom(position);
- }
- }
- this.onRender(this.container, position || null);
- if(this.cls){
- this.el.addClass(this.cls);
- delete this.cls;
- }
- if(this.style){
- this.el.applyStyles(this.style);
- delete this.style;
- }
- this.fireEvent("render", this);
- this.afterRender(this.container);
- if(this.hidden){
- this.hide();
- }
- if(this.disabled){
- this.disable();
+
+ if(this.rendered){
+ return this;
+ }
+
+ if(this.fireEvent("beforerender", this) === false){
+ return false;
+ }
+
+ if(!container && this.el){
+ this.el = Roo.get(this.el);
+ container = this.el.dom.parentNode;
+ this.allowDomMove = false;
+ }
+ this.container = Roo.get(container);
+ this.rendered = true;
+ if(position !== undefined){
+ if(typeof position == 'number'){
+ position = this.container.dom.childNodes[position];
+ }else{
+ position = Roo.getDom(position);
}
}
+ this.onRender(this.container, position || null);
+ if(this.cls){
+ this.el.addClass(this.cls);
+ delete this.cls;
+ }
+ if(this.style){
+ this.el.applyStyles(this.style);
+ delete this.style;
+ }
+ this.fireEvent("render", this);
+ this.afterRender(this.container);
+ if(this.hidden){
+ this.hide();
+ }
+ if(this.disabled){
+ this.disable();
+ }
+
return this;
+
},
/** @private */
* Our builder application needs the ability to preview these sub compoennts. They will normally have parent=false set,
* hence confusing the component builder as it thinks there are multiple top level elements.
*
+ * String Over-ride & Translations
+ *
+ * Our builder application writes all the strings as _strings and _named_strings. This is to enable the translation of elements,
+ * and also the 'overlaying of string values - needed when different versions of the same application with different text content
+ * are needed. @see Roo.XComponent.overlayString
+ *
*
*
* @extends Roo.util.Observable
" of " + total +
(m.name ? (' - ' + m.name) : '');
Roo.debug && Roo.log(msg);
- if (!this.hideProgress && Roo.MessageBox) {
+ if (!_this.hideProgress && Roo.MessageBox) {
Roo.MessageBox.updateProgress( (total - mods.length)/total, msg );
}
},
-
+ /**
+ * Overlay a set of modified strings onto a component
+ * This is dependant on our builder exporting the strings and 'named strings' elements.
+ *
+ * @param {Object} element to overlay on - eg. Pman.Dialog.Login
+ * @param {Object} associative array of 'named' string and it's new value.
+ *
+ */
+ overlayStrings : function( component, strings )
+ {
+ if (typeof(component['_named_strings']) == 'undefined') {
+ throw "ERROR: component does not have _named_strings";
+ }
+ for ( var k in strings ) {
+ var md = typeof(component['_named_strings'][k]) == 'undefined' ? false : component['_named_strings'][k];
+ if (md !== false) {
+ component['_strings'][md] = strings[k];
+ } else {
+ Roo.log('could not find named string: ' + k + ' in');
+ Roo.log(component);
+ }
+
+ }
+
+ },
+
/**
* Event Object.
remove : function(record){
var index = this.data.indexOf(record);
this.data.removeAt(index);
+
if(this.pruneModifiedRecords){
this.modified.remove(record);
}
this.totalLength = Math.max(t, this.data.length+r.length);
this.add(r);
}
+
+ if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
+
+ var e = new Roo.data.Record({});
+
+ e.set(this.parent.displayField, this.parent.emptyTitle);
+ e.set(this.parent.valueField, '');
+
+ this.insert(0, e);
+ }
+
this.fireEvent("load", this, r, options, o);
if(options.callback){
options.callback.call(options.scope || this, r, options, true);
if(ttp){
showProc = show.defer(tm.showDelay, tm, [{
el: t,
- text: ttp,
+ text: ttp.replace(/\\n/g,'<br/>'),
width: et.getAttributeNS(ns, cfg.width),
autoHide: et.getAttributeNS(ns, cfg.hide) != "user",
title: et.getAttributeNS(ns, cfg.title),
*/
reset : function(){
this.setValue(this.resetValue);
+ this.originalValue = this.getValue();
this.clearInvalid();
},
reset : function(){
// overridden so that last data is reset..
this.setValue(this.resetValue);
+ this.originalValue = this.getValue();
this.clearInvalid();
this.lastData = false;
if (this.view) {
black: false,
white: false,
-
+ bodyCls : '',
/**
* Protected method that will not generally be called directly. It
'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
'</style>';
} else {
-
+ st = '<style type="text/css">' +
+ this.stylesheets +
+ '</style>';
}
st += '<style type="text/css">' +
'IMG { cursor: pointer } ' +
'</style>';
+ var cls = 'roo-htmleditor-body';
+
+ if(this.bodyCls.length){
+ cls += ' ' + this.bodyCls;
+ }
return '<html><head>' + st +
//<style type="text/css">' +
//'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
//'</style>' +
- ' </head><body class="roo-htmleditor-body"></body></html>';
+ ' </head><body class="' + cls + '"></body></html>';
},
// private
insertAtCursor : function(text)
{
-
-
if(!this.activated){
return;
}
if (v.match(/^\./) || v.match(/^\//)) {
return;
}
- if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
+ if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
return;
}
if (v.match(/^#/)) {
node.className = '';
}
- if (a.value.match(/body/)) {
+ if (a.value.match(/^body$/)) {
node.className = '';
}
continue;
Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
s.remove();
});
+ },
+
+ setStyle : function(style)
+ {
+ Roo.get(this.iframe.contentDocument.head).createChild({
+ tag : 'style',
+ type : 'text/css',
+ html : style
+ });
+
+ return;
}
// hide stuff that is not compatible
/**
* @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
*/
+ /**
+ * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
+ */
/**
* @cfg {String} cursor (Optional)
*/
}
*/
-
-
- this.el.unmask(this.removeMask);
+ (function() { this.el.unmask(this.removeMask); }).defer(50, this);
},
// private
onLoad : function()
{
- this.el.unmask(this.removeMask);
+ (function() { this.el.unmask(this.removeMask); }).defer(50, this);
},
// private
onBeforeLoad : function(){
if(!this.disabled){
- this.el.mask(this.msg, this.msgCls);
+ (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
}
},