Twipped / Kalendae

A javascript date picker that just works.
MIT License
1.99k stars 285 forks source link

It prompts that if stop running the script on IE8. (May be the code needs to be optimized. ) #211

Open ijobs opened 7 years ago

ijobs commented 7 years ago

THE CODE:

<script >
    new Kalendae({
         attachTo: dicument.body,
         months: 24,
         mode: "multiple",
         direction: "future",
         selected: ["2018-01-01", "2018-01-02", "2018-01-03", "2018-01-04", "2018-01-05", "2018-01-06", "2018-01-07", "2018-01-08", "2018-01-09", "2018-01-10", "2018-01-11", "2018-01-12", "2018-01-13", "2018-01-14", "2018-01-15", "2018-01-16", "2018-01-17", "2018-01-18", "2018-01-19", "2018-01-20", "2018-01-21", "2018-01-22", "2018-01-23", "2018-01-24", "2018-01-25", "2018-01-26", "2018-01-27", "2018-01-28", "2018-01-29", "2018-01-30", "2018-01-31", "2018-02-01", "2018-02-02", "2018-02-03", "2018-02-04", "2018-02-05", "2018-02-06", "2018-02-07", "2018-02-08", "2018-02-09", "2018-02-10", "2018-02-11", "2018-02-12", "2018-02-13", "2018-02-14", "2018-02-15", "2018-02-16", "2018-02-17", "2018-02-18", "2018-02-19", "2018-02-20", "2018-02-21", "2018-02-22", "2018-02-23", "2018-02-24", "2018-02-25", "2018-02-26", "2018-02-27", "2018-02-28", "2018-03-01", "2018-03-02", "2018-03-03", "2018-03-04", "2018-03-05", "2018-03-06", "2018-03-07", "2018-03-08", "2018-03-09"]
    });
</script>

PS: please notice the parameter "month"

ijobs commented 7 years ago

I modified the code in line 495 to solve the problem.

before: this._sel.sort(function(a, b){return a.startOf('day').yearDay() - b.startOf('day').yearDay()}

after:

this._sel.sort(
     function(a, b){
          var reg = /-/;
          if(reg.test(a._i)){
               return parseInt(a._i.replace(/-/g, '')) - parseInt(b._i.replace(/-/g, ''));
           }else{
               a._i - b._i;
           }
     }
)

BUT... -- I find another problem that it worked so slowly when i picked a date.