this.tpl = depreciated_tpl;
Roo.apply(this, depreciated_config);
}
-
+ this.wrapEl = this.el.wrap().wrap();
+ ///this.el = this.wrapEla.appendChild(document.createElement("div"));
+
if(typeof(this.tpl) == "string"){
this.tpl = new Roo.Template(this.tpl);
this.tpl.compile();
-
+
+
/** @private */
this.addEvents({
* @param {Object} data to be rendered (change this)
*/
"preparedata" : true
+
+
});
+
+
this.el.on({
"click": this.onClick,
"dblclick": this.onDblClick,
this.store = Roo.factory(this.store, Roo.data);
this.setStore(this.store, true);
}
+
+ if ( this.footer && this.footer.xtype) {
+
+ var fctr = this.wrapEl.appendChild(document.createElement("div"));
+
+ this.footer.dataSource = this.store
+ this.footer.container = fctr;
+ this.footer = Roo.factory(this.footer, Roo);
+ fctr.insertFirst(this.el);
+
+ // this is a bit insane - as the paging toolbar seems to detach the el..
+// dom.parentNode.parentNode.parentNode
+ // they get detached?
+ }
+
+
Roo.View.superclass.constructor.call(this);
+
+
};
Roo.extend(Roo.View, Roo.util.Observable, {
* @return {Roo.Element}
*/
getEl : function(){
- return this.el;
+ return this.wrapEl;
},
+
+
/**
* Refreshes the view. - called by datachanged on the store. - do not call directly.
// private
updateChildSize : function(){
+
if(this.resizeChild){
+ Roo.log('in?');
var el = this.el;
var child = this.resizeChild;
var adj = this.adjustments;
if(tag == 'input'){
return w + 2;
}
- if(tag = 'textarea'){
+ if(tag == 'textarea'){
return w-2;
}
}else if(Roo.isOpera){
if(tag == 'input'){
return w + 2;
}
- if(tag = 'textarea'){
+ if(tag == 'textarea'){
return w-2;
}
}
if (!li.length) {
return;
}
- add = {};
+ var add = {};
add[this.valueField] = k;
add[this.displayField] = li.item(0).data[this.displayField];
*/
getGroupValue : function(){
return this.el.up('form').child('input[name='+this.el.dom.name+']:checked', true).value;
- }
+ },
+
+
+ onRender : function(ct, position){
+ Roo.form.Checkbox.superclass.onRender.call(this, ct, position);
+
+ if(this.inputValue !== undefined){
+ this.el.dom.value = this.inputValue;
+ }
+
+ this.wrap = this.el.wrap({cls: "x-form-check-wrap"});
+ //this.wrap = this.el.wrap({cls: 'x-menu-check-item '});
+ //var viewEl = this.wrap.createChild({
+ // tag: 'img', cls: 'x-menu-item-icon', style: 'margin: 0px;' ,src : Roo.BLANK_IMAGE_URL });
+ //this.viewEl = viewEl;
+ //this.wrap.on('click', this.onClick, this);
+
+ //this.el.on('DOMAttrModified', this.setFromHidden, this); //ff
+ //this.el.on('propertychange', this.setFromHidden, this); //ie
+
+
+
+ if(this.boxLabel){
+ this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
+ // viewEl.on('click', this.onClick, this);
+ }
+ if(this.checked){
+ this.el.dom.checked = 'checked' ;
+ }
+
+ }
+
+
});//<script type="text/javascript">
/*
insertTag : function(tg)
{
// could be a bit smarter... -> wrap the current selected tRoo..
- if (tg.toLowerCase() == 'span') {
+ if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
range = this.createRange(this.getSelection());
- var wrappingNode = this.doc.createElement("span");
+ var wrappingNode = this.doc.createElement(tg.toLowerCase());
wrappingNode.appendChild(range.extractContents());
range.insertNode(wrappingNode);
return;
}
var v = f.getValue();
+ if (f.inputType =='radio') {
+ if (typeof(ret[f.getName()]) == 'undefined') {
+ ret[f.getName()] = ''; // empty..
+ }
+
+ if (!f.el.dom.checked) {
+ return;
+
+ }
+ v = f.el.dom.value;
+
+ }
+
// not sure if this supported any more..
if ((typeof(v) == 'object') && f.getRawValue) {
v = f.getRawValue() ; // dates..
this.value = v;
}
+});/*
+ * Based on:
+ * Ext JS Library 1.1.1
+ * Copyright(c) 2006-2007, Ext JS, LLC.
+ *
+ * Originally Released Under LGPL - original licence link has changed is not relivant.
+ *
+ * Fork - LGPL
+ * <script type="text/javascript">
+ */
+
+/**
+ * @class Roo.form.Signature
+ * @extends Roo.form.Field
+ * Signature field.
+ * @constructor
+ *
+ * @param {Object} config Configuration options
+ */
+
+Roo.form.Signature = function(config){
+ Roo.form.Signature.superclass.constructor.call(this, config);
+
+ this.addEvents({// not in used??
+ /**
+ * @event confirm
+ * Fires when the 'confirm' icon is pressed (add a listener to enable add button)
+ * @param {Roo.form.Signature} combo This combo box
+ */
+ 'confirm' : true,
+ /**
+ * @event reset
+ * Fires when the 'edit' icon is pressed (add a listener to enable add button)
+ * @param {Roo.form.ComboBox} combo This combo box
+ * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
+ */
+ 'reset' : true
+ });
+};
+
+Roo.extend(Roo.form.Signature, Roo.form.Field, {
+ /**
+ * @cfg {Object} labels Label to use when rendering a form.
+ * defaults to
+ * labels : {
+ * clear : "Clear",
+ * confirm : "Confirm"
+ * }
+ */
+ labels : {
+ clear : "Clear",
+ confirm : "Confirm"
+ },
+ /**
+ * @cfg {Number} width The signature panel width (defaults to 300)
+ */
+ width: 300,
+ /**
+ * @cfg {Number} height The signature panel height (defaults to 100)
+ */
+ height : 100,
+ /**
+ * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to false)
+ */
+ allowBlank : false,
+
+ //private
+ // {Object} signPanel The signature SVG panel element (defaults to {})
+ signPanel : {},
+ // {Boolean} isMouseDown False to validate that the mouse down event (defaults to false)
+ isMouseDown : false,
+ // {Boolean} isConfirmed validate the signature is confirmed or not for submitting form (defaults to false)
+ isConfirmed : false,
+ // {String} signatureTmp SVG mapping string (defaults to empty string)
+ signatureTmp : '',
+
+
+ defaultAutoCreate : { // modified by initCompnoent..
+ tag: "input",
+ type:"hidden"
+ },
+
+ // private
+ onRender : function(ct, position){
+
+ Roo.form.Signature.superclass.onRender.call(this, ct, position);
+
+ this.wrap = this.el.wrap({
+ cls:'x-form-signature-wrap', style : 'width: ' + this.width + 'px', cn:{cls:'x-form-signature'}
+ });
+
+ this.createToolbar(this);
+ this.signPanel = this.wrap.createChild({
+ tag: 'div',
+ style: 'width: ' + this.width + 'px; height: ' + this.height + 'px; border: 0;'
+ }, this.el
+ );
+
+ this.svgID = Roo.id();
+ this.svgEl = this.signPanel.createChild({
+ xmlns : 'http://www.w3.org/2000/svg',
+ tag : 'svg',
+ id : this.svgID + "-svg",
+ width: this.width,
+ height: this.height,
+ viewBox: '0 0 '+this.width+' '+this.height,
+ cn : [
+ {
+ tag: "rect",
+ id: this.svgID + "-svg-r",
+ width: this.width,
+ height: this.height,
+ fill: "#ffa"
+ },
+ {
+ tag: "line",
+ id: this.svgID + "-svg-l",
+ x1: "0", // start
+ y1: (this.height*0.8), // start set the line in 80% of height
+ x2: this.width, // end
+ y2: (this.height*0.8), // end set the line in 80% of height
+ 'stroke': "#666",
+ 'stroke-width': "1",
+ 'stroke-dasharray': "3",
+ 'shape-rendering': "crispEdges",
+ 'pointer-events': "none"
+ },
+ {
+ tag: "path",
+ id: this.svgID + "-svg-p",
+ 'stroke': "navy",
+ 'stroke-width': "3",
+ 'fill': "none",
+ 'pointer-events': 'none'
+ }
+ ]
+ });
+ this.createSVG();
+ this.svgBox = this.svgEl.dom.getScreenCTM();
+ },
+ createSVG : function(){
+ var svg = this.signPanel;
+ var r = svg.select('#'+ this.svgID + '-svg-r', true).first().dom;
+ var t = this;
+
+ r.addEventListener('mousedown', function(e) { return t.down(e); }, false);
+ r.addEventListener('mousemove', function(e) { return t.move(e); }, false);
+ r.addEventListener('mouseup', function(e) { return t.up(e); }, false);
+ r.addEventListener('mouseout', function(e) { return t.up(e); }, false);
+ r.addEventListener('touchstart', function(e) { return t.down(e); }, false);
+ r.addEventListener('touchmove', function(e) { return t.move(e); }, false);
+ r.addEventListener('touchend', function(e) { return t.up(e); }, false);
+
+ },
+ isTouchEvent : function(e){
+ return e.type.match(/^touch/);
+ },
+ getCoords : function (e) {
+ var pt = this.svgEl.dom.createSVGPoint();
+ pt.x = e.clientX;
+ pt.y = e.clientY;
+ if (this.isTouchEvent(e)) {
+ pt.x = e.targetTouches[0].clientX
+ pt.y = e.targetTouches[0].clientY;
+ }
+ var a = this.svgEl.dom.getScreenCTM();
+ var b = a.inverse();
+ var mx = pt.matrixTransform(b);
+ return mx.x + ',' + mx.y;
+ },
+ //mouse event headler
+ down : function (e) {
+ this.signatureTmp += 'M' + this.getCoords(e) + ' ';
+ this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr('d', this.signatureTmp);
+
+ this.isMouseDown = true;
+
+ e.preventDefault();
+ },
+ move : function (e) {
+ if (this.isMouseDown) {
+ this.signatureTmp += 'L' + this.getCoords(e) + ' ';
+ this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', this.signatureTmp);
+ }
+
+ e.preventDefault();
+ },
+ up : function (e) {
+ this.isMouseDown = false;
+ var sp = this.signatureTmp.split(' ');
+
+ if(sp.length > 1){
+ if(!sp[sp.length-2].match(/^L/)){
+ sp.pop();
+ sp.pop();
+ sp.push("");
+ this.signatureTmp = sp.join(" ");
+ }
+ }
+ if(this.getValue() != this.signatureTmp){
+ this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#ffa');
+ this.isConfirmed = false;
+ }
+ e.preventDefault();
+ },
+
+ /**
+ * Protected method that will not generally be called directly. It
+ * is called when the editor creates its toolbar. Override this method if you need to
+ * add custom toolbar buttons.
+ * @param {HtmlEditor} editor
+ */
+ createToolbar : function(editor){
+ function btn(id, toggle, handler){
+ var xid = fid + '-'+ id ;
+ return {
+ id : xid,
+ cmd : id,
+ cls : 'x-btn-icon x-edit-'+id,
+ enableToggle:toggle !== false,
+ scope: editor, // was editor...
+ handler:handler||editor.relayBtnCmd,
+ clickEvent:'mousedown',
+ tooltip: etb.buttonTips[id] || undefined, ///tips ???
+ tabIndex:-1
+ };
+ }
+
+
+ var tb = new Roo.Toolbar(editor.wrap.dom.firstChild);
+ this.tb = tb;
+ this.tb.add(
+ {
+ cls : ' x-signature-btn x-signature-'+id,
+ scope: editor, // was editor...
+ handler: this.reset,
+ clickEvent:'mousedown',
+ text: this.labels.clear
+ },
+ {
+ xtype : 'Fill',
+ xns: Roo.Toolbar
+ },
+ {
+ cls : ' x-signature-btn x-signature-'+id,
+ scope: editor, // was editor...
+ handler: this.confirmHandler,
+ clickEvent:'mousedown',
+ text: this.labels.confirm
+ }
+ );
+
+ },
+ //public
+ /**
+ * when user is clicked confirm then show this image.....
+ *
+ * @return {String} Image Data URI
+ */
+ getImageDataURI : function(){
+ var svg = this.svgEl.dom.parentNode.innerHTML;
+ var src = 'data:image/svg+xml;base64,'+window.btoa(svg);
+ return src;
+ },
+ /**
+ *
+ * @return {Boolean} this.isConfirmed
+ */
+ getConfirmed : function(){
+ return this.isConfirmed;
+ },
+ /**
+ *
+ * @return {Number} this.width
+ */
+ getWidth : function(){
+ return this.width;
+ },
+ /**
+ *
+ * @return {Number} this.height
+ */
+ getHeight : function(){
+ return this.height;
+ },
+ // private
+ getSignature : function(){
+ return this.signatureTmp;
+ },
+ // private
+ reset : function(){
+ this.signatureTmp = '';
+ this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#ffa');
+ this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', '');
+ this.isConfirmed = false;
+ Roo.form.Signature.superclass.reset.call(this);
+ },
+ setSignature : function(s){
+ this.signatureTmp = s;
+ this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#ffa');
+ this.signPanel.select('#'+ this.svgID + '-svg-p', true).first().attr( 'd', s);
+ this.setValue(s);
+ this.isConfirmed = false;
+ Roo.form.Signature.superclass.reset.call(this);
+ },
+ test : function(){
+// Roo.log(this.signPanel.dom.contentWindow.up())
+ },
+ //private
+ setConfirmed : function(){
+
+
+
+// Roo.log(Roo.get(this.signPanel.dom.contentWindow.r).attr('fill', '#cfc'));
+ },
+ // private
+ confirmHandler : function(){
+ if(!this.getSignature()){
+ return;
+ }
+ this.signPanel.select('#'+ this.svgID + '-svg-r', true).first().attr('fill', '#cfc');
+ this.setValue(this.getSignature());
+ this.isConfirmed = true;
+
+ Roo.log('in confirm clicked');
+//
+// var valid = true;
+// this.items.each(function(f){
+// if(!f.isValid(true)){
+// valid = false;
+// return false;
+// }
+// });
+// for(var i = 0, len = this.buttons.length; i < len; i++){
+// var btn = this.buttons[i];
+// if(btn.formBind === true && btn.disabled === valid){
+// btn.setDisabled(!valid);
+// }
+// }
+ this.fireEvent('confirm', this);
+ },
+ // private
+ // Subclasses should provide the validation implementation by overriding this
+ validateValue : function(value){
+ if(this.allowBlank){
+ return true;
+ }
+
+ if(this.isConfirmed){
+ return true;
+ }
+ return false;
+ }
});//<script type="text/javasscript">
{
case 'ContentPanel': // ContentPanel (el, cfg)
case 'ScrollPanel': // ContentPanel (el, cfg)
+ case 'ViewPanel':
if(cfg.autoCreate) {
ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
} else {
}
break;
-
+
+
+
default:
}
// handle view.xtype
- if (this.view && typeof(this.view.xtype) != 'undefined') {
- this.view.el = this.el.appendChild(document.createElement("div"));
- this.view = Roo.factory(this.view);
- this.view.render && this.view.render(false, ''); // render blank..
- }
-
+
this.addEvents({
});
+
+
+
+
if(this.autoScroll){
this.resizeEl.setStyle("overflow", "auto");
} else {
Roo.ContentPanel.superclass.constructor.call(this);
+ if (this.view && typeof(this.view.xtype) != 'undefined') {
+ this.view.el = this.el.appendChild(document.createElement("div"));
+ this.view = Roo.factory(this.view);
+ this.view.render && this.view.render(false, '');
+ }
+
+
this.fireEvent('render', this);
};
return this.form;
}
// should only have one of theses..
- if (['View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
- // views..
+ if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
+ // views.. should not be just added - used named prop 'view''
+
cfg.el = this.el.appendChild(document.createElement("div"));
// factory?
var ret = new Roo.factory(cfg);
- ret.render && ret.render(false, ''); // render blank..
+
+ ret.render && ret.render(false, ''); // render blank..
this.view = ret;
return ret;
}
// make a flat list in order of modules to build.
var mods = this.topModule ? [ this.topModule ] : [];
+
// elmodules (is a list of DOM based modules )
Roo.each(this.elmodules, function(e) {
- mods.push(e)
+ mods.push(e);
+ if (!this.topModule &&
+ typeof(e.parent) == 'string' &&
+ e.parent.substring(0,1) == '#' &&
+ Roo.get(e.parent.substr(1))
+ ) {
+
+ _this.topModule = e;
+ }
+
});
// add modules to their parents..
var addMod = function(m) {
- Roo.debug && Roo.log("build Order: add: " + m.name);
-
- mods.push(m);
- if (m.modules && !m.disabled) {
- Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules");
- m.modules.keySort('ASC', cmp );
- Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules (after sort)");
-
- m.modules.each(addMod);
- } else {
- Roo.debug && Roo.log("build Order: no child modules");
- }
+ Roo.debug && Roo.log("build Order: add: " + m.name);
+
+ mods.push(m);
+ if (m.modules && !m.disabled) {
+ Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules");
+ m.modules.keySort('ASC', cmp );
+ Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules (after sort)");
+
+ m.modules.each(addMod);
+ } else {
+ Roo.debug && Roo.log("build Order: no child modules");
+ }
// not sure if this is used any more..
if (m.finalize) {
m.finalize.name = m.name + " (clean up) ";
}
}
- if (this.topModule) {
+ if (this.topModule && this.topModule.modules) {
this.topModule.modules.keySort('ASC', cmp );
this.topModule.modules.each(addMod);
- }
+ }
return mods;
},
});
Roo.XComponent.on = Roo.XComponent.event.on.createDelegate(Roo.XComponent.event);
- //<script type="text/javascript">
-
-
-/**
- * @class Roo.Login
- * @extends Roo.LayoutDialog
- * A generic Login Dialog..... - only one needed in theory!?!?
- *
- * Fires XComponent builder on success...
- *
- * Sends
- * username,password, lang = for login actions.
- * check = 1 for periodic checking that sesion is valid.
- * passwordRequest = email request password
- * logout = 1 = to logout
- *
- * Affects: (this id="????" elements)
- * loading (removed) (used to indicate application is loading)
- * loading-mask (hides) (used to hide application when it's building loading)
- *
- *
- * Usage:
- *
- *
- * Myapp.login = Roo.Login({
- url: xxxx,
-
- realm : 'Myapp',
-
-
- method : 'POST',
-
-
- *
- })
- *
- *
- *
- **/
-
-Roo.Login = function(cfg)
-{
- this.addEvents({
- 'refreshed' : true
- });
-
- Roo.apply(this,cfg);
-
- Roo.onReady(function() {
- this.onLoad();
- }, this);
- // call parent..
-
-
- Roo.Login.superclass.constructor.call(this, this);
- //this.addxtype(this.items[0]);
-
-
-}
-
-
-Roo.extend(Roo.Login, Roo.LayoutDialog, {
-
- /**
- * @cfg {String} method
- * Method used to query for login details.
- */
-
- method : 'POST',
- /**
- * @cfg {String} url
- * URL to query login data. - eg. baseURL + '/Login.php'
- */
- url : '',
-
- /**
- * @property user
- * The user data - if user.id < 0 then login will be bypassed. (used for inital setup situation.
- * @type {Object}
- */
- user : false,
- /**
- * @property checkFails
- * Number of times we have attempted to get authentication check, and failed.
- * @type {Number}
- */
- checkFails : 0,
- /**
- * @property intervalID
- * The window interval that does the constant login checking.
- * @type {Number}
- */
- intervalID : 0,
-
-
- onLoad : function() // called on page load...
- {
- // load
-
- if (Roo.get('loading')) { // clear any loading indicator..
- Roo.get('loading').remove();
- }
-
- //this.switchLang('en'); // set the language to english..
-
- this.check({
- success: function(response, opts) { // check successfull...
-
- var res = this.processResponse(response);
- this.checkFails =0;
- if (!res.success) { // error!
- this.checkFails = 5;
- //console.log('call failure');
- return this.failure(response,opts);
- }
-
- if (!res.data.id) { // id=0 == login failure.
- return this.show();
- }
-
-
- //console.log(success);
- this.fillAuth(res.data);
- this.checkFails =0;
- Roo.XComponent.build();
- },
- failure : this.show
- });
-
- },
-
-
- check: function(cfg) // called every so often to refresh cookie etc..
- {
- if (cfg.again) { // could be undefined..
- this.checkFails++;
- } else {
- this.checkFails = 0;
- }
- var _this = this;
- if (this.sending) {
- if ( this.checkFails > 4) {
- Roo.MessageBox.alert("Error",
- "Error getting authentication status. - try reloading, or wait a while", function() {
- _this.sending = false;
- });
- return;
- }
- cfg.again = true;
- _this.check.defer(10000, _this, [ cfg ]); // check in 10 secs.
- return;
- }
- this.sending = true;
-
- Roo.Ajax.request({
- url: this.url,
- params: {
- getAuthUser: true
- },
- method: this.method,
- success: cfg.success || this.success,
- failure : cfg.failure || this.failure,
- scope : this,
- callCfg : cfg
-
- });
- },
-
-
- logout: function()
- {
- window.onbeforeunload = function() { }; // false does not work for IE..
- this.user = false;
- var _this = this;
-
- Roo.Ajax.request({
- url: this.url,
- params: {
- logout: 1
- },
- method: 'GET',
- failure : function() {
- Roo.MessageBox.alert("Error", "Error logging out. - continuing anyway.", function() {
- document.location = document.location.toString() + '?ts=' + Math.random();
- });
-
- },
- success : function() {
- _this.user = false;
- this.checkFails =0;
- // fixme..
- document.location = document.location.toString() + '?ts=' + Math.random();
- }
-
-
- });
- },
-
- processResponse : function (response)
- {
- var res = '';
- try {
- res = Roo.decode(response.responseText);
- // oops...
- if (typeof(res) != 'object') {
- res = { success : false, errorMsg : res, errors : true };
- }
- if (typeof(res.success) == 'undefined') {
- res.success = false;
- }
-
- } catch(e) {
- res = { success : false, errorMsg : response.responseText, errors : true };
- }
- return res;
- },
-
- success : function(response, opts) // check successfull...
- {
- this.sending = false;
- var res = this.processResponse(response);
- if (!res.success) {
- return this.failure(response, opts);
- }
- if (!res.data || !res.data.id) {
- return this.failure(response,opts);
- }
- //console.log(res);
- this.fillAuth(res.data);
-
- this.checkFails =0;
-
- },
-
-
- failure : function (response, opts) // called if login 'check' fails.. (causes re-check)
- {
- this.authUser = -1;
- this.sending = false;
- var res = this.processResponse(response);
- //console.log(res);
- if ( this.checkFails > 2) {
-
- Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg :
- "Error getting authentication status. - try reloading");
- return;
- }
- opts.callCfg.again = true;
- this.check.defer(1000, this, [ opts.callCfg ]);
- return;
- },
-
-
-
- fillAuth: function(au) {
- this.startAuthCheck();
- this.authUserId = au.id;
- this.authUser = au;
- this.lastChecked = new Date();
- this.fireEvent('refreshed', au);
- //Pman.Tab.FaxQueue.newMaxId(au.faxMax);
- //Pman.Tab.FaxTab.setTitle(au.faxNumPending);
- au.lang = au.lang || 'en';
- //this.switchLang(Roo.state.Manager.get('Pman.Login.lang', 'en'));
- Roo.state.Manager.set( this.realm + 'lang' , au.lang);
- this.switchLang(au.lang );
-
-
- // open system... - -on setyp..
- if (this.authUserId < 0) {
- Roo.MessageBox.alert("Warning",
- "This is an open system - please set up a admin user with a password.");
- }
-
- //Pman.onload(); // which should do nothing if it's a re-auth result...
-
-
- },
-
- startAuthCheck : function() // starter for timeout checking..
- {
- if (this.intervalID) { // timer already in place...
- return false;
- }
- var _this = this;
- this.intervalID = window.setInterval(function() {
- _this.check(false);
- }, 120000); // every 120 secs = 2mins..
-
-
- },
-
-
- switchLang : function (lang)
- {
- _T = typeof(_T) == 'undefined' ? false : _T;
- if (!_T || !lang.length) {
- return;
- }
-
- if (!_T && lang != 'en') {
- Roo.MessageBox.alert("Sorry", "Language not available yet (" + lang +')');
- return;
- }
-
- if (typeof(_T.en) == 'undefined') {
- _T.en = {};
- Roo.apply(_T.en, _T);
- }
-
- if (typeof(_T[lang]) == 'undefined') {
- Roo.MessageBox.alert("Sorry", "Language not available yet (" + lang +')');
- return;
- }
-
-
- Roo.apply(_T, _T[lang]);
- // just need to set the text values for everything...
- var _this = this;
- /* this will not work ...
- if (this.form) {
-
-
- function formLabel(name, val) {
- _this.form.findField(name).fieldEl.child('label').dom.innerHTML = val;
- }
-
- formLabel('password', "Password"+':');
- formLabel('username', "Email Address"+':');
- formLabel('lang', "Language"+':');
- this.dialog.setTitle("Login");
- this.dialog.buttons[0].setText("Forgot Password");
- this.dialog.buttons[1].setText("Login");
- }
- */
-
-
- },
-
-
- title: "Login",
- modal: true,
- width: 350,
- //height: 230,
- height: 180,
- shadow: true,
- minWidth:200,
- minHeight:180,
- //proxyDrag: true,
- closable: false,
- draggable: false,
- collapsible: false,
- resizable: false,
- center: { // needed??
- autoScroll:false,
- titlebar: false,
- // tabPosition: 'top',
- hideTabs: true,
- closeOnTab: true,
- alwaysShowTabs: false
- } ,
- listeners : {
-
- show : function(dlg)
- {
- //console.log(this);
- this.form = this.layout.getRegion('center').activePanel.form;
- this.form.dialog = dlg;
- this.buttons[0].form = this.form;
- this.buttons[0].dialog = dlg;
- this.buttons[1].form = this.form;
- this.buttons[1].dialog = dlg;
-
- //this.resizeToLogo.defer(1000,this);
- // this is all related to resizing for logos..
- //var sz = Roo.get(Pman.Login.form.el.query('img')[0]).getSize();
- //// if (!sz) {
- // this.resizeToLogo.defer(1000,this);
- // return;
- // }
- //var w = Ext.lib.Dom.getViewWidth() - 100;
- //var h = Ext.lib.Dom.getViewHeight() - 100;
- //this.resizeTo(Math.max(350, Math.min(sz.width + 30, w)),Math.min(sz.height+200, h));
- //this.center();
- if (this.disabled) {
- this.hide();
- return;
- }
-
- if (this.user.id < 0) { // used for inital setup situations.
- return;
- }
-
- if (this.intervalID) {
- // remove the timer
- window.clearInterval(this.intervalID);
- this.intervalID = false;
- }
-
-
- if (Roo.get('loading')) {
- Roo.get('loading').remove();
- }
- if (Roo.get('loading-mask')) {
- Roo.get('loading-mask').hide();
- }
-
- //incomming._node = tnode;
- this.form.reset();
- //this.dialog.modal = !modal;
- //this.dialog.show();
- this.el.unmask();
-
-
- this.form.setValues({
- 'username' : Roo.state.Manager.get(this.realm + '.username', ''),
- 'lang' : Roo.state.Manager.get(this.realm + '.lang', 'en')
- });
-
- this.switchLang(Roo.state.Manager.get(this.realm + '.lang', 'en'));
- if (this.form.findField('username').getValue().length > 0 ){
- this.form.findField('password').focus();
- } else {
- this.form.findField('username').focus();
- }
-
- }
- },
- items : [
- {
-
- xtype : 'ContentPanel',
- xns : Roo,
- region: 'center',
- fitToFrame : true,
-
- items : [
-
- {
-
- xtype : 'Form',
- xns : Roo.form,
- labelWidth: 100,
- style : 'margin: 10px;',
-
- listeners : {
- actionfailed : function(f, act) {
- // form can return { errors: .... }
-
- //act.result.errors // invalid form element list...
- //act.result.errorMsg// invalid form element list...
-
- this.dialog.el.unmask();
- Roo.MessageBox.alert("Error", act.result.errorMsg ? act.result.errorMsg :
- "Login failed - communication error - try again.");
-
- },
- actioncomplete: function(re, act) {
-
- Roo.state.Manager.set(
- this.dialog.realm + '.username',
- this.findField('username').getValue()
- );
- Roo.state.Manager.set(
- this.dialog.realm + '.lang',
- this.findField('lang').getValue()
- );
-
- this.dialog.fillAuth(act.result.data);
-
- this.dialog.hide();
-
- if (Roo.get('loading-mask')) {
- Roo.get('loading-mask').show();
- }
- Roo.XComponent.build();
-
-
-
- }
- },
- items : [
- {
- xtype : 'TextField',
- xns : Roo.form,
- fieldLabel: "Email Address",
- name: 'username',
- width:200,
- autoCreate : {tag: "input", type: "text", size: "20"}
- },
- {
- xtype : 'TextField',
- xns : Roo.form,
- fieldLabel: "Password",
- inputType: 'password',
- name: 'password',
- width:200,
- autoCreate : {tag: "input", type: "text", size: "20"},
- listeners : {
- specialkey : function(e,ev) {
- if (ev.keyCode == 13) {
- this.form.dialog.el.mask("Logging in");
- this.form.doAction('submit', {
- url: this.form.dialog.url,
- method: this.form.dialog.method
- });
- }
- }
- }
- },
- {
- xtype : 'ComboBox',
- xns : Roo.form,
- fieldLabel: "Language",
- name : 'langdisp',
- store: {
- xtype : 'SimpleStore',
- fields: ['lang', 'ldisp'],
- data : [
- [ 'en', 'English' ],
- [ 'zh_HK' , '\u7E41\u4E2D' ],
- [ 'zh_CN', '\u7C21\u4E2D' ]
- ]
- },
-
- valueField : 'lang',
- hiddenName: 'lang',
- width: 200,
- displayField:'ldisp',
- typeAhead: false,
- editable: false,
- mode: 'local',
- triggerAction: 'all',
- emptyText:'Select a Language...',
- selectOnFocus:true,
- listeners : {
- select : function(cb, rec, ix) {
- this.form.switchLang(rec.data.lang);
- }
- }
-
- }
- ]
- }
-
-
- ]
- }
- ],
- buttons : [
- {
- xtype : 'Button',
- xns : 'Roo',
- text : "Forgot Password",
- listeners : {
- click : function() {
- //console.log(this);
- var n = this.form.findField('username').getValue();
- if (!n.length) {
- Roo.MessageBox.alert("Error", "Fill in your email address");
- return;
- }
- Roo.Ajax.request({
- url: this.dialog.url,
- params: {
- passwordRequest: n
- },
- method: this.dialog.method,
- success: function(response, opts) { // check successfull...
-
- var res = this.dialog.processResponse(response);
- if (!res.success) { // error!
- Roo.MessageBox.alert("Error" ,
- res.errorMsg ? res.errorMsg : "Problem Requesting Password Reset");
- return;
- }
- Roo.MessageBox.alert("Notice" ,
- "Please check you email for the Password Reset message");
- },
- failure : function() {
- Roo.MessageBox.alert("Error" , "Problem Requesting Password Reset");
- }
-
- });
- }
- }
- },
- {
- xtype : 'Button',
- xns : 'Roo',
- text : "Login",
- listeners : {
-
- click : function () {
-
- this.dialog.el.mask("Logging in");
- this.form.doAction('submit', {
- url: this.dialog.url,
- method: this.dialog.method
- });
- }
- }
- }
- ]
-
-
-})
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file