From 45937d3dbd21329cf901589467038d07e8b196b6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 8 Feb 2021 11:09:00 +0800 Subject: [PATCH] Fix #6593 - time picker tester --- Roo/bootstrap/TimeField.js | 125 +++++++++---------- docs/src/Roo_bootstrap_TimeField.js.html | 142 +++++++++++---------- docs/summary.txt | 4 +- examples/bootstrap4/TimePicker.html | 37 ++++++ examples/bootstrap4/timefield.js | 151 +++++++++++++++++++++++ roojs-bootstrap-debug.js | 130 ++++++++++--------- roojs-bootstrap.js | 37 +++--- 7 files changed, 416 insertions(+), 210 deletions(-) create mode 100644 examples/bootstrap4/TimePicker.html create mode 100644 examples/bootstrap4/timefield.js diff --git a/Roo/bootstrap/TimeField.js b/Roo/bootstrap/TimeField.js index 59de8c565c..b258728282 100644 --- a/Roo/bootstrap/TimeField.js +++ b/Roo/bootstrap/TimeField.js @@ -55,8 +55,8 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { getAutoCreate : function() { this.after = ''; - Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this); - + return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this); + }, onRender: function(ct, position) @@ -64,7 +64,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { 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'; @@ -79,10 +79,10 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { 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); @@ -126,7 +126,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { picker : function() { - return this.el.select('.datepicker', true).first(); + return this.pickerEl; }, fillTime: function() @@ -147,8 +147,8 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { cls: 'btn', cn: [ { - tag: 'span', - cls: 'hours-up glyphicon glyphicon-chevron-up' + tag: 'i', + cls: 'hours-up fa fas fa-chevron-up' } ] } @@ -167,8 +167,8 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { cls: 'btn', cn: [ { - tag: 'span', - cls: 'minutes-up glyphicon glyphicon-chevron-up' + tag: 'i', + cls: 'minutes-up fa fas fa-chevron-up' } ] } @@ -241,7 +241,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { cn: [ { tag: 'span', - cls: 'hours-down glyphicon glyphicon-chevron-down' + cls: 'hours-down fa fas fa-chevron-down' } ] } @@ -261,7 +261,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { cn: [ { tag: 'span', - cls: 'minutes-down glyphicon glyphicon-chevron-down' + cls: 'minutes-down fa fas fa-chevron-down' } ] } @@ -334,21 +334,27 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { 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; @@ -357,6 +363,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft()); return; } + */ }); }, @@ -444,48 +451,7 @@ Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, { }); - -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, { @@ -501,8 +467,43 @@ 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' + } + ] + } + + ] + } + ] + } ] } ] diff --git a/docs/src/Roo_bootstrap_TimeField.js.html b/docs/src/Roo_bootstrap_TimeField.js.html index 33a1d42ac7..43fa72603a 100644 --- a/docs/src/Roo_bootstrap_TimeField.js.html +++ b/docs/src/Roo_bootstrap_TimeField.js.html @@ -52,12 +52,19 @@ */ 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'; @@ -72,10 +79,10 @@ 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); @@ -119,7 +126,7 @@ picker : function() { - return this.el.select('.datepicker', true).first(); + return this.pickerEl; }, fillTime: function() @@ -140,8 +147,8 @@ cls: 'btn', cn: [ { - tag: 'span', - cls: 'hours-up glyphicon glyphicon-chevron-up' + tag: 'i', + cls: 'hours-up fa fas fa-chevron-up' } ] } @@ -160,8 +167,8 @@ cls: 'btn', cn: [ { - tag: 'span', - cls: 'minutes-up glyphicon glyphicon-chevron-up' + tag: 'i', + cls: 'minutes-up fa fas fa-chevron-up' } ] } @@ -234,7 +241,7 @@ cn: [ { tag: 'span', - cls: 'hours-down glyphicon glyphicon-chevron-down' + cls: 'hours-down fa fas fa-chevron-down' } ] } @@ -254,7 +261,7 @@ cn: [ { tag: 'span', - cls: 'minutes-down glyphicon glyphicon-chevron-down' + cls: 'minutes-down fa fas fa-chevron-down' } ] } @@ -327,30 +334,37 @@ 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()); - return; - } + _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false); - if(c == 'left'){ - _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth()); + //_this.picker().setTop(0 - _this.picker().getHeight()); return; } - if(c == 'right'){ - _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft()); - return; + /* + if(c == 'left'){ + _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth()); + return; } - }); + if(c == 'right'){ + _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft()); + return; + } + */ + }); }, @@ -438,47 +452,6 @@ }); -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, { @@ -494,9 +467,44 @@ 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' + } + ] + } + + ] + } + ] + } + ] } ] } diff --git a/docs/summary.txt b/docs/summary.txt index ffd297ff91..894f2ddf4e 100644 --- a/docs/summary.txt +++ b/docs/summary.txt @@ -225,7 +225,9 @@ Bootstrap Widgets Roo.bootstrap.BezierSignature Roo.bootstrap.RadioSet Roo.bootstrap.Markdown - textarea that views as a markdown rendered display - + Examples + [examples/bootstrap4/TimePicker.html] Timepicker on a dialog + Complex Widgets diff --git a/examples/bootstrap4/TimePicker.html b/examples/bootstrap4/TimePicker.html new file mode 100644 index 0000000000..28fa0ec869 --- /dev/null +++ b/examples/bootstrap4/TimePicker.html @@ -0,0 +1,37 @@ + + + + Bootstrap 101 Template + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/bootstrap4/timefield.js b/examples/bootstrap4/timefield.js new file mode 100644 index 0000000000..bef6fcbdf5 --- /dev/null +++ b/examples/bootstrap4/timefield.js @@ -0,0 +1,151 @@ +//