var isStrict = document.compatMode == "CSS1Compat",
isOpera = ua.indexOf("opera") > -1,
isSafari = (/webkit|khtml/).test(ua),
+ isFirefox = ua.indexOf("firefox") > -1,
isIE = ua.indexOf("msie") > -1,
isIE7 = ua.indexOf("msie 7") > -1,
+ isIE11 = /trident.*rv\:11\./.test(ua),
isGecko = !isSafari && ua.indexOf("gecko") > -1,
isBorderBox = isIE && !isStrict,
isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
isLinux = (ua.indexOf("linux") != -1),
isSecure = window.location.href.toLowerCase().indexOf("https") === 0,
+ isIOS = /iphone|ipad/.test(ua),
isTouch = (function() {
try {
document.createEvent("TouchEvent");
return c;
}
if (ns[c.xtype]) {
- if (Roo.debug) Roo.log("Roo.Factory(" + c.xtype + ")");
+ if (Roo.debug) { Roo.log("Roo.Factory(" + c.xtype + ")"); }
var ret = new ns[c.xtype](c);
ret.xns = false;
return ret;
/** @type Boolean */
isSafari : isSafari,
/** @type Boolean */
+ isFirefox : isFirefox,
+ /** @type Boolean */
isIE : isIE,
/** @type Boolean */
isIE7 : isIE7,
/** @type Boolean */
+ isIE11 : isIE11,
+ /** @type Boolean */
isGecko : isGecko,
/** @type Boolean */
isBorderBox : isBorderBox,
/** @type Boolean */
isMac : isMac,
/** @type Boolean */
+ isIOS : isIOS,
+ /** @type Boolean */
isTouch : isTouch,
/**
*/
indexOf : function(o){
for (var i = 0, len = this.length; i < len; i++){
- if(this[i] == o) return i;
+ if(this[i] == o) { return i; }
}
return -1;
},
map : function(fun )
{
var len = this.length >>> 0;
- if (typeof fun != "function")
+ if (typeof fun != "function") {
throw new TypeError();
-
+ }
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
- if (i in this)
+ if (i in this) {
res[i] = fun.call(thisp, this[i], i, this);
+ }
}
return res;
});
- /*
+
+/*
* Based on:
* Ext JS Library 1.1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
*/
Date.prototype.add = function(interval, value){
var d = this.clone();
- if (!interval || value === 0) return d;
+ if (!interval || value === 0) { return d; }
switch(interval.toLowerCase()){
case Date.MILLI:
d.setMilliseconds(this.getMilliseconds() + value);
}
b += "<" + o.tag;
for(var attr in o){
- if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
+ if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") { continue; }
if(attr == "style"){
var s = o["style"];
if(typeof s == "function"){
for(var attr in o){
if(attr == "tag" || attr == "ns" ||attr == "xmlns" ||attr == "children" || attr == "cn" || attr == "html" ||
- attr == "style" || typeof o[attr] == "function") continue;
+ attr == "style" || typeof o[attr] == "function") { continue; }
if(attr=="cls" && Roo.isIE){
el.className = o["cls"];
}else{
- if(useSet) el.setAttribute(attr=="cls" ? 'class' : attr, o[attr]);
- else el[attr] = o[attr];
+ if(useSet) { el.setAttribute(attr=="cls" ? 'class' : attr, o[attr]);}
+ else {
+ el[attr] = o[attr];
+ }
}
}
Roo.DomHelper.applyStyles(el, o.style);
if(Roo.isLinux){
cls.push("roo-linux");
}
+ if(Roo.isIOS){
+ cls.push("roo-ios");
+ }
+ if(Roo.isTouch){
+ cls.push("roo-touch");
+ }
if(Roo.isBorderBox){
cls.push('roo-border-box');
}
* @type String
*/
defaultUnit : "px",
+
/**
* Sets the element's visibility mode. When setVisible() is called it
* will use this to determine whether to set the visibility or the display property.
*/
enableDisplayMode : function(display){
this.setVisibilityMode(El.DISPLAY);
- if(typeof display != "undefined") this.originalDisplay = display;
+ if(typeof display != "undefined") { this.originalDisplay = display; }
return this;
},
this.setHeight(oldHeight); // restore original height
this.setHeight(height, animate, duration, function(){
this.unclip();
- if(typeof onComplete == "function") onComplete();
+ if(typeof onComplete == "function") { onComplete(); }
}.createDelegate(this), easing);
}
}.createDelegate(this), 0);
// we wander
var z = 0;
- var dom = this.dom
+ var dom = this.dom;
while (dom && dom.style) {
if (!isNaN(parseInt(dom.style.zIndex))) {
z = Math.max(z, parseInt(dom.style.zIndex));
var el = this.dom;
useSet = typeof useSet == 'undefined' ? (el.setAttribute ? true : false) : useSet;
for(var attr in o){
- if(attr == "style" || typeof o[attr] == "function") continue;
+ if(attr == "style" || typeof o[attr] == "function") { continue; }
if(attr=="cls"){
el.className = o["cls"];
}else{
- if(useSet) el.setAttribute(attr, o[attr]);
- else el[attr] = o[attr];
+ if(useSet) {
+ el.setAttribute(attr, o[attr]);
+ } else {
+ el[attr] = o[attr];
+ }
}
}
if(o.style){
Roo.CompositeElement.prototype = {
isComposite: true,
addElements : function(els){
- if(!els) return this;
+ if(!els) {
+ return this;
+ }
if(typeof els == "string"){
els = Roo.Element.selectorFunction(els);
}
indexOf : function(o){
if(!this.items.indexOf){
for(var i = 0, len = this.items.length; i < len; i++){
- if(this.items[i] == o) return i;
+ if(this.items[i] == o) {
+ return i;
+ }
}
return -1;
}else{
indexOfKey : function(key){
if(!this.keys.indexOf){
for(var i = 0, len = this.keys.length; i < len; i++){
- if(this.keys[i] == key) return i;
+ if(this.keys[i] == key) {
+ return i;
+ }
}
return -1;
}else{
decodeValue : function(cookie){
var re = /^(a|n|d|b|s|o)\:(.*)$/;
var matches = re.exec(unescape(cookie));
- if(!matches || !matches[1]) return; // non state cookie
+ if(!matches || !matches[1]) {
+ return; // non state cookie
+ }
var type = matches[1];
var v = matches[2];
switch(type){
var flat = "";
for(var i = 0, len = v.length; i < len; i++){
flat += this.encodeValue(v[i]);
- if(i != len-1) flat += "^";
+ if(i != len-1) {
+ flat += "^";
+ }
}
enc = "a:" + flat;
}else if(typeof v == "object"){
destroy : true
});
if(!this.id){
- this.id = "ext-comp-" + (++Roo.Component.AUTO_ID);
+ this.id = "roo-comp-" + (++Roo.Component.AUTO_ID);
}
Roo.ComponentMgr.register(this);
Roo.Component.superclass.constructor.call(this);
*/
asFloat : function(s) {
var val = parseFloat(String(s).replace(/,/g, ""));
- if(isNaN(val)) val = 0;
+ if(isNaN(val)) {
+ val = 0;
+ }
return val;
},
*/
asInt : function(s) {
var val = parseInt(String(s).replace(/,/g, ""));
- if(isNaN(val)) val = 0;
+ if(isNaN(val)) {
+ val = 0;
+ }
return val;
}
};/*
}
value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
}
-
return function(r){
return value.test(r.data[property]);
};
* @param {Boolean} anyMatch True to match any part not just the beginning
*/
filter : function(property, value, anyMatch){
-
- if(typeof(property) == 'string'){
- var fn = this.createFilterFn(property, value, anyMatch);
- return fn ? this.filterBy(fn) : this.clearFilter();
- }
-
- var fn = [];
- var afn = [];
-
- var _this = this;
-
- Roo.each(property, function(p){
- if(anyMatch == true){
- afn.push(_this.createFilterFn(p, value, true));
- }
-
- fn.push(_this.createFilterFn(p, value, false));
- });
-
- if(!fn.length && !afn.length){
- return this.clearFilter();
- }
-
- this.snapshot = this.snapshot || this.data;
-
- var filterData = [];
-
- Roo.each(fn, function(f){
- filterData.push(_this.queryBy(f, _this));
- });
-
- Roo.each(afn, function(f){
- filterData.push(_this.queryBy(f, _this));
- });
-
- var data = this.snapshot || this.data;
-
- var r = new Roo.util.MixedCollection();
- r.getKey = data.getKey;
-
- var keys =[];
-
- Roo.each(filterData, function(d){
- var k = d.keys, it = d.items;
- for(var i = 0, len = it.length; i < len; i++){
- if(keys.indexOf(k[i]) == -1){
- r.add(k[i], it[i]);
- }
- }
- });
-
- this.data = r;
- this.fireEvent("datachanged", this);
+ var fn = this.createFilterFn(property, value, anyMatch);
+ return fn ? this.filterBy(fn) : this.clearFilter();
},
/**
* @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
* @cfg {String} root name of the property which contains the Array of row objects.
* @cfg {String} id Name of the property within a row object that contains a record identifier value.
+ * @cfg {Array} fields Array of field definition objects
* @constructor
* Create a new JsonReader
* @param {Object} meta Metadata configuration options
var fctr = this.wrapEl.appendChild(document.createElement("div"));
- this.footer.dataSource = this.store
+ this.footer.dataSource = this.store;
this.footer.container = fctr;
this.footer = Roo.factory(this.footer, Roo);
fctr.insertFirst(this.el);
var re = "(?:";
for(var i = 0; i < dd.length; i++){
re += dd[i];
- if(i != dd.length-1) re += "|";
+ if(i != dd.length-1) {
+ re += "|";
+ }
}
this.disabledDatesRE = new RegExp(re + ")");
}
autoSizeTabs : function(){
var count = this.items.length;
var vcount = count - this.hiddenCount;
- if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) return;
+ if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
+ return;
+ }
var w = Math.max(this.el.getWidth() - this.cpad, 10);
var availWidth = Math.floor(w / vcount);
var b = this.stripBody;
setTabWidth : function(width){
this.currentTabWidth = width;
for(var i = 0, len = this.items.length; i < len; i++) {
- if(!this.items[i].isHidden())this.items[i].setWidth(width);
+ if(!this.items[i].isHidden()) {
+ this.items[i].setWidth(width);
+ }
}
},
{
var v = this.field.dom.value, pageNum;
var increment = (e.shiftKey) ? 10 : 1;
- if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
+ if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
increment *= -1;
+ }
if(!v || isNaN(pageNum = parseInt(v, 10))) {
this.field.dom.value = d.activePage;
return;
// private
snap : function(value, inc, min){
- if(!inc || !value) return value;
+ if(!inc || !value) {
+ return value;
+ }
var newValue = value;
var m = value % inc;
if(m > 0){
t.removeAttribute("title");
e.preventDefault();
}else{
- ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute);
+ ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute) || et.getAttributeNS(cfg.alt_namespace, cfg.attribute) ;
}
if(ttp){
showProc = show.defer(tm.showDelay, tm, [{
// private
tagConfig : {
- namespace : "ext",
+ namespace : "roo", // was ext?? this may break..
+ alt_namespace : "ext",
attribute : "qtip",
width : "width",
target : "target",
tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1"
});
var ul = el.createChild({tag: "ul", cls: "x-menu-list"});
- ul.on(Roo.isTouch ? 'touchstart' : 'click' , this.onClick, this);
+ //disabling touch- as it's causing issues ..
+ //ul.on(Roo.isTouch ? 'touchstart' : 'click' , this.onClick, this);
+ ul.on('click' , this.onClick, this);
+
ul.on("mouseover", this.onMouseOver, this);
ul.on("mouseout", this.onMouseOut, this);
/**
* @cfg {String} cls A CSS class to apply to the field's underlying element.
*/
-
+ // private
+ loadedValue : false,
+
+
// private ??
initComponent : function(){
Roo.form.Field.superclass.initComponent.call(this);
/**
* Returns true if this field has been changed since it was originally loaded and is not disabled.
+ * DEPRICATED - it never worked well - use hasChanged/resetHasChanged.
*/
isDirty : function() {
if(this.disabled) {
return String(this.getValue()) !== String(this.originalValue);
},
+ /**
+ * stores the current value in loadedValue
+ */
+ resetHasChanged : function()
+ {
+ this.loadedValue = String(this.getValue());
+ },
+ /**
+ * checks the current value against the 'loaded' value.
+ * Note - will return false if 'resetHasChanged' has not been called first.
+ */
+ hasChanged : function()
+ {
+ if(this.disabled || this.readOnly) {
+ return false;
+ }
+ return this.loadedValue !== false && String(this.getValue()) !== this.loadedValue;
+ },
+
+
+
// private
afterRender : function(){
Roo.form.Field.superclass.afterRender.call(this);
});
- if(typeof this.minValue == "string") this.minValue = this.parseDate(this.minValue);
- if(typeof this.maxValue == "string") this.maxValue = this.parseDate(this.maxValue);
+ if(typeof this.minValue == "string") {
+ this.minValue = this.parseDate(this.minValue);
+ }
+ if(typeof this.maxValue == "string") {
+ this.maxValue = this.parseDate(this.maxValue);
+ }
this.ddMatch = null;
if(this.disabledDates){
var dd = this.disabledDates;
var re = "(?:";
for(var i = 0; i < dd.length; i++){
re += dd[i];
- if(i != dd.length-1) re += "|";
+ if(i != dd.length-1) {
+ re += "|";
+ }
}
this.ddMatch = new RegExp(re + ")");
}
});
- if(typeof this.minValue == "string") this.minValue = this.parseDate(this.minValue);
- if(typeof this.maxValue == "string") this.maxValue = this.parseDate(this.maxValue);
+ if(typeof this.minValue == "string") {
+ this.minValue = this.parseDate(this.minValue);
+ }
+ if(typeof this.maxValue == "string") {
+ this.maxValue = this.parseDate(this.maxValue);
+ }
this.ddMatch = null;
if(this.disabledDates){
var dd = this.disabledDates;
var re = "(?:";
for(var i = 0; i < dd.length; i++){
re += dd[i];
- if(i != dd.length-1) re += "|";
+ if(i != dd.length-1) {
+ re += "|";
+ }
}
this.ddMatch = new RegExp(re + ")");
}
}
// scroll to?
this.view.select(match);
- var sn = Roo.get(this.view.getSelectedNodes()[0])
+ var sn = Roo.get(this.view.getSelectedNodes()[0]);
sn.scrollIntoView(sn.dom.parentNode, false);
}
}
Roo.form.Checkbox.superclass.onDestroy.call(this);
+ },
+
+ setBoxLabel : function(str)
+ {
+ this.wrap.select('.x-form-cb-label', true).first().dom.innerHTML = str;
}
});/*
this.execCmd('FontSize', v );
},
- onEditorEvent : function(e){
+ onEditorEvent : function(e)
+ {
this.owner.fireEvent('editorevent', this, e);
// this.updateToolbar();
this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
var nodeIsBefore = ss == 1;
var nodeIsAfter = ee == -1;
- if (nodeIsBefore && nodeIsAfter)
+ if (nodeIsBefore && nodeIsAfter) {
return 0; // outer
- if (!nodeIsBefore && nodeIsAfter)
+ }
+ if (!nodeIsBefore && nodeIsAfter) {
return 1; //right trailed.
+ }
- if (nodeIsBefore && !nodeIsAfter)
+ if (nodeIsBefore && !nodeIsAfter) {
return 2; // left trailed.
+ }
// fully contined.
return 3;
},
},
+
/**
* Clean up MS wordisms...
*/
cleanWord : function(node)
{
- var _t = this;
- var cleanWordChildren = function()
- {
- if (!node.childNodes.length) {
- return;
- }
- for (var i = node.childNodes.length-1; i > -1 ; i--) {
- _t.cleanWord(node.childNodes[i]);
- }
- }
if (!node) {
node.parentNode.insertBefore(cn, node);
}
node.parentNode.removeChild(node);
- cleanWordChildren();
+ this.iterateChildren(node, this.cleanWord);
return;
}
// clean styles
node.removeAttribute('style');
}
}
+ this.iterateChildren(node, this.cleanWord);
- cleanWordChildren();
},
+ /**
+ * iterateChildren of a Node, calling fn each time, using this as the scole..
+ * @param {DomNode} node node to iterate children of.
+ * @param {Function} fn method of this class to call on each item.
+ */
+ iterateChildren : function(node, fn)
+ {
+ if (!node.childNodes.length) {
+ return;
+ }
+ for (var i = node.childNodes.length-1; i > -1 ; i--) {
+ fn.call(this, node.childNodes[i])
+ }
+ },
+
+
+ /**
+ * cleanTableWidths.
+ *
+ * Quite often pasting from word etc.. results in tables with column and widths.
+ * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
+ *
+ */
+ cleanTableWidths : function(node)
+ {
+
+
+ if (!node) {
+ this.cleanTableWidths(this.doc.body);
+ return;
+ }
+
+ // ignore list...
+ if (node.nodeName == "#text" || node.nodeName == "#comment") {
+ return;
+ }
+ Roo.log(node.tagName);
+ if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
+ this.iterateChildren(node, this.cleanTableWidths);
+ return;
+ }
+ if (node.hasAttribute('width')) {
+ node.removeAttribute('width');
+ }
+
+
+ if (node.hasAttribute("style")) {
+ // pretty basic...
+
+ var styles = node.getAttribute("style").split(";");
+ var nstyle = [];
+ Roo.each(styles, function(s) {
+ if (!s.match(/:/)) {
+ return;
+ }
+ var kv = s.split(":");
+ if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
+ return;
+ }
+ // what ever is left... we allow.
+ nstyle.push(s);
+ });
+ node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
+ if (!nstyle.length) {
+ node.removeAttribute('style');
+ }
+ }
+
+ this.iterateChildren(node, this.cleanTableWidths);
+
+
+ },
+
+
+
+
domToHTML : function(currentElement, depth, nopadtext) {
depth = depth || 0;
tb.add(
btn('bold'),
btn('italic'),
- btn('underline')
+ btn('underline'),
+ btn('strikethrough')
);
};
if(!this.disable.fontSize){
tabIndex:-1
});
}
+ cmenu.menu.items.push({
+ actiontype : 'tablewidths',
+ html: 'Remove Table Widths',
+ handler: function(a,b) {
+ editorcore.cleanTableWidths();
+ editorcore.syncValue();
+ },
+ tabIndex:-1
+ });
cmenu.menu.items.push({
actiontype : 'word',
html: 'Remove MS Word Formating',
},
tabIndex:-1
});
+
+ cmenu.menu.items.push({
+ actiontype : 'all',
+ html: 'Remove All CSS Classes',
+ handler: function(a,b) {
+
+ var c = Roo.get(editorcore.doc.body);
+ c.select('[class]').each(function(s) {
+ s.dom.className = '';
+ });
+ editorcore.syncValue();
+ },
+ tabIndex:-1
+ });
+
cmenu.menu.items.push({
- actiontype : 'word',
+ actiontype : 'tidy',
html: 'Tidy HTML Source',
handler: function(a,b) {
editorcore.doc.body.innerHTML = editorcore.domToHTML();
btns[frameId + '-bold'].toggle(doc.queryCommandState('bold'));
btns[frameId + '-italic'].toggle(doc.queryCommandState('italic'));
btns[frameId + '-underline'].toggle(doc.queryCommandState('underline'));
+ btns[frameId + '-strikethrough'].toggle(doc.queryCommandState('strikethrough'));
}
if(!this.disable.alignments){
btns[frameId + '-justifyleft'].toggle(doc.queryCommandState('justifyleft'));
text: 'Underline the selected text.',
cls: 'x-html-editor-tip'
},
+ strikethrough : {
+ title: 'Strikethrough',
+ text: 'Strikethrough the selected text.',
+ cls: 'x-html-editor-tip'
+ },
increasefontsize : {
title: 'Grow Text',
text: 'Increase the font size.',
// fixme - these need to be configurable..
-Roo.form.HtmlEditor.ToolbarContext.types
+//Roo.form.HtmlEditor.ToolbarContext.types
Roo.apply(Roo.form.HtmlEditor.ToolbarContext.prototype, {
/**
* Protected method that will not generally be called directly. It triggers
* a toolbar update by reading the markup state of the current selection in the editor.
+ *
+ * Note you can force an update by calling on('editorevent', scope, false)
*/
updateToolbar: function(editor,ev,sel){
return;
}
+
+
// http://developer.yahoo.com/yui/docs/simple-editor.js.html
// selectNode - might want to handle IE?
if (ev &&
tn = sel.tagName.toUpperCase();
- var lastSel = this.tb.selectedNode
+ var lastSel = this.tb.selectedNode;
this.tb.selectedNode = sel;
// if current menu does not match..
- if ((this.tb.name != tn) || (lastSel != this.tb.selectedNode)) {
+
+ if ((this.tb.name != tn) || (lastSel != this.tb.selectedNode) || ev === false) {
this.tb.el.hide();
///console.log("show: " + tn);
},
/**
- * Returns true if any fields in this form have changed since their original load.
+ * DEPRICATED Returns true if any fields in this form have changed since their original load.
* @return Boolean
*/
isDirty : function(){
});
return dirty;
},
-
+
+ /**
+ * Returns true if any fields in this form have changed since their original load. (New version)
+ * @return Boolean
+ */
+
+ hasChanged : function()
+ {
+ var dirty = false;
+ this.items.each(function(f){
+ if(f.hasChanged()){
+ dirty = true;
+ return false;
+ }
+ });
+ return dirty;
+
+ },
+ /**
+ * Resets all hasChanged to 'false' -
+ * The old 'isDirty' used 'original value..' however this breaks reset() and a few other things.
+ * So hasChanged storage is only to be used for this purpose
+ * @return Boolean
+ */
+ resetHasChanged : function()
+ {
+ this.items.each(function(f){
+ f.resetHasChanged();
+ });
+
+ },
+
+
/**
* Performs a predefined action (submit or load) or custom actions you define on this form.
* @param {String} actionName The name of the action type
}
}
}
-
+ this.resetHasChanged();
+
+
Roo.each(this.childForms || [], function (f) {
f.setValues(values);
+ f.resetHasChanged();
});
return this;
Roo.each(this.childForms || [], function (f) {
f.reset();
});
-
+ this.resetHasChanged();
return this;
},
// closure these in so they are only created once.
var alpha = /^[a-zA-Z_]+$/;
var alphanum = /^[a-zA-Z0-9_]+$/;
- var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
+ var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
// All these messages and functions are configurable
replaceTextarea : function()
{
- if ( document.getElementById( this.getId() + '___Frame' ) )
+ if ( document.getElementById( this.getId() + '___Frame' ) ) {
return ;
+ }
//if ( !this.checkBrowser || this._isCompatibleBrowser() )
//{
// We must check the elements firstly using the Id and then the name.
* @class Roo.form.DisplayField
* @extends Roo.form.Field
* A generic Field to display non-editable data.
+ * @cfg {Boolean} closable (true|false) default false
* @constructor
* Creates a new Display Field item.
* @param {Object} config Configuration options
Roo.form.DisplayField = function(config){
Roo.form.DisplayField.superclass.constructor.call(this, config);
+ this.addEvents({
+ /**
+ * @event close
+ * Fires after the click the close btn
+ * @param {Roo.form.DisplayField} this
+ */
+ close : true
+ });
};
Roo.extend(Roo.form.DisplayField, Roo.form.TextField, {
*/
// defaultAutoCreate : { tag: 'input', type: 'hidden', autocomplete: 'off'},
-
+
+ closable : false,
+
onResize : function(){
Roo.form.DisplayField.superclass.onResize.apply(this, arguments);
initEvents : function(){
// Roo.form.Checkbox.superclass.initEvents.call(this);
// has no events...
+
+ if(this.closable){
+ this.closeEl.on('click', this.onClose, this);
+ }
},
this.viewEl = this.wrap.createChild({ tag: 'div', cls: 'x-form-displayfield'});
+ if(this.closable){
+ this.closeEl = this.wrap.createChild({ tag: 'div', cls: 'x-dlg-close'});
+ }
+
if (this.bodyStyle) {
this.viewEl.applyStyles(this.bodyStyle);
}
this.viewEl.dom.innerHTML = html;
Roo.form.DisplayField.superclass.setValue.call(this, v);
+ },
+
+ onClose : function(e)
+ {
+ e.preventDefault();
+
+ this.fireEvent('close', this);
}
});/*
*
pt.x = e.clientX;
pt.y = e.clientY;
if (this.isTouchEvent(e)) {
- pt.x = e.targetTouches[0].clientX
+ pt.x = e.targetTouches[0].clientX;
pt.y = e.targetTouches[0].clientY;
}
var a = this.svgEl.dom.getScreenCTM();
* Performs a layout update.
*/
layout : function(){
- if(this.updating) return;
+ if(this.updating) {
+ return;
+ }
var size = this.getViewSize();
var w = size.width;
var h = size.height;
* @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
*/
collapse : function(skipAnim){
- if(this.collapsed) return;
+ if(this.collapsed) {
+ return;
+ }
this.collapsed = true;
if(this.split){
this.split.el.hide();
* @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
*/
expand : function(e, skipAnim){
- if(e) e.stopPropagation();
- if(!this.collapsed || this.el.hasActiveFx()) return;
+ if(e) {
+ e.stopPropagation();
+ }
+ if(!this.collapsed || this.el.hasActiveFx()) {
+ return;
+ }
if(this.isSlid){
this.afterSlideIn();
skipAnim = true;
beforeSlide: function(){
if(Roo.isGecko){// firefox overflow auto bug workaround
this.bodyEl.clip();
- if(this.tabs) this.tabs.bodyEl.clip();
+ if(this.tabs) {
+ this.tabs.bodyEl.clip();
+ }
if(this.activePanel){
this.activePanel.getEl().clip();
afterSlide : function(){
if(Roo.isGecko){// firefox overflow auto bug workaround
this.bodyEl.unclip();
- if(this.tabs) this.tabs.bodyEl.unclip();
+ if(this.tabs) {
+ this.tabs.bodyEl.unclip();
+ }
if(this.activePanel){
this.activePanel.getEl().unclip();
if(this.activePanel.afterSlide){
this.form = new Roo.form.Form(cfg);
- if ( this.form.allItems.length) this.form.render(el.dom);
+ if ( this.form.allItems.length) {
+ this.form.render(el.dom);
+ }
return this.form;
}
// should only have one of theses..
if(!tpls.hcell){
tpls.hcell = new Roo.Template(
- '<td class="x-grid-hd x-grid-td-{id} {cellId}"><div title="{title}" class="x-grid-hd-inner x-grid-hd-{id}">',
+ '<td class="x-grid-hd x-grid-td-{id} {cellId}"><div " title="{title}" class="x-grid-hd-inner x-grid-hd-{id}">',
'<div class="x-grid-hd-text ' + this.unselectableCls + '" ' + this.unselectable +'>{value}<img class="x-grid-sort-icon" src="', Roo.BLANK_IMAGE_URL, '" /></div>',
"</div></td>"
);
p.cellId = "x-grid-hd-0-" + i;
p.splitId = "x-grid-csplit-0-" + i;
p.id = cm.getColumnId(i);
- p.title = cm.getColumnTooltip(i) || "";
+ p.title = cm.getColumnTooltip(i) || cm.getColumnHeader(i) || "";
p.value = cm.getColumnHeader(i) || "";
p.style = (this.grid.enableColumnResize === false || !cm.isResizable(i) || cm.isFixed(i)) ? 'cursor:default' : '';
if(!cm.isLocked(i)){
if(s){ // splitters not created yet
var pos = 0, locked = true;
for(var i = 0, len = cm.getColumnCount(); i < len; i++){
- if(cm.isHidden(i)) continue;
+ if(cm.isHidden(i)) {
+ continue;
+ }
var w = cm.getColumnWidth(i); // make sure it's a number
if(!cm.isLocked(i) && locked){
pos = 0;
name : typeof name == 'undefined' ? ds.fields.get(i).name : name,
renderer : cm.getRenderer(i),
id : cm.getColumnId(i),
- locked : cm.isLocked(i)
+ locked : cm.isLocked(i),
+ has_editor : cm.isCellEditable(i)
};
}
p.id = c.id;
p.css = p.attr = "";
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
- if(p.value == undefined || p.value === "") p.value = " ";
- if(r.dirty && typeof r.modified[c.name] !== 'undefined'){
- p.css += p.css ? ' x-grid-dirty-cell' : 'x-grid-dirty-cell';
+ if(p.value == undefined || p.value === "") {
+ p.value = " ";
+ }
+ if(c.has_editor){
+ p.css += ' x-grid-editable-cell';
+ }
+ if(c.dirty && typeof r.modified[c.name] !== 'undefined'){
+ p.css += ' x-grid-dirty-cell';
}
var markup = ct.apply(p);
if(!c.locked){
record: r,
rowIndex : rowIndex,
rowClass : ''
- }
+ };
this.grid.fireEvent('rowclass', this, rowcfg);
alt.push(rowcfg.rowClass);
}
p.id = c.id;
p.css = p.attr = "";
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
- if(p.value == undefined || p.value === "") p.value = " ";
+ if(p.value == undefined || p.value === "") {
+ p.value = " ";
+ }
+ //Roo.log(c);
+ if(c.has_editor){
+ p.css += ' x-grid-editable-cell';
+ }
if(r.dirty && typeof r.modified[c.name] !== 'undefined'){
- p.css += p.css ? ' x-grid-dirty-cell' : 'x-grid-dirty-cell';
+ p.css += ' x-grid-dirty-cell'
}
var markup = ct.apply(p);
record: r,
rowIndex : rowIndex,
rowClass : ''
- }
+ };
this.grid.fireEvent('rowclass', this, rowcfg);
alt.push(rowcfg.rowClass);
}
+
rp.alt = alt.join(" ");
rp.cells = lcb.join("");
lbuf[lbuf.length] = rt.apply(rp);
};
var renderer = cm.getRenderer(colIndex);
var val = renderer(dm.getValueAt(rowIndex, dataIndex), p, rowIndex, colIndex, dm);
- if(typeof val == "undefined" || val === "") val = " ";
+ if(typeof val == "undefined" || val === "") {
+ val = " ";
+ }
cellText.innerHTML = val;
cell.className = this.cellClass + " " + this.idToCssName(p.cellId) + " " + p.css;
this.syncRowHeights(rowIndex, rowIndex);
s.setSize(vw, vh);
var bt = this.getBodyTable();
+
+ if(cm.getLockedCount() == cm.config.length){
+ bt = this.getLockedTable();
+ }
+
var ltWidth = hasLock ?
Math.max(this.getLockedTable().offsetWidth, this.lockedHd.dom.firstChild.offsetWidth) : 0;
/**
* @cfg {String} tooltip (Optional)
*/
+ /**
+ * @cfg {Number} xs (Optional)
+ */
+ /**
+ * @cfg {Number} sm (Optional)
+ */
+ /**
+ * @cfg {Number} md (Optional)
+ */
+ /**
+ * @cfg {Number} lg (Optional)
+ */
/**
* Returns the id of the column at the specified index.
* @param {Number} index The column index
return i;
}
}
+
+ return this.config.length;
},
/**
/**
* Returns true if the cell is editable.
* @param {Number} colIndex The column index
- * @param {Number} rowIndex The row index
+ * @param {Number} rowIndex The row index - this is nto actually used..?
* @return {Boolean}
*/
isCellEditable : function(colIndex, rowIndex){
s.each(function(r){
if((i = ds.indexOfId(r.id)) != -1){
v.onRowSelect(i);
+ s.add(ds.getAt(i)); // updating the selection relate data
}else{
s.remove(r);
}
* Clears all selections.
*/
clearSelections : function(fast){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
if(fast !== true){
var ds = this.grid.dataSource;
var s = this.selections;
* Selects all rows.
*/
selectAll : function(){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
this.selections.clear();
for(var i = 0, len = this.grid.dataSource.getCount(); i < len; i++){
this.selectRow(i, true);
* @param {Boolean} keepExisting (optional) True to retain existing selections
*/
selectRange : function(startRow, endRow, keepExisting){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
if(!keepExisting){
this.clearSelections();
}
* @param {Number} endRow The index of the last row in the range
*/
deselectRange : function(startRow, endRow, preventViewNotify){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
for(var i = startRow; i <= endRow; i++){
this.deselectRow(i, preventViewNotify);
}
* @param {Boolean} keepExisting (optional) True to keep existing selections
*/
selectRow : function(index, keepExisting, preventViewNotify){
- if(this.locked || (index < 0 || index >= this.grid.dataSource.getCount())) return;
+ if(this.locked || (index < 0 || index >= this.grid.dataSource.getCount())) {
+ return;
+ }
if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
if(!keepExisting || this.singleSelect){
this.clearSelections();
* @param {Number} row The index of the row to deselect
*/
deselectRow : function(index, preventViewNotify){
- if(this.locked) return;
+ if(this.locked) {
+ return;
+ }
if(this.last == index){
this.last = false;
}
cancel:false,
editor: ed
};
- var cell = Roo.get(this.view.getCell(ed.row,ed.col))
+ var cell = Roo.get(this.view.getCell(ed.row,ed.col));
cell.show();
if(String(value) !== String(startValue)){