Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="content">
  <h2>jQuery Time Picker plugin</h2>
  <h5><a href="https://www.apollowebstudio.com/screenshots/2016/jQuery%20Time%20Picker%20Plugin%20Documentation.pdf">How to use</a></h5>
  <h3>Examples</h3>
</div>
<div class="demo">
  <div style="width:500px;text-align: right;">
    <b>Example 1:</b>
    <pre style="text-align:left;">
                $('.timepicker').timepicker({
                    step:10,
                    at_row:18,
                    active_from:'21:30',
                    active_to:'10:00',
                    alarm_from:'21:30',
                    alarm_to:'23:00',
                    alarm_color:'#e73626'
                }); 
                </pre>
    <input type="text" value="11:30" class="timepicker3">
  </div>
  <br><br>
  <div style="width:500px;text-align: right;">
    <b>Example 2:</b>
    <pre style="text-align:left;">
            $('.timepicker1').timepicker({
                step:15,
                at_row:12,
                active_from:'08:00',
                active_to:'12:00',
                alarm_from:'08:00',
                alarm_to:'24:00',
                alarm_color:'#f49100'
                }); 
            </pre>
    <input type="text" value="11:30" class="timepicker1">
  </div>
  <br><br>
  <div style="width:500px;text-align: right;">
    <b>Example 3:</b>
    <pre style="text-align:left;">
            var popup3 = {
                step:60,
                at_row:3,
                active_from:'09:00',
                active_to:'18:00',
                alarm_from:'00:00',
                alarm_to:'00:00'};
            $('.timepicker2').timepicker(popup3); 
            $('#destroy_2').click(function(){
                $('.timepicker2').timepicker('destroy');
            });
            $('#create_2').click(function(){
                $('.timepicker2').timepicker(popup3);
            });
            </pre>
    <input type="text" value="11:30" class="timepicker2">
    <input type="button" id="destroy_2" value="destroy">
    <input type="button" id="create_2" value="create">
  </div>
  <br><br>
  <div style="width:500px;text-align: right;">
    <b>Example 4:</b>
    <pre style="text-align:left;">
                $('.timepicker3').timepicker({
                    step:30, // time interval in minutes
                    at_row:6, // count intervals at row
                    active_from:'10:00', // time, from links are enabled
                    active_to:'21:00', // time, from links are disabled
                    alarm_from:'10:00', // time, from links are enabled and colored (example - discount work from 10am to 3pm) 
                    alarm_to:'12:00', // time, from colored links are disabled
                    alarm_color:'#e73626', // color of colored links
                    select_callback:function(){ // called whan user select enabled time interval link
                        alert('select callback');
                    },
                    open_callback:function(){ // called whan user click at input feld and select time
                        alert('open callback');
                    },
                    close_callback:function(){ // called whan window close does not matter why
                        alert('close callback');
                    }
                }); 
            </pre>
    <input type="text" value="11:30" class="timepicker">
  </div>
  <h2 class="demo-table">Settings</h2>
  <table class="demo-table">
    <tr>
      <td>
        <b>Param</b>
      </td>
      <td>
        <b>Default</b>
      </td>
      <td>
        <b>Description</b>
      </td>
    </tr>
    <tr>
      <td>
        step
      </td>
      <td>
        30
      </td>
      <td>
        Time interval in minutes
      </td>
    </tr>
    <tr>
      <td>
        at_row
      </td>
      <td>
        6
      </td>
      <td>
        Count intervals at row
      </td>
    </tr>
    <tr>
      <td>
        active_from
      </td>
      <td>
        '00:00'
      </td>
      <td>
        Time, from links are enabled
      </td>
    </tr>
    <tr>
      <td>
        active_to
      </td>
      <td>
        '00:00'
      </td>
      <td>
        Time, from links are disabled
      </td>
    </tr>

    <tr>
      <td>
        alarm_from
      </td>
      <td>
        '00:00'
      </td>
      <td>
        Time, from links are enabled and colored (example - discount work from 10am to 3pm)
      </td>
    </tr>
    <tr>
      <td>
        alarm_to
      </td>
      <td>
        '00:00'
      </td>
      <td>
        Time, from colored links are disabled
      </td>
    </tr>
    <tr>
      <td>
        alarm_color
      </td>
      <td style="color:#e73626">
        '#e73626'
      </td>
      <td>
        Color of colored links
      </td>
    </tr>
    <tr>
      <td>
        select_callback
      </td>
      <td>
        null
      </td>
      <td>
        Called whan user select enabled time interval link
      </td>
    </tr>
    <tr>
      <td>
        open_callback
      </td>
      <td>
        null
      </td>
      <td>
        Called whan user click at input feld and select time
      </td>
    </tr>
    <tr>
      <td>
        close_callback
      </td>
      <td>
        null
      </td>
      <td>
        Called whan window close does not matter why
      </td>
    </tr>
    <tr>
      <td>
        lang
      </td>
      <td>
        'en'
      </td>
      <td>
        Language
      </td>
    </tr>
    <tr>
      <td>
        $('.timepicker').timepicker('destroy')
      </td>
      <td>
        method
      </td>
      <td>
        Destroy plugin
      </td>
    </tr>
  </table>
