You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2016/05/25 10:20:51 UTC

svn commit: r1745465 - /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js

Author: lofwyr
Date: Wed May 25 10:20:50 2016
New Revision: 1745465

URL: http://svn.apache.org/viewvc?rev=1745465&view=rev
Log:
TOBAGO 1483 Let tc date use a Bootstrap component as picker
* fix change event

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js?rev=1745465&r1=1745464&r2=1745465&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-calendar.js Wed May 25 10:20:50 2016
@@ -23,9 +23,9 @@ Tobago.DateTime.init = function (element
       .not("[disabled]")
       .not("[readonly]")
       .each(function () {
-        var date = jQuery(this);
+        var $date = jQuery(this);
 
-        var analyzed = Tobago.DateTime.analyzePattern(date.data("tobago-pattern"));
+        var analyzed = Tobago.DateTime.analyzePattern($date.data("tobago-pattern"));
         var options = {
           format: analyzed,
           icons: {
@@ -42,7 +42,7 @@ Tobago.DateTime.init = function (element
           widgetParent: '.tobago-page'
         };
 
-        var i18n = date.data("tobago-date-time-i18n");
+        var i18n = $date.data("tobago-date-time-i18n");
         if (i18n) {
           var monthNames = i18n.monthNames;
           if (monthNames) {
@@ -70,13 +70,34 @@ Tobago.DateTime.init = function (element
           }
         }
 
-        date.parent().datetimepicker(options);
+        $date.parent().datetimepicker(options);
+
+        // we need to add the change listener here, because
+        // in line 1307 of bootstrap-datetimepicker.js
+        // the 'stopImmediatePropagation()' stops the change-event
+        // execution of line 686 in tobago.js
+        $date.parent().on('dp.change', function (event) {
+          var commands = jQuery(this).find("input").data("tobago-commands");
+          if (commands.change.partially) {
+            //Tobago.reloadComponent(this, commands.change.partially, commands.change.action, commands.change);
+            jsf.ajax.request(
+                jQuery(this).find("input").attr("name"),
+                event,
+                {
+                  "javax.faces.behavior.event": "change",
+                  execute: commands.change.partially,
+                  render: commands.change.partially
+                });
+          } else {
+            Tobago.submitAction(this.firstElementChild, commands.change.action, commands.change);
+          }
+        });
 
         /*
          XXX need for fixing wrong positioning of bootstrap datepicker.
          See https://github.com/Eonasdan/bootstrap-datetimepicker/issues/790 for more information.
          */
-        date.parent().on('dp.show', function () {
+        $date.parent().on('dp.show', function () {
           var datepicker = jQuery('.bootstrap-datetimepicker-widget');
           var $div = jQuery(this);
           if (datepicker.hasClass('bottom')) {