Yehzuna / jquery-schedule

jQuery Schedule
MIT License
63 stars 31 forks source link

Hidden calendar validation #22

Open skibq opened 6 years ago

skibq commented 6 years ago

Validation is based on height and distance from top calculation. Problem is when i try to build hidden calendar. Dispaly: none is giving 0px of height to calnedar, so validation is not working.

To resolve it, i add one "if condition", to disable validation, when calendar is hidden.

im creating page based on tabs, where on tab is displayd and other are hidden. Switching is based on giving display none/block to tabs content.

Here is hotfixed isValid function. Look at if ($(current).is(':visible')) { line

isValid: function (current) {
      var currentStart = Math.round(current.position().top);
      var currentEnd = Math.round(current.position().top + current.height());

      var start = 0;
      var end = 0;
      var check = true;
      if ($(current).is(':visible')) {
          $('.jqs-period', $(current).parent()).each(function (index, period) {
            if (current.attr('id') !== $(period).attr('id')) {
              start = Math.round($(period).position().top);
              end = Math.round($(period).position().top + $(period).height());

              if (start > currentStart && start < currentEnd) {
                check = false;
              }

              if (end > currentStart && end < currentEnd) {
                check = false;
              }

              if (start < currentStart && end > currentEnd) {
                check = false;
              }

              if (start === currentStart || end === currentEnd) {
                check = false;
              }
            }
          });
       }
      return check;
    },
panmitz commented 5 years ago

@skibq many thanks for this