</div>
              
            
!

CSS

              
                /*
 * Css styles for jQuery pugin timepicker
*/

input.timepicker_input {
    background: url(https://www.apollowebstudio.com/screenshots/2016/time_bg.png) no-repeat center left;
    background-color: white;
    border: 1px solid #CCC;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    - ms-border-radius: 3px;
    border-radius: 3px;
    padding: 2px 3px 2px 35px;
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    display: inline-block;
    color: #555;
    vertical-align: middle;
    width: 100px;
    margin-right: 5px;
    cursor: pointer;
}

.reserve-time-dropdown {
    display: block;
    margin: 0;
    padding: 15px 5px;
    background: white;
    position: relative;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    box-shadow: 0px 1px 3px rgba(0,0,0,0.25);
    border: 1px solid rgba(153, 153, 153, 0.6);
}

.reserve-time-dropdown:after,.reserve-time-dropdown:before {
    bottom: 100%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.reserve-time-dropdown:after {
    border-color: rgba(255, 255, 255, 0);
    border-bottom-color: #fff;
    border-width: 5px;
    left: 50%;
    margin-left: -5px;
}

.reserve-time-dropdown:before {
    border-color: rgba(153, 153, 153, 0);
    border-bottom-color: #999;
    border-width: 6px;
    left: 50%;
    margin-left: -6px;
}

table.reserve-time-table {
    position: relative;
    border: none;
    font-size: 11px;
    text-shadow: none;
    color: #333;
}

.reserve-time-dropdown td.time-cell {
    padding: 3px;
    background: white;
    border: 1px solid white;
    text-align: center;
    line-height: 18px;
}

.reserve-time-dropdown td.time-cell a {
    padding: 3px 5px;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
}

.reserve-time-dropdown td.time-cell a:hover {
    color: #f49100;
}

.reserve-time-dropdown td.time-cell a.no-reserve-time {
    color: #bbb;
    cursor: not-allowed;
}

.reserve-time-dropdown td.time-cell a.possible-reserve-time {
    background: #f49100;
    color: #fff;
}

.reserve-time-dropdown td.time-cell .active {
    border: 1px black solid;
}

.reserve-time-dropdown td.time-cell .user_active {
    border: 1px greenyellow solid;
}

.timepicker-span {
    position: relative;
} 













/*
 * Css styles for demo
*/
body {
    position: relative;
    background: #f3f3f3;
    padding-left: 200px;
}

div.demo {
}

.demo-table {
    padding-left: 95px;
    padding-top: 30px;
}

.demo-table td {
    min-width: 150px;
} 


              
            
!

JS

              
                $.fn.timepicker = function(j) {
  var a = {
    step: 30,
    at_row: 6,
    active_from: "00:00",
    active_to: "00:00",
    alarm_from: "00:00",
    alarm_to: "00:00",
    alarm_color: "#e73626",
    lang: "en",
    select_callback: "",
    open_callback: "",
    close_callback: ""
  };
  if ("string" == typeof j && "destroy" == j) this.each(function() {
    1 === $(this).next().data("timepicker") && ($(this).next().remove(), $(this).parent().after(this), $(this).prev().remove(), $(this).off("click", this.clickFunc), $(document).off("click", this.documentClick), $(this).removeClass("timepicker_input"))
  });
  else {
    var a = $.extend({}, a, j),
      h = function(a) {
        a = a.split(":");
        return parseInt(60 * a[0]) + parseInt(a[1])
      };
    a.active_from = h(a.active_from);
    a.active_to = h(a.active_to);
    0 == a.active_from && 0 == a.active_to && (a.active_from = a.active_to = -1);
    a.alarm_from = h(a.alarm_from);
    a.alarm_to = h(a.alarm_to);
    0 == a.alarm_from && 0 == a.alarm_to && (a.alarm_from = a.alarm_to = -1);
    var b = ['<div data-timepicker="1" rel="timepickerWindow" style="position:absolute;z-index:9900;display:none;"><div class="reserve-time-dropdown"><table class="reserve-time-table">',
      ""
    ];
    b[2] = '<td class="time-cell"><a class="possible-reserve-time example" href="#" style="background:' + a.alarm_color + '">25</a></td><td class="time-cell " colspan="5" style="text-align:left;">' + {
      ru: {
        alarm_comment: " - \u0447\u0430\u0441\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043a\u0438\u0434\u043a\u0438"
      },
      en: {
        alarm_comment: " - discount time"
      }
    }[a.lang].alarm_comment + "</td></tr></tbody></table></div></div>";
    this.each(function() {
      this.setPosition = function(a) {
        $(a).css("left", 0 - a[0].clientWidth /
          2 + this.clientWidth / 2 + "px");
        $(a).css("top", this.offsetTop + this.offsetHeight + 6 + "px")
      };
      var c = this;
      this.create = function() {
        1 === $(this).next().data("timepicker") && $(this).next().remove();
        $(this).addClass("timepicker_input");
        $(this).after('<span class="timepicker-span"></span>').next().append(this).find("input");
        $(this).attr("autocomplete", "off").attr("readonly", "readonly");
        b[1] = "";
        for (var j = 1440 / a.step, e = "", m = h($(this).val()), e = new Date, l = h(e.getHours() + ":" + e.getMinutes()), k = 0; k < j; k++) {
          0 == k % a.at_row && (0 !=
            k && (b[1] += "</tr>"), b[1] += "<tr>");
          var d = k * a.step,
            f = parseInt(d / 60),
            g = d % 60;
          10 > f && (f = "0" + f);
          10 > g && (g = "0" + g);
          e = m == d ? "active" : l <= d && l + a.step >= d ? "user_active" : "";
          if (a.alarm_from < a.alarm_to) {
            if (a.alarm_from <= d && a.alarm_to >= d && -1 != a.alarm_from) {
              b[1] += '<td class="time-cell "><a class="possible-reserve-time ' + e + '" href="#" style="background:' + a.alarm_color + '">' + f + "." + g + "</a></td>";
              continue
            }
          } else if ((a.alarm_from <= d || a.alarm_to >= d) && -1 != a.alarm_from) {
            b[1] += '<td class="time-cell "><a class="possible-reserve-time ' +
              e + '" href="#" style="background:' + a.alarm_color + '">' + f + "." + g + "</a></td>";
            continue
          }
          if (a.active_from < a.active_to) {
            if (a.active_from <= d && a.active_to >= d && -1 != a.active_from) {
              b[1] += '<td class="time-cell"><a class=" ' + e + '" href="#">' + f + "." + g + "</a></td>";
              continue
            }
          } else if ((a.active_from <= d || a.active_to >= d) && -1 != a.active_from) {
            b[1] += '<td class="time-cell"><a class=" ' + e + '" href="#">' + f + "." + g + "</a></td>";
            continue
          }
          b[1] += '<td class="time-cell"><a class="no-reserve-time ' + e + '" href="#">' + f + "." + g + "</a></td>"
        }
        b[1] +=
          "</tr>";
        $(this).after(b.join().replace(/,/g, "", "g"));
        this.clickFunc = function() {
          "none" == $(c).next().css("display") ? setTimeout(function() {
            $(c).next().show();
            c.setPosition($(c).next());
            a.open_callback && a.open_callback(c)
          }, 10) : ($(c).next().hide(), a.close_callback && a.close_callback(c))
        };
        $(this).next().find("a").click(function() {
          if ($(this).hasClass("no-reserve-time") || $(this).hasClass("example")) return !1;
          $(c).next().find("a").removeClass("active");
          $(this).addClass("active");
          a.select_callback && a.select_callback(this);
console.log($(this).html());
          $(c).val($(this).html());
          c.clickFunc();
          return !1
        });
        this.focused = 0;
        $(this).next().mouseover(function() {
          c.focused = 1
        }).mouseout(function() {
          c.focused = 0
        });
        this.documentClick = function() {
          !c.focused && "none" != $(c).next().css("display") && ($(c).next().hide(), a.close_callback && a.close_callback(c))
        };
        $(document).on("click", this.documentClick);
        $(document).keydown(function(b) {
          27 == b.keyCode && "none" != $(c).css("display") && ($(c).next().hide(), a.close_callback && a.close_callback(c))
        })
      };
      this.create();
      $(this).on("click", c.clickFunc)
    });
    return !0
  }
};

$(document).ready(function() {
  $('.timepicker').timepicker({
    step: 30,
    at_row: 6,
    active_from: '10:00',
    active_to: '21:00',
    alarm_from: '10:00',
    alarm_to: '12:00',
    alarm_color: '#e73626',
    select_callback: function() {
      alert('select callback');
    },
    open_callback: function() {
      alert('open callback');
    },
    close_callback: function() {
      alert('close callback');
    }
  });
  $('.timepicker1').timepicker({
    step: 15,
    at_row: 12,
    active_from: '08:00',
    active_to: '12:00',
    alarm_from: '08:00',
    alarm_to: '24:00',
    alarm_color: '#f49100'
  });
  var popup3 = {
    step: 60,
    at_row: 3,
    active_from: '09:00',
    active_to: '18:00',
    alarm_from: '00:00',
    alarm_to: '00:00'
  };
  $('.timepicker2').timepicker(popup3);
  $('#destroy_2').click(function() {
    $('.timepicker2').timepicker('destroy');
  });
  $('#create_2').click(function() {
    $('.timepicker2').timepicker(popup3);
  });
  $('.timepicker3').timepicker({
    step: 10,
    at_row: 18,
    active_from: '21:30',
    active_to: '10:00',
    alarm_from: '21:00',
    alarm_to: '23:00',
    alarm_color: '#e73626'
  });
});
              
            
!
999px

Console