* @cfg {String} icon (info-sign|check|...) glyphicon name
* @cfg {Boolean} hidden (true|false) hide the element
* @cfg {Boolean} expandable (true|false) default false
+ * @cfg {Boolean} expanded (true|false) default true
* @cfg {String} rheader contet on the right of header
*
body = false;
cfg.cn.push({
- cls : 'panel-body',
+ cls : 'panel-body' + (this.expanded ? '' : ' hide'),
html : this.html
});
this.expanded = true;
- this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
-
+ //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
+
+ this.el.select('.panel-body',true).first().removeClass('hide');
+
var toggleEl = this.toggleEl();
if(!toggleEl){
this.expanded = false;
- this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
+ //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
+ this.el.select('.panel-body',true).first().addClass('hide');
var toggleEl = this.toggleEl();
this.inputEl().on("blur", this.onBlur, this);
this.inputEl().relayEvent('keyup', this);
- this.inputEl().relayEvent('change', this);
-
+
// reference to original value for reset
this.originalValue = this.getValue();
//Roo.form.TextField.superclass.initEvents.call(this);
* @event exception
* Fire when xhr load exception
* @param {Roo.bootstrap.DocumentManager} this
- * @param {Object} response
+ * @param {XMLHttpRequest} xhr
*/
"exception" : true,
/**
},
{
tag : 'div',
- cls : 'roo-document-manager-block roo-document-manager-uploader',
+ cls : 'roo-document-manager-uploader',
cn : [
{
tag : 'div',
this.el.createChild({
tag : 'div',
- cls : 'roo-document-manager-block',
+ cls : 'roo-document-manager-preview',
cn : [
{
tag : 'div',
};
xhr.open(this.method, this.url, true);
-
+
+ for (var headerName in headers) {
+ var headerValue = headers[headerName];
+ if (headerValue) {
+ xhr.setRequestHeader(headerName, headerValue);
+ }
+ }
+
var _this = this;
xhr.onload = function()
_this.xhrOnError(xhr);
}
- for (var headerName in headers) {
- var headerValue = headers[headerName];
- if (headerValue) {
- xhr.setRequestHeader(headerName, headerValue);
- }
- }
-
var formData = new FormData();
formData.append('returnHTML', 'NO');
refresh : function()
{
- var elements = this.el.select('.roo-document-manager-thumb', true).elements;
+ Roo.each(this.el.select('.roo-document-manager-preview', true).elements, function(el){
+ el.remove();
+ }, this);
var files = [];
- Roo.log(this.files);
-
- Roo.each(this.files, function(file, index){
+ Roo.each(this.files, function(file){
- if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
- elements[index].dom.innerHTML = '<img src="' + baseURL +'/Images/Thumb/50/' + file.id + '/' + file.filename + '" alt="' + file.filename + '">';
- files.push(file);
+ if(typeof(file.id) == 'undefined' && file.id * 1 < 1){
return;
}
- elements[index].remove();
+ files.push(file);
+
+ this.el.createChild({
+ tag : 'div',
+ cls : 'roo-document-manager-preview',
+ cn : [
+ {
+ tag : 'div',
+ tooltip : file.filename,
+ cls : 'roo-document-manager-thumb',
+ html : '<img src="' + baseURL +'/Images/Thumb/50/' + file.id + '/' + file.filename + '">'
+ },
+ {
+ tag : 'button',
+ cls : 'close',
+ html : 'x'
+ }
+ ]
+
+ });
+
return;
}, this);
this.files = files;
+
+ this.uploader.show();
+
+ if(this.files.length > 11){
+ this.uploader.hide();
+ }
},
xhrOnLoad : function(xhr)
{
if (xhr.readyState !== 4) {
+ this.refresh();
+ this.fireEvent('exception', this, xhr);
return;
}
if(!response.success){
this.refresh();
- this.fireEvent('exception', this, response);
+ this.fireEvent('exception', this, xhr);
return;
}
}if(this.panel.length){return this.el.select('.panel-body',true).first();}return this.el;},getAutoCreate:function(){var A={tag:this.tag||'div',html:'',cls:''};if(this.jumbotron){A.cls='jumbotron';}if(this.sticky.length){var bd=Roo.get(document.body);if(!bd.hasClass('bootstrap-sticky')){bd.addClass('bootstrap-sticky');
Roo.select('html',true).setStyle('height','100%');}A.cls+='bootstrap-sticky-'+this.sticky;}if(this.well.length){switch(this.well){case 'lg':case 'sm':A.cls+=' well well-'+this.well;break;default:A.cls+=' well';break;}}if(this.hidden){A.cls+=' hidden';}if(this.alert&&["success","info","warning","danger"].indexOf(this.alert)>-1){A.cls+=' alert alert-'+this.alert;
}var B=A;if(this.panel.length){A.cls+=' panel panel-'+this.panel;A.cn=[];if(this.header.length){var h=[];if(this.expandable){A.cls=A.cls+' expandable';h.push({tag:'i',cls:'fa fa-minus'});}h.push({tag:'span',cls:'panel-title',html:this.header},{tag:'span',cls:'panel-header-right',html:this.rheader}
-);A.cn.push({cls:'panel-heading',cn:h});}B=false;A.cn.push({cls:'panel-body',html:this.html});if(this.footer.length){A.cn.push({cls:'panel-footer',html:this.footer});}}if(B){B.html=this.html||A.html;if(this.fa){B.html='<i class="fa fa-'+this.fa+'"></i>'+B.html;
+);A.cn.push({cls:'panel-heading',cn:h});}B=false;A.cn.push({cls:'panel-body'+(this.expanded?'':' hide'),html:this.html});if(this.footer.length){A.cn.push({cls:'panel-footer',html:this.footer});}}if(B){B.html=this.html||A.html;if(this.fa){B.html='<i class="fa fa-'+this.fa+'"></i>'+B.html;
}if(this.icon){B.html='<i class="glyphicon glyphicon-'+this.icon+'"></i>'+B.html;}}if((!this.cls||!this.cls.length)&&(!A.cls||!A.cls.length)){A.cls='container';}return A;},initEvents:function(){if(!this.expandable){return;}var A=this.headerEl();if(!A){return;
-}A.on('click',this.onToggleClick,this);},onToggleClick:function(){var A=this.headerEl();if(!A){return;}if(this.expanded){this.collapse();return;}this.expand();},expand:function(){if(this.fireEvent('expand',this)){this.expanded=true;this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
-var A=this.toggleEl();if(!A){return;}A.removeClass(['fa-minus','fa-plus']).addClass(['fa-minus']);}},collapse:function(){if(this.fireEvent('collapse',this)){this.expanded=false;this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
-var A=this.toggleEl();if(!A){return;}A.removeClass(['fa-minus','fa-plus']).addClass(['fa-plus']);}},toggleEl:function(){if(!this.el||!this.panel.length||!this.header.length||!this.expandable){return;}return this.el.select('.panel-heading .fa',true).first();
-},headerEl:function(){if(!this.el||!this.panel.length||!this.header.length){return;}return this.el.select('.panel-heading',true).first()},titleEl:function(){if(!this.el||!this.panel.length||!this.header.length){return;}return this.el.select('.panel-title',true).first();
-},setTitle:function(v){var A=this.titleEl();if(!A){return;}A.dom.innerHTML=v;},getTitle:function(){var A=this.titleEl();if(!A){return '';}return A.dom.innerHTML;},setRightTitle:function(v){var t=this.el.select('.panel-header-right',true).first();if(!t){return;
-}t.dom.innerHTML=v;}});
+}A.on('click',this.onToggleClick,this);},onToggleClick:function(){var A=this.headerEl();if(!A){return;}if(this.expanded){this.collapse();return;}this.expand();},expand:function(){if(this.fireEvent('expand',this)){this.expanded=true;this.el.select('.panel-body',true).first().removeClass('hide');
+var A=this.toggleEl();if(!A){return;}A.removeClass(['fa-minus','fa-plus']).addClass(['fa-minus']);}},collapse:function(){if(this.fireEvent('collapse',this)){this.expanded=false;this.el.select('.panel-body',true).first().addClass('hide');var A=this.toggleEl();
+if(!A){return;}A.removeClass(['fa-minus','fa-plus']).addClass(['fa-plus']);}},toggleEl:function(){if(!this.el||!this.panel.length||!this.header.length||!this.expandable){return;}return this.el.select('.panel-heading .fa',true).first();},headerEl:function(){if(!this.el||!this.panel.length||!this.header.length){return;
+}return this.el.select('.panel-heading',true).first()},titleEl:function(){if(!this.el||!this.panel.length||!this.header.length){return;}return this.el.select('.panel-title',true).first();},setTitle:function(v){var A=this.titleEl();if(!A){return;}A.dom.innerHTML=v;
+},getTitle:function(){var A=this.titleEl();if(!A){return '';}return A.dom.innerHTML;},setRightTitle:function(v){var t=this.el.select('.panel-header-right',true).first();if(!t){return;}t.dom.innerHTML=v;}});
// Roo/bootstrap/Img.js
Roo.bootstrap.Img=function(A){Roo.bootstrap.Img.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.Img,Roo.bootstrap.Component,{imgResponsive:true,border:'',src:'',href:false,target:false,xsUrl:'',smUrl:'',mdUrl:'',lgUrl:'',getAutoCreate:function(){if(this.src||(!this.xsUrl&&!this.smUrl&&!this.mdUrl&&!this.lgUrl)){return this.createSingleImg();
}var A={tag:'div',cls:'roo-image-responsive-group',cn:[]};var _this=this;Roo.each(['xs','sm','md','lg'],function(B){if(!_this[B+'Url']){return;}var C={tag:'img',cls:(_this.imgResponsive)?'img-responsive':'',html:_this.html||A.html,src:_this[B+'Url']};C.cls+=' roo-image-responsive-'+B;
E.cn.push(F);}};if(A==='left'&&this.fieldLabel.length){Roo.log("left and has label");B.cn=[{tag:'label','for':id,cls:'control-label col-sm-'+this.labelWidth,html:this.fieldLabel},{cls:"col-sm-"+(12-this.labelWidth),cn:[E]}];}else if(this.fieldLabel.length){Roo.log(" label");
B.cn=[{tag:'label',html:this.fieldLabel},E];}else{Roo.log(" no label && no align");B.cn=[E];};Roo.log('input-parentType: '+this.parentType);if(this.parentType==='Navbar'&&this.parent().bar){B.cls+=' navbar-form';Roo.log(B);}return B;},inputEl:function(){return this.el.select('input.form-control',true).first();
},tooltipEl:function(){return this.inputEl();},setDisabled:function(v){var i=this.inputEl().dom;if(!v){i.removeAttribute('disabled');return;}i.setAttribute('disabled','true');},initEvents:function(){this.inputEl().on("keydown",this.fireKey,this);this.inputEl().on("focus",this.onFocus,this);
-this.inputEl().on("blur",this.onBlur,this);this.inputEl().relayEvent('keyup',this);this.inputEl().relayEvent('change',this);this.originalValue=this.getValue();if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(this.validate,this);
-this.inputEl().on('keyup',this.filterValidation,this);}else if(this.validationEvent!==false){this.inputEl().on(this.validationEvent,this.validate,this,{buffer:this.validationDelay});}if(this.selectOnFocus){this.on("focus",this.preFocus,this);}if(this.maskRe||(this.vtype&&this.disableKeyFilter!==true&&(this.maskRe=Roo.form.VTypes[this.vtype+'Mask']))){this.inputEl().on("keypress",this.filterKeys,this);
+this.inputEl().on("blur",this.onBlur,this);this.inputEl().relayEvent('keyup',this);this.originalValue=this.getValue();if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(this.validate,this);this.inputEl().on('keyup',this.filterValidation,this);
+}else if(this.validationEvent!==false){this.inputEl().on(this.validationEvent,this.validate,this,{buffer:this.validationDelay});}if(this.selectOnFocus){this.on("focus",this.preFocus,this);}if(this.maskRe||(this.vtype&&this.disableKeyFilter!==true&&(this.maskRe=Roo.form.VTypes[this.vtype+'Mask']))){this.inputEl().on("keypress",this.filterKeys,this);
}if(this.inputEl().is('input[type=password]')&&Roo.isSafari){this.inputEl().on('keydown',this.SafariOnKeyDown,this);}if(typeof(this.before)=='object'){this.before.render(this.el.select('.roo-input-before',true).first());}if(typeof(this.after)=='object'){this.after.render(this.el.select('.roo-input-after',true).first());
}},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},validate:function(){if(this.disabled||this.validateValue(this.getRawValue())){this.markValid();return true;}this.markInvalid();return false;},validateValue:function(A){if(A.length<1){if(this.allowBlank){return true;
}return false;}if(A.length<this.minLength){return false;}if(A.length>this.maxLength){return false;}if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(B!==true){return false;
},size:8}}});
// Roo/bootstrap/DocumentManager.js
Roo.bootstrap.DocumentManager=function(A){Roo.bootstrap.DocumentManager.superclass.constructor.call(this,A);this.addEvents({"inspect":true,"exception":true,"prepare":true});};Roo.extend(Roo.bootstrap.DocumentManager,Roo.bootstrap.Component,{boxes:12,inputName:'',minWidth:300,minHeight:300,multiple:true,files:[],method:'POST',url:'',paramName:'imageUpload',getAutoCreate:function(){var A={tag:'div',cls:'roo-document-manager',cn:[{tag:'input',cls:'roo-document-manager-selector',type:'file'}
-,{tag:'div',cls:'roo-document-manager-block roo-document-manager-uploader',cn:[{tag:'div',cls:'roo-document-manager-upload-btn',html:'<i class="fa fa-plus"></i>'}]}]};return A;},initEvents:function(){this.selectorEl=this.el.select('.roo-document-manager-selector',true).first();
-this.selectorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';this.selectorEl.hide();if(this.multiple){this.selectorEl.attr('multiple','multiple');}this.selectorEl.on('change',this.onSelect,this);this.uploader=this.el.select('.roo-document-manager-uploader',true).first();
-this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';this.uploader.on('click',this.onUpload,this);},onUpload:function(e){e.preventDefault();this.selectorEl.dom.click();},onSelect:function(e){e.preventDefault();if(typeof(this.selectorEl.dom.files)=='undefined'||!this.selectorEl.dom.files.length){return;
-}Roo.each(this.selectorEl.dom.files,function(A){if(this.fireEvent('inspect',this,A)!=false){this.files.push(A);}},this);this.process();},process:function(){if(!this.files.length){return;}if(this.files.length>12){this.files=this.files.slice(0,12);}var A=new XMLHttpRequest();
-Roo.each(this.files,function(G,H){if(typeof(G.id)!='undefined'&&G.id*1>0){return;}G.xhr=A;this.el.createChild({tag:'div',cls:'roo-document-manager-block',cn:[{tag:'div',tooltip:G.name,cls:'roo-document-manager-thumb',html:'<i class="fa fa-spinner fa-pulse"></i>'}
-]});},this);if(this.files.length>11){this.uploader.hide();}var B={"Accept":"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};A.open(this.method,this.url,true);var C=this;A.onload=function(){C.xhrOnLoad(A);};A.onerror=function(){C.xhrOnError(A);
-};for(var D in B){var E=B[D];if(E){A.setRequestHeader(D,E);}}var F=new FormData();F.append('returnHTML','NO');Roo.each(this.files,function(G,H){if(typeof(G.id)!='undefined'&&G.id*1>0){return;}F.append(this.getParamName(H),G,G.name);},this);if(this.fireEvent('prepare',this,F)!=false){A.send(F);
-};},getParamName:function(i){if(!this.multiple){return this.paramName;}return this.paramName+"_"+i;},refresh:function(){var A=this.el.select('.roo-document-manager-thumb',true).elements;var B=[];Roo.log(this.files);Roo.each(this.files,function(C,D){if(typeof(C.id)!='undefined'&&C.id*1>0){A[D].dom.innerHTML='<img src="'+baseURL+'/Images/Thumb/50/'+C.id+'/'+C.filename+'" alt="'+C.filename+'">';
-B.push(C);return;}A[D].remove();return;},this);this.files=B;},xhrOnLoad:function(A){if(A.readyState!==4){return;}var B=Roo.decode(A.responseText);if(!B.success){this.refresh();this.fireEvent('exception',this,B);return;}var i=0;Roo.each(this.files,function(C,D){if(typeof(C.id)!='undefined'&&C.id*1>0){return;
-}this.files[D]=B.data[i];i++;return;},this);this.refresh();},xhrOnError:function(){Roo.log('xhr on error');var A=Roo.decode(xhr.responseText);Roo.log(A);}});
+,{tag:'div',cls:'roo-document-manager-uploader',cn:[{tag:'div',cls:'roo-document-manager-upload-btn',html:'<i class="fa fa-plus"></i>'}]}]};return A;},initEvents:function(){this.selectorEl=this.el.select('.roo-document-manager-selector',true).first();this.selectorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';
+this.selectorEl.hide();if(this.multiple){this.selectorEl.attr('multiple','multiple');}this.selectorEl.on('change',this.onSelect,this);this.uploader=this.el.select('.roo-document-manager-uploader',true).first();this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';
+this.uploader.on('click',this.onUpload,this);},onUpload:function(e){e.preventDefault();this.selectorEl.dom.click();},onSelect:function(e){e.preventDefault();if(typeof(this.selectorEl.dom.files)=='undefined'||!this.selectorEl.dom.files.length){return;}Roo.each(this.selectorEl.dom.files,function(A){if(this.fireEvent('inspect',this,A)!=false){this.files.push(A);
+}},this);this.process();},process:function(){if(!this.files.length){return;}if(this.files.length>12){this.files=this.files.slice(0,12);}var A=new XMLHttpRequest();Roo.each(this.files,function(G,H){if(typeof(G.id)!='undefined'&&G.id*1>0){return;}G.xhr=A;this.el.createChild({tag:'div',cls:'roo-document-manager-preview',cn:[{tag:'div',tooltip:G.name,cls:'roo-document-manager-thumb',html:'<i class="fa fa-spinner fa-pulse"></i>'}
+]});},this);if(this.files.length>11){this.uploader.hide();}var B={"Accept":"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};A.open(this.method,this.url,true);for(var C in B){var D=B[C];if(D){A.setRequestHeader(C,D);}}var E=this;
+A.onload=function(){E.xhrOnLoad(A);};A.onerror=function(){E.xhrOnError(A);};var F=new FormData();F.append('returnHTML','NO');Roo.each(this.files,function(G,H){if(typeof(G.id)!='undefined'&&G.id*1>0){return;}F.append(this.getParamName(H),G,G.name);},this);
+if(this.fireEvent('prepare',this,F)!=false){A.send(F);};},getParamName:function(i){if(!this.multiple){return this.paramName;}return this.paramName+"_"+i;},refresh:function(){Roo.each(this.el.select('.roo-document-manager-preview',true).elements,function(el){el.remove();
+},this);var A=[];Roo.each(this.files,function(B){if(typeof(B.id)=='undefined'&&B.id*1<1){return;}A.push(B);this.el.createChild({tag:'div',cls:'roo-document-manager-preview',cn:[{tag:'div',tooltip:B.filename,cls:'roo-document-manager-thumb',html:'<img src="'+baseURL+'/Images/Thumb/50/'+B.id+'/'+B.filename+'">'}
+,{tag:'button',cls:'close',html:'x'}]});return;},this);this.files=A;this.uploader.show();if(this.files.length>11){this.uploader.hide();}},xhrOnLoad:function(A){if(A.readyState!==4){this.refresh();this.fireEvent('exception',this,A);return;}var B=Roo.decode(A.responseText);
+if(!B.success){this.refresh();this.fireEvent('exception',this,A);return;}var i=0;Roo.each(this.files,function(C,D){if(typeof(C.id)!='undefined'&&C.id*1>0){return;}this.files[D]=B.data[i];i++;return;},this);this.refresh();},xhrOnError:function(){Roo.log('xhr on error');
+var A=Roo.decode(xhr.responseText);Roo.log(A);}});