You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/11/23 14:18:17 UTC

[myfaces-tobago] branch master updated: TOBAGO-1821 Update bootstrap datepicker library * fix datepicker if date AND time could be selected * add a test for the bug

This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a16aab  TOBAGO-1821 Update bootstrap datepicker library * fix datepicker if date AND time could be selected * add a test for the bug
9a16aab is described below

commit 9a16aabf9456b761460065eae38fcf4a2cd7b999
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Nov 23 15:18:11 2017 +0100

    TOBAGO-1821 Update bootstrap datepicker library
    * fix datepicker if date AND time could be selected
    * add a test for the bug
---
 .../20-component/010-input/40-date/date.test.js    | 39 +++++++++++++++++++++-
 .../20-component/010-input/40-date/date.xhtml      |  2 +-
 .../_version/js/tobago-calendar.js                 | 11 ++++++
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js
index 1d475f1..49ac52a 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.test.js
@@ -44,7 +44,44 @@ QUnit.test("date with label", function (assert) {
   $dateButton.click(); // IE11: close datetimepicker for next test
 });
 
-QUnit.test("submit", function(assert) {
+QUnit.test("date+time pattern", function (assert) {
+  assert.expect(5);
+  var done = assert.async();
+  var step = 1;
+
+  var $dateButton = jQueryFrame("#page\\:mainForm\\:dateTimePattern .datepickerbutton");
+  $dateButton.click();
+
+  var $datepicker = jQueryFrame(".bootstrap-datetimepicker-widget");
+  assert.equal($datepicker.length, 1);
+
+  var $firstLi = jQueryFrame(".bootstrap-datetimepicker-widget .list-unstyled li:first-child");
+  var $lastLi = jQueryFrame(".bootstrap-datetimepicker-widget .list-unstyled li:last-child");
+
+  assert.notEqual($firstLi.css("display"), "none"); //block
+  assert.equal($lastLi.css("display"), "none");
+
+  var $togglePickerButton = jQueryFrame(".bootstrap-datetimepicker-widget .picker-switch a");
+  $togglePickerButton.click();
+  step++;
+
+  waitForAjax(function () {
+    $firstLi = jQueryFrame($firstLi.selector);
+    $lastLi = jQueryFrame($lastLi.selector);
+    return step === 2 && $firstLi.css("display") === "none" && $lastLi.css("display") !== "none";
+  }, function () {
+    $firstLi = jQueryFrame($firstLi.selector);
+    $lastLi = jQueryFrame($lastLi.selector);
+
+    assert.equal($firstLi.css("display"), "none");
+    assert.notEqual($lastLi.css("display"), "none"); //block
+
+    $dateButton.click(); // IE11: close datetimepicker for next test
+    done();
+  });
+});
+
+QUnit.test("submit", function (assert) {
   assert.expect(6);
   var done = assert.async();
 
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.xhtml
index 01cfe42..3eb3122 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/date.xhtml
@@ -146,7 +146,7 @@
             <pre><code class="language-markup">&lt;tc:date label="Date and time" value="\#{dateController.today}"&gt;
   &lt;f:convertDateTime pattern="dd.MM. - HH:mm" type="both"/&gt;
 &lt;/tc:date&gt;</code></pre>
-      <tc:date id="d9" label="Date and time" value="#{dateController.now}">
+      <tc:date id="dateTimePattern" label="Date and time" value="#{dateController.now}">
         <f:convertDateTime pattern="dd.MM. - HH:mm" type="both"/>
       </tc:date>
     </tc:section>
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
index b9e60eb..3e04fee 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
@@ -124,6 +124,17 @@ Tobago.DateTime.init = function (elements) {
         $date.parent().on('dp.update', function () {
           Tobago.DateTime.addPastClass($date);
         });
+
+        // fix for bootstrap-datetimepicker v4.17.45
+        $date.parent().on('dp.show', function () {
+          jQuery(".bootstrap-datetimepicker-widget .collapse.in").addClass("show");
+          jQuery(".bootstrap-datetimepicker-widget .picker-switch a").click(function () {
+            // the click is executed before togglePicker() function
+            var $datetimepicker = jQuery(".bootstrap-datetimepicker-widget");
+            $datetimepicker.find(".collapse.in").removeClass("in");
+            $datetimepicker.find(".collapse.show").addClass("in");
+          });
+        });
       });
 };
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].