maskEl : false, // the mask element
headerEl : false,
contentEl : false,
-
+ alignEl : false, // when show is called with an element - this get's stored.
getChildContainer : function()
{
Roo.bootstrap.Popover.register(this);
}
-
+ this.arrowEl = this.el.select('.arrow',true).first();
this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
this.el.enableDisplayMode('block');
this.el.hide();
+
+
if (this.over === false && !this.parent()) {
return;
}
on_el.on(eventOut, this.leave, this);
}
}, this);
-
},
},
/**
* Show the popover
- * @param {Roo.Element|string|false} - element to align and point to.
+ * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
+ * @param {string} (left|right|top|bottom) position
*/
- show : function (on_el)
+ show : function (on_el, placement)
{
-
+ this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
on_el = on_el || false; // default to false
+
if (!on_el) {
if (this.parent() && (this.over == 'parent' || (this.over === false))) {
on_el = this.parent().el;
this.headerEl.hide();
}
-
- var placement = typeof this.placement == 'function' ?
- this.placement.call(this, this.el, on_el) :
- this.placement;
-
- /*
- var autoToken = /\s?auto?\s?/i; /// not sure how this was supposed to work? right auto ? what?
-
- // I think 'auto right' - but
-
- var autoPlace = autoToken.test(placement);
- if (autoPlace) {
- placement = placement.replace(autoToken, '') || 'top';
- }
- */
-
-
+
this.el.show();
- this.el.dom.style.display='block';
-
- //this.el.appendTo(on_el);
-
- var p = this.getPosition();
- var box = this.el.getBox();
-
+ this.el.dom.style.display = 'block';
+
- var align = Roo.bootstrap.Popover.alignment[placement];
- this.el.addClass(align[2]);
-
-// Roo.log(align);
+ this.el.addClass(placement + ' roo-popover-' + placement);
if (on_el) {
- this.el.alignTo(on_el, align[0],align[1]);
+ this.updatePosition();
+
} else {
// this is usually just done by the builder = to show the popoup in the middle of the scren.
var es = this.el.getSize();
this.el.addClass('in');
-
- if (this.el.hasClass('fade')) {
- // fade it?
- }
+
this.hoverState = 'in';
this.maskEl.addClass('show');
}
this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
-
+
+ this.fireEvent('show', this);
+ },
+ /**
+ * fire this manually after loading a grid in the table for example
+ * @param {string} (left|right|top|bottom) where to try and put it
+ * @param {Boolean} try and move it if we cant get right position.
+ */
+ updatePosition : function(placement, try_move)
+ {
+ this.el.removeClass([
+ 'fade','top','bottom', 'left', 'right','in',
+ 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
+ ]);
+ this.el.addClass(placement + ' roo-popover-' + placement);
- this.fireEvent('show', this);
+ if (!this.alignEl ) {
+ return false;
+ }
+ switch (placement) {
+ case 'right':
+ var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
+ var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
+ if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('tr', false);
+ xy[0]+=2;xy[1]+=5;
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ // continue through...
+ try_move = false;
+
+
+ case 'left':
+ var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
+ var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
+ if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('tl', false);
+ xy[0]+=2;xy[1]+=5; // << fix me
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ // call self...
+ return this.updatePosition('right', false);
+
+ case 'top':
+ var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,-10]);
+ var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,-10]);
+ if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('b', false);
+ xy[0]+=2;xy[1]+=5; // << fix me
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ // fall through
+ try_move = false;
+
+ case 'bottom':
+ var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,10]);
+ var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,10]);
+ if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
+ //normal display... or moved up/down.
+ this.setXY(offset);
+ var xy = this.alignEl.getAnchorXY('t', false);
+ xy[0]+=2;xy[1]+=5; // << fix me
+ this.arrowEl.setXY(xy);
+ return true;
+ }
+ // fall through
+ return this.updatePosition('top', false);
+
+
+ }
+
+
+ return false;
},
+
hide : function()
{
this.el.setXY([0,0]);
* valid according to {@link Date#parseDate} (defaults to 'H:i').
*/
format : "H:i",
-
+
+ getAutoCreate : function()
+ {
+ this.after = '<i class="fa far fa-clock"></i>';
+ return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
+
+
+ },
onRender: function(ct, position)
{
Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
- this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
+ this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
this.fillTime();
this.update();
- this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
- this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
- this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
- this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
+ this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
+ this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
+ this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
+ this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
this.pop.select('button.ok', true).first().on('click', this.setTime, this);
picker : function()
{
- return this.el.select('.datepicker', true).first();
+ return this.pickerEl;
},
fillTime: function()
cls: 'btn',
cn: [
{
- tag: 'span',
- cls: 'hours-up glyphicon glyphicon-chevron-up'
+ tag: 'i',
+ cls: 'hours-up fa fas fa-chevron-up'
}
]
}
cls: 'btn',
cn: [
{
- tag: 'span',
- cls: 'minutes-up glyphicon glyphicon-chevron-up'
+ tag: 'i',
+ cls: 'minutes-up fa fas fa-chevron-up'
}
]
}
cn: [
{
tag: 'span',
- cls: 'hours-down glyphicon glyphicon-chevron-down'
+ cls: 'hours-down fa fas fa-chevron-down'
}
]
}
cn: [
{
tag: 'span',
- cls: 'minutes-down glyphicon glyphicon-chevron-down'
+ cls: 'minutes-down fa fas fa-chevron-down'
}
]
}
cls.pop();
cls.push('left');
}
-
+ //this.picker().setXY(20000,20000);
this.picker().addClass(cls.join('-'));
var _this = this;
Roo.each(cls, function(c){
if(c == 'bottom'){
- _this.picker().setTop(_this.inputEl().getHeight());
+ (function() {
+ //
+ }).defer(200);
+ _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
+ //_this.picker().setTop(_this.inputEl().getHeight());
return;
}
if(c == 'top'){
- _this.picker().setTop(0 - _this.picker().getHeight());
+ _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
+
+ //_this.picker().setTop(0 - _this.picker().getHeight());
return;
}
-
+ /*
if(c == 'left'){
_this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
return;
_this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
return;
}
+ */
});
},
});
-
-Roo.apply(Roo.bootstrap.TimeField, {
-
- content : {
- tag: 'tbody',
- cn: [
- {
- tag: 'tr',
- cn: [
- {
- tag: 'td',
- colspan: '7'
- }
- ]
- }
- ]
- },
-
- footer : {
- tag: 'tfoot',
- cn: [
- {
- tag: 'tr',
- cn: [
- {
- tag: 'th',
- colspan: '7',
- cls: '',
- cn: [
- {
- tag: 'button',
- cls: 'btn btn-info ok',
- html: 'OK'
- }
- ]
- }
-
- ]
- }
- ]
- }
-});
+
Roo.apply(Roo.bootstrap.TimeField, {
tag: 'table',
cls: 'table-condensed',
cn:[
- Roo.bootstrap.TimeField.content,
- Roo.bootstrap.TimeField.footer
+ {
+ tag: 'tbody',
+ cn: [
+ {
+ tag: 'tr',
+ cn: [
+ {
+ tag: 'td',
+ colspan: '7'
+ }
+ ]
+ }
+ ]
+ },
+ {
+ tag: 'tfoot',
+ cn: [
+ {
+ tag: 'tr',
+ cn: [
+ {
+ tag: 'th',
+ colspan: '7',
+ cls: '',
+ cn: [
+ {
+ tag: 'button',
+ cls: 'btn btn-info ok',
+ html: 'OK'
+ }
+ ]
+ }
+
+ ]
+ }
+ ]
+ }
]
}
]
// private
onLoad : function(ds, r, o)
{
- this.cursor = o.params.start ? o.params.start : 0;
+ this.cursor = o.params && o.params.start ? o.params.start : 0;
var d = this.getPageData(),
ap = d.activePage,