dlegr250_material_design 0.5.56 → 0.5.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dlegr250_material_design/version.rb +1 -1
  3. data/vendor/assets/javascripts/components/clockpicker.coffee +31 -0
  4. data/vendor/assets/javascripts/components/combobox.coffee +28 -0
  5. data/vendor/assets/javascripts/components/datepicker.coffee +29 -0
  6. data/vendor/assets/javascripts/components/expansion_panels.coffee +14 -0
  7. data/vendor/assets/javascripts/components/form_submit_buttons.coffee +4 -0
  8. data/vendor/assets/javascripts/components/html_editor.coffee +94 -0
  9. data/vendor/assets/javascripts/dlegr250_material_design.js +2 -6
  10. data/vendor/assets/javascripts/extensions/jquery/binary_insert.coffee +61 -0
  11. data/vendor/assets/javascripts/extensions/jquery/increment_and_decrement.coffee +19 -0
  12. data/vendor/assets/javascripts/extensions/jquery/positioning.coffee +22 -0
  13. data/vendor/assets/javascripts/extensions/jquery/spinner.coffee +13 -0
  14. data/vendor/assets/javascripts/third_party/autosize.min.3.0.20.js +6 -0
  15. data/vendor/assets/javascripts/third_party/jquery.clockpicker.js +737 -0
  16. data/vendor/assets/javascripts/third_party/moment.min.2.17.1.js +551 -0
  17. data/vendor/assets/javascripts/third_party/mousetrap.min.1.6.0.js +11 -0
  18. data/vendor/assets/javascripts/third_party/pikaday.base.js +1201 -0
  19. data/vendor/assets/javascripts/third_party/pikaday.jquery.js +56 -0
  20. data/vendor/assets/javascripts/third_party/scroll_scope.min.js +4 -0
  21. data/vendor/assets/javascripts/third_party/select2.min.4.0.3.js +3 -0
  22. data/vendor/assets/javascripts/third_party/sortable.js +1481 -0
  23. data/vendor/assets/stylesheets/base/global_classes.scss +0 -6
  24. data/vendor/assets/stylesheets/components/comments.scss +43 -4
  25. data/vendor/assets/stylesheets/components/cursors.scss +6 -0
  26. data/vendor/assets/stylesheets/components/dialogs.scss +5 -2
  27. data/vendor/assets/stylesheets/components/expansion_panels.scss +19 -0
  28. data/vendor/assets/stylesheets/components/lists.scss +48 -4
  29. data/vendor/assets/stylesheets/dlegr250_material_design.scss +2 -0
  30. data/vendor/assets/stylesheets/layouts/application/appbar.scss +4 -4
  31. metadata +23 -3
  32. data/vendor/assets/javascripts/extensions/jquery.js.coffee +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f7e4851568813052c1e24e54bc36411acd45172
4
- data.tar.gz: 5a28b7a91bf5ad136608df5ce363d98a9c8c56b3
3
+ metadata.gz: cb92af7b02663bd3df3f46e5569dc993ebba9437
4
+ data.tar.gz: d2c2ae272666057ce34659b7b4e0eaf4a60d3a9a
5
5
  SHA512:
6
- metadata.gz: 3fd9a6b19f7d003614647abfcc2a2b5cb74cd8f4e666d2fade0945332e9cc4cbc2c4168383be1677078f494416d707d3ec1d4fe9b04fb9b565bd59aa55d04ba7
7
- data.tar.gz: 1830de9b6f2f00550e3c24ea479784e713575440683af5a700ffc6cdadd805bee63a8d15c264a5071616a469a3ae25e04e61d420d558f07bea96069c70be26d6
6
+ metadata.gz: 552ee703ae299327f500448b04c03453dd437c39dd7ded79c8307d691384257677d1aa3abc44ff56db2f7fa848c31aa309d54eeac2399c57b2551fbd7ff12a0c
7
+ data.tar.gz: d898459d07bdb43a6dbe7fa3bd77ae8a96144bbdc23f3f70fff5c3296c56c7c31dcef8c413f27de44b0a1e901e1497e3027e80a53bd6ddbe9045025722a218cf
@@ -1,3 +1,3 @@
1
1
  module Dlegr250MaterialDesign
2
- VERSION = "0.5.56"
2
+ VERSION = "0.5.57"
3
3
  end
@@ -0,0 +1,31 @@
1
+ class App.MD.Clockpicker
2
+ @init: () ->
3
+ # TODO DEPRECATE
4
+ $.map $("[role='clockpicker']"), (element, index) ->
5
+ new App.MD.Clockpicker(element)
6
+
7
+ $.map $("[data-behavior='clockpicker']"), (element, index) ->
8
+ new App.MD.Clockpicker(element)
9
+
10
+ constructor: (element, options = {}) ->
11
+ @$element = $(element)
12
+
13
+ # Do not re-run on elements that already have clockpickers
14
+ if @$element.attr("data-has-clockpicker") == "true"
15
+ return
16
+ else
17
+ @options = $.extend({}, @defaultOptions(), options)
18
+ @init()
19
+
20
+ init: () ->
21
+ @$element.clockpicker(@options)
22
+ @$element.attr("data-has-clockpicker", true)
23
+
24
+ defaultOptions: () ->
25
+ {
26
+ donetext: "Select",
27
+ twelvehour: true,
28
+ autoclose: false,
29
+ placement: "bottom",
30
+ align: "left",
31
+ }
@@ -0,0 +1,28 @@
1
+ class App.MD.Combobox
2
+ @init: () ->
3
+ $.map $("[role='combobox']"), (element, index) ->
4
+ new App.MD.Combobox(element)
5
+
6
+ $.map $("[data-behavior='combobox']"), (element, index) ->
7
+ new App.MD.Combobox(element)
8
+
9
+ constructor: (element, options = {}) ->
10
+ @$element = $(element)
11
+
12
+ if @$element.attr("data-has-combobox") == "true"
13
+ return
14
+ else
15
+ @options = $.extend({}, @defaultOptions(), options)
16
+ @init()
17
+
18
+ init: () ->
19
+ @$element.select2(@options)
20
+ @$element.attr("data-has-combobox", true)
21
+
22
+ defaultOptions: () ->
23
+ {
24
+ placeholder: null,
25
+ allowClear: true,
26
+ minimumResultsForSearch: Infinity,
27
+ maximumSelectionLength: 1
28
+ }
@@ -0,0 +1,29 @@
1
+ class App.MD.Datepicker
2
+ @init: () ->
3
+ # TODO DEPRECATE: use data-behavior below
4
+ $.map $("[role='datepicker']"), (element, index) ->
5
+ new App.MD.Datepicker(element)
6
+
7
+ $.map $("[data-behavior='datepicker']"), (element, index) ->
8
+ new App.MD.Datepicker(element)
9
+
10
+ constructor: (element, options = {}) ->
11
+ @$element = $(element)
12
+
13
+ # Do not re-run on elements that already have datepickers
14
+ if @$element.attr("data-has-datepicker") == "true"
15
+ return
16
+ else
17
+ @options = $.extend({}, @defaultOptions(), options)
18
+ @init()
19
+
20
+ init: () ->
21
+ @$element.pikaday(@options)
22
+ @$element.attr("data-has-datepicker", true)
23
+
24
+ defaultOptions: () ->
25
+ {
26
+ format: "MM/DD/YYYY",
27
+ bound: true,
28
+ keyboardInput: false,
29
+ }
@@ -0,0 +1,14 @@
1
+ window.App.MD ||= {}
2
+
3
+ class App.MD.ExpansionPanel
4
+ @init: () ->
5
+ $(document).off("click", "[data-behavior='expansion-panel-toggle']").on "click", "[data-behavior='expansion-panel-toggle']", (e) ->
6
+ $panel = $(this).closest("[data-behavior='expansion-panel']")
7
+ $details = $panel.find("[data-behavior='expansion-panel-details']")
8
+ $editor = $details.find("[data-behavior~='html-editor']")
9
+
10
+ if $panel.attr("data-state") == "expanded"
11
+ $panel.attr("data-state", "collapsed")
12
+ else
13
+ $panel.attr("data-state", "expanded")
14
+ $editor.froalaEditor("events.focus") if $editor.length > 0
@@ -0,0 +1,4 @@
1
+ $(document).on "turbolinks:load", ->
2
+ $("[data-submit]").on "click", (e) ->
3
+ formId = $(this).data("submit")
4
+ $(formId).submit()
@@ -0,0 +1,94 @@
1
+ class App.MD.HtmlEditor
2
+ constructor: (element, options = {}) ->
3
+ @$element = $(element)
4
+ @format = options["format"] || "simple"
5
+ @templateVariables = options["templateVariables"] || false
6
+
7
+ if @format == "full"
8
+ @options = $.extend({}, @defaultFullSettings(), options)
9
+ else if @format == "core"
10
+ @options = $.extend({}, @defaultCoreSettings(), options)
11
+ else
12
+ @options = $.extend({}, @defaultSimpleSettings(), options)
13
+
14
+ @init()
15
+
16
+ init: () ->
17
+ if @templateVariables
18
+ @$element.on("froalaEditor.initialized", (e, editor) ->
19
+ new App.AtWhoWithTemplateVariables(editor.$el)
20
+ editor.events.on("keydown", (e) ->
21
+ if (e.which == $.FroalaEditor.KEYCODE.ENTER && editor.$el.atwho("isSelecting"))
22
+ return false
23
+ , true)
24
+ ).froalaEditor(@options)
25
+ else
26
+ @$element.froalaEditor(@options)
27
+
28
+ if @options["focus"] == true || @$element.attr("autofocus")
29
+ @$element.froalaEditor("events.focus")
30
+
31
+ # Simple Settings
32
+ #----------------------------------------------------------------------
33
+
34
+ defaultCoreSettings: () ->
35
+ {
36
+ placeholderText: null,
37
+ enter: 2, # $.FroalaEditor.ENTER_BR
38
+ heightMin: 100,
39
+ toolbarBottom: false,
40
+ toolbarSticky: false,
41
+ toolbarButtons: @coreToolbarButtons(),
42
+ toolbarButtonsMD: @coreToolbarButtons(),
43
+ toolbarButtonsSM: @coreToolbarButtons(),
44
+ toolbarButtonsXS: @coreToolbarButtons(),
45
+ }
46
+
47
+ coreToolbarButtons: () ->
48
+ [
49
+ "bold", "italic", "underline", "|", "formatOL", "formatUL"
50
+ ]
51
+
52
+ defaultSimpleSettings: () ->
53
+ {
54
+ placeholderText: null,
55
+ enter: 2, # $.FroalaEditor.ENTER_BR
56
+ heightMin: 100,
57
+ toolbarBottom: false,
58
+ toolbarSticky: false,
59
+ toolbarButtons: @simpleToolbarButtons(),
60
+ toolbarButtonsMD: @simpleToolbarButtons(),
61
+ toolbarButtonsSM: @simpleToolbarButtons(),
62
+ toolbarButtonsXS: @simpleToolbarButtons(),
63
+ }
64
+
65
+ simpleToolbarButtons: () ->
66
+ [
67
+ "bold", "italic", "underline", "color",
68
+ "|", "insertLink",
69
+ "|", "formatOL", "formatUL", "outdent", "indent",
70
+ "|", "clearFormatting"
71
+ ]
72
+
73
+ # Full Settings
74
+ #----------------------------------------------------------------------
75
+
76
+ defaultFullSettings: () ->
77
+ {
78
+ placeholderText: null,
79
+ enter: 2, # $.FroalaEditor.ENTER_BR
80
+ heightMin: 100,
81
+ toolbarBottom: false,
82
+ toolbarSticky: false,
83
+ toolbarButtons: @fullToolbarButtons(),
84
+ toolbarButtonsMD: @fullToolbarButtons(),
85
+ toolbarButtonsSM: @fullToolbarButtons(),
86
+ toolbarButtonsXS: @fullToolbarButtons(),
87
+ }
88
+
89
+ fullToolbarButtons: () ->
90
+ [
91
+ "fontSize", "|", "bold", "italic", "underline", "color",
92
+ "|", "align", "formatOL", "formatUL", "outdent",
93
+ "indent", "|", "insertLink", "|", "clearFormatting"
94
+ ]
@@ -4,11 +4,7 @@
4
4
  //= require jquery3
5
5
  //= require jquery_ujs
6
6
  //= require turbolinks
7
- //= require extensions/jquery
8
- //= require extensions/coffeescript
7
+ //= require ./extensions
9
8
  //= require base/init
10
- //= require third_party/handlebars.latest
11
- //= require third_party/jquery.inputmask.min.3.2.8-11
12
- //= require third_party/jquery.autonumeric.1-9-44
13
- //= require third_party/jquery.scroll_scope.min.0.1.0
9
+ //= require_tree ./third_party
14
10
  //= require_tree ./components
@@ -0,0 +1,61 @@
1
+ jQuery.extend jQuery.fn,
2
+ binaryInsert: (element) ->
3
+ @each ->
4
+ $list = $(this)
5
+
6
+ # Remove any elements that have a blank sort attribute
7
+ # See: http://stackoverflow.com/a/8127904/667772
8
+ $collection = $list.children().filter ->
9
+ return !!$(this).attr("data-sort")
10
+
11
+ # Pre-fetch values to compare
12
+ $collectionValues = $collection.map ->
13
+ $(this).attr("data-sort")
14
+
15
+ # New element to insert
16
+ $element = $(element)
17
+ elementValue = $element.attr("data-sort")
18
+
19
+ collectionLength = $collection.length
20
+ startIndex = 0
21
+ endIndex = collectionLength - 1
22
+ middleIndex = startIndex + Math.floor((endIndex - startIndex) / 2)
23
+
24
+ # Edge cases for optimizations
25
+ #----------------------------------------------------------------------
26
+
27
+ # Empty list, make new element first one
28
+ if collectionLength <= 0
29
+ $list.append($element)
30
+ return
31
+
32
+ # New element does not have a sortable value, add to the bottom
33
+ if elementValue == null || elementValue == "" || isNaN(elementValue)
34
+ $list.append($element)
35
+ return
36
+
37
+ # Less than start element, so prepend to collection
38
+ if elementValue <= $collection.first().attr("data-sort")
39
+ $list.prepend($element)
40
+ return
41
+
42
+ # Greater than last element, so append to collection
43
+ if elementValue >= $collection.last().attr("data-sort")
44
+ $list.append($element)
45
+ return
46
+
47
+ # Actual binary search algorithm
48
+ #----------------------------------------------------------------------
49
+
50
+ while startIndex <= endIndex
51
+ middleIndex = startIndex + Math.floor((endIndex - startIndex) / 2)
52
+
53
+ if $collectionValues[middleIndex] > elementValue
54
+ endIndex = middleIndex - 1
55
+ continue
56
+
57
+ startIndex = middleIndex + 1
58
+ if $collectionValues[middleIndex] == elementValue
59
+ break
60
+
61
+ $collection.eq(startIndex).before($element)
@@ -0,0 +1,19 @@
1
+ jQuery.extend jQuery.fn,
2
+ increment: ->
3
+ @each ->
4
+ $element = $(this)
5
+ $value = parseInt($element.text())
6
+ if $value != NaN
7
+ $element.text($value + 1)
8
+ $element
9
+
10
+ decrement: ->
11
+ @each ->
12
+ $element = $(this)
13
+ $value = parseInt($element.text())
14
+ if $value != NaN
15
+ if $value <= 0
16
+ $element.text(0)
17
+ else
18
+ $element.text($value - 1)
19
+ $element
@@ -0,0 +1,22 @@
1
+ # Center an absolute element horizontally and vertically in window
2
+ #----------------------------------------------------------------------
3
+
4
+ jQuery.extend jQuery.fn,
5
+ absoluteCenter: ->
6
+ @each ->
7
+ element = $(this)
8
+ element.css("left", ($(document).width() - element.width()) / 2)
9
+ element.css("top", ($(document).height() - element.height()) / 2)
10
+ element
11
+
12
+ horizontalCenter: ->
13
+ @each ->
14
+ element = $(this)
15
+ element.css("left", ($(document).width() - element.width()) / 2)
16
+ element
17
+
18
+ verticalCenter: ->
19
+ @each ->
20
+ element = $(this)
21
+ element.css("top", ($(document).height() - element.height()) / 2)
22
+ element
@@ -0,0 +1,13 @@
1
+ # Change content of element to be centered spinner
2
+ #----------------------------------------------------------------------
3
+
4
+ jQuery.extend jQuery.fn,
5
+ replaceWithSpinner: (options = {}) ->
6
+ color = options["color"] || "primary"
7
+ size = options["size"] || "normal"
8
+
9
+ @each ->
10
+ element = $(this)
11
+ spinner = $("<div class='spinner-container'><div class='spinner spinner-#{color} spinner-#{size}'></div></div>")
12
+ element.html(spinner)
13
+ element
@@ -0,0 +1,6 @@
1
+ /*!
2
+ Autosize 3.0.20
3
+ license: MIT
4
+ http://www.jacklmoore.com/autosize
5
+ */
6
+ !function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var n={exports:{}};t(n.exports,n),e.autosize=n.exports}}(this,function(e,t){"use strict";function n(e){function t(){var t=window.getComputedStyle(e,null);"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),s="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(s)&&(s=0),l()}function n(t){var n=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=n,e.style.overflowY=t}function o(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}function r(){var t=e.style.height,n=o(e),r=document.documentElement&&document.documentElement.scrollTop;e.style.height="auto";var i=e.scrollHeight+s;return 0===e.scrollHeight?void(e.style.height=t):(e.style.height=i+"px",u=e.clientWidth,n.forEach(function(e){e.node.scrollTop=e.scrollTop}),void(r&&(document.documentElement.scrollTop=r)))}function l(){r();var t=Math.round(parseFloat(e.style.height)),o=window.getComputedStyle(e,null),i=Math.round(parseFloat(o.height));if(i!==t?"visible"!==o.overflowY&&(n("visible"),r(),i=Math.round(parseFloat(window.getComputedStyle(e,null).height))):"hidden"!==o.overflowY&&(n("hidden"),r(),i=Math.round(parseFloat(window.getComputedStyle(e,null).height))),a!==i){a=i;var l=d("autosize:resized");try{e.dispatchEvent(l)}catch(e){}}}if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!i.has(e)){var s=null,u=e.clientWidth,a=null,p=function(){e.clientWidth!==u&&l()},c=function(t){window.removeEventListener("resize",p,!1),e.removeEventListener("input",l,!1),e.removeEventListener("keyup",l,!1),e.removeEventListener("autosize:destroy",c,!1),e.removeEventListener("autosize:update",l,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n]}),i.delete(e)}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",c,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",l,!1),window.addEventListener("resize",p,!1),e.addEventListener("input",l,!1),e.addEventListener("autosize:update",l,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",i.set(e,{destroy:c,update:l}),t()}}function o(e){var t=i.get(e);t&&t.destroy()}function r(e){var t=i.get(e);t&&t.update()}var i="function"==typeof Map?new Map:function(){var e=[],t=[];return{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){e.indexOf(n)===-1&&(e.push(n),t.push(o))},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1))}}}(),d=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){d=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?(l=function(e){return e},l.destroy=function(e){return e},l.update=function(e){return e}):(l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return n(e,t)}),e},l.destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e}),t.exports=l});
@@ -0,0 +1,737 @@
1
+ /*!
2
+ * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
3
+ * Copyright 2014 Wang Shenwei.
4
+ * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
5
+ */
6
+
7
+ ;(function(){
8
+ var $ = window.jQuery,
9
+ $win = $(window),
10
+ $doc = $(document),
11
+ $body;
12
+
13
+ // Can I use inline svg ?
14
+ var svgNS = 'http://www.w3.org/2000/svg',
15
+ svgSupported = 'SVGAngle' in window && (function(){
16
+ var supported,
17
+ el = document.createElement('div');
18
+ el.innerHTML = '<svg/>';
19
+ supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
20
+ el.innerHTML = '';
21
+ return supported;
22
+ })();
23
+
24
+ // Can I use transition ?
25
+ var transitionSupported = (function(){
26
+ var style = document.createElement('div').style;
27
+ return 'transition' in style ||
28
+ 'WebkitTransition' in style ||
29
+ 'MozTransition' in style ||
30
+ 'msTransition' in style ||
31
+ 'OTransition' in style;
32
+ })();
33
+
34
+ // Listen touch events in touch screen device, instead of mouse events in desktop.
35
+ var touchSupported = 'ontouchstart' in window,
36
+ mousedownEvent = 'mousedown' + ( touchSupported ? ' touchstart' : ''),
37
+ mousemoveEvent = 'mousemove.clockpicker' + ( touchSupported ? ' touchmove.clockpicker' : ''),
38
+ mouseupEvent = 'mouseup.clockpicker' + ( touchSupported ? ' touchend.clockpicker' : '');
39
+
40
+ // Vibrate the device if supported
41
+ var vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
42
+
43
+ function createSvgElement(name) {
44
+ return document.createElementNS(svgNS, name);
45
+ }
46
+
47
+ function leadingZero(num) {
48
+ return (num < 10 ? '0' : '') + num;
49
+ }
50
+
51
+ // Get a unique id
52
+ var idCounter = 0;
53
+ function uniqueId(prefix) {
54
+ var id = ++idCounter + '';
55
+ return prefix ? prefix + id : id;
56
+ }
57
+
58
+ // Clock size
59
+ var dialRadius = 100,
60
+ outerRadius = 80,
61
+ // innerRadius = 80 on 12 hour clock
62
+ innerRadius = 54,
63
+ tickRadius = 13,
64
+ diameter = dialRadius * 2,
65
+ duration = transitionSupported ? 350 : 1;
66
+
67
+ // Popover template
68
+ var tpl = [
69
+ '<div class="popover clockpicker-popover">',
70
+ // '<div class="arrow"></div>',
71
+ '<div class="popover-title">',
72
+ '<span class="clockpicker-span-hours text-primary"></span>',
73
+ ' : ',
74
+ '<span class="clockpicker-span-minutes"></span>',
75
+ ' <span class="clockpicker-span-am-pm"></span>',
76
+ '</div>',
77
+ '<div class="popover-content">',
78
+ '<div class="clockpicker-plate">',
79
+ '<div class="clockpicker-canvas"></div>',
80
+ '<div class="clockpicker-dial clockpicker-hours"></div>',
81
+ '<div class="clockpicker-dial clockpicker-minutes clockpicker-dial-out"></div>',
82
+ '</div>',
83
+ '<span class="clockpicker-am-pm-block">',
84
+ '</span>',
85
+ '</div>',
86
+ '</div>'
87
+ ].join('');
88
+
89
+ // ClockPicker
90
+ function ClockPicker(element, options) {
91
+ var popover = $(tpl),
92
+ plate = popover.find('.clockpicker-plate'),
93
+ hoursView = popover.find('.clockpicker-hours'),
94
+ minutesView = popover.find('.clockpicker-minutes'),
95
+ amPmBlock = popover.find('.clockpicker-am-pm-block'),
96
+ isInput = element.prop('tagName') === 'INPUT',
97
+ input = isInput ? element : element.find('input'),
98
+ addon = element.find('.input-group-addon'),
99
+ self = this,
100
+ timer;
101
+
102
+ this.id = uniqueId('cp');
103
+ this.element = element;
104
+ this.options = options;
105
+ this.isAppended = false;
106
+ this.isShown = false;
107
+ this.currentView = 'hours';
108
+ this.isInput = isInput;
109
+ this.input = input;
110
+ this.addon = addon;
111
+ this.popover = popover;
112
+ this.plate = plate;
113
+ this.hoursView = hoursView;
114
+ this.minutesView = minutesView;
115
+ this.amPmBlock = amPmBlock;
116
+ this.spanHours = popover.find('.clockpicker-span-hours');
117
+ this.spanMinutes = popover.find('.clockpicker-span-minutes');
118
+ this.spanAmPm = popover.find('.clockpicker-span-am-pm');
119
+ this.amOrPm = "PM";
120
+
121
+ // Setup for for 12 hour clock if option is selected
122
+ if (options.twelvehour) {
123
+
124
+ var amPmButtonsTemplate = ['<div class="clockpicker-am-pm-block">',
125
+ '<button type="button" class="btn btn-sm btn-default clockpicker-button clockpicker-am-button">',
126
+ 'AM</button>',
127
+ '<button type="button" class="btn btn-sm btn-default clockpicker-button clockpicker-pm-button">',
128
+ 'PM</button>',
129
+ '</div>'].join('');
130
+
131
+ var amPmButtons = $(amPmButtonsTemplate);
132
+ //amPmButtons.appendTo(plate);
133
+
134
+ ////Not working b/c they are not shown when this runs
135
+ //$('clockpicker-am-button')
136
+ // .on("click", function() {
137
+ // self.amOrPm = "AM";
138
+ // $('.clockpicker-span-am-pm').empty().append('AM');
139
+ // });
140
+ //
141
+ //$('clockpicker-pm-button')
142
+ // .on("click", function() {
143
+ // self.amOrPm = "PM";
144
+ // $('.clockpicker-span-am-pm').empty().append('PM');
145
+ // });
146
+
147
+ $('<button type="button" class="btn btn-sm btn-default clockpicker-button am-button">' + "AM" + '</button>')
148
+ .on("click", function() {
149
+ self.amOrPm = "AM";
150
+ $('.clockpicker-span-am-pm').empty().append('AM');
151
+ }).appendTo(this.amPmBlock);
152
+
153
+
154
+ $('<button type="button" class="btn btn-sm btn-default clockpicker-button pm-button">' + "PM" + '</button>')
155
+ .on("click", function() {
156
+ self.amOrPm = 'PM';
157
+ $('.clockpicker-span-am-pm').empty().append('PM');
158
+ }).appendTo(this.amPmBlock);
159
+
160
+ }
161
+
162
+ if (! options.autoclose) {
163
+ // If autoclose is not setted, append a button
164
+ $('<button type="button" class="btn btn-sm btn-default btn-block clockpicker-button">' + options.donetext + '</button>')
165
+ .click($.proxy(this.done, this))
166
+ .appendTo(popover);
167
+ }
168
+
169
+ // Placement and arrow align - make sure they make sense.
170
+ if ((options.placement === 'top' || options.placement === 'bottom') && (options.align === 'top' || options.align === 'bottom')) options.align = 'left';
171
+ if ((options.placement === 'left' || options.placement === 'right') && (options.align === 'left' || options.align === 'right')) options.align = 'top';
172
+
173
+ popover.addClass(options.placement);
174
+ popover.addClass('clockpicker-align-' + options.align);
175
+
176
+ this.spanHours.click($.proxy(this.toggleView, this, 'hours'));
177
+ this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes'));
178
+
179
+ // Show or toggle
180
+ input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this));
181
+ addon.on('click.clockpicker', $.proxy(this.toggle, this));
182
+
183
+ // Build ticks
184
+ var tickTpl = $('<div class="clockpicker-tick"></div>'),
185
+ i, tick, radian, radius;
186
+
187
+ // Hours view
188
+ if (options.twelvehour) {
189
+ for (i = 1; i < 13; i += 1) {
190
+ tick = tickTpl.clone();
191
+ radian = i / 6 * Math.PI;
192
+ radius = outerRadius;
193
+ tick.css('font-size', '120%');
194
+ tick.css({
195
+ left: dialRadius + Math.sin(radian) * radius - tickRadius,
196
+ top: dialRadius - Math.cos(radian) * radius - tickRadius
197
+ });
198
+ tick.html(i === 0 ? '00' : i);
199
+ hoursView.append(tick);
200
+ tick.on(mousedownEvent, mousedown);
201
+ }
202
+ } else {
203
+ for (i = 0; i < 24; i += 1) {
204
+ tick = tickTpl.clone();
205
+ radian = i / 6 * Math.PI;
206
+ var inner = i > 0 && i < 13;
207
+ radius = inner ? innerRadius : outerRadius;
208
+ tick.css({
209
+ left: dialRadius + Math.sin(radian) * radius - tickRadius,
210
+ top: dialRadius - Math.cos(radian) * radius - tickRadius
211
+ });
212
+ if (inner) {
213
+ tick.css('font-size', '120%');
214
+ }
215
+ tick.html(i === 0 ? '00' : i);
216
+ hoursView.append(tick);
217
+ tick.on(mousedownEvent, mousedown);
218
+ }
219
+ }
220
+
221
+ // Minutes view
222
+ for (i = 0; i < 60; i += 5) {
223
+ tick = tickTpl.clone();
224
+ radian = i / 30 * Math.PI;
225
+ tick.css({
226
+ left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
227
+ top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
228
+ });
229
+ tick.css('font-size', '120%');
230
+ tick.html(leadingZero(i));
231
+ minutesView.append(tick);
232
+ tick.on(mousedownEvent, mousedown);
233
+ }
234
+
235
+ // Clicking on minutes view space
236
+ plate.on(mousedownEvent, function(e){
237
+ if ($(e.target).closest('.clockpicker-tick').length === 0) {
238
+ mousedown(e, true);
239
+ }
240
+ });
241
+
242
+ // Mousedown or touchstart
243
+ function mousedown(e, space) {
244
+ var offset = plate.offset(),
245
+ isTouch = /^touch/.test(e.type),
246
+ x0 = offset.left + dialRadius,
247
+ y0 = offset.top + dialRadius,
248
+ dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
249
+ dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
250
+ z = Math.sqrt(dx * dx + dy * dy),
251
+ moved = false;
252
+
253
+ // When clicking on minutes view space, check the mouse position
254
+ if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {
255
+ return;
256
+ }
257
+ e.preventDefault();
258
+
259
+ // Set cursor style of body after 200ms
260
+ var movingTimer = setTimeout(function(){
261
+ $body.addClass('clockpicker-moving');
262
+ }, 200);
263
+
264
+ // Place the canvas to top
265
+ if (svgSupported) {
266
+ plate.append(self.canvas);
267
+ }
268
+
269
+ // Clock
270
+ self.setHand(dx, dy, ! space, true);
271
+
272
+ // Mousemove on document
273
+ $doc.off(mousemoveEvent).on(mousemoveEvent, function(e){
274
+ e.preventDefault();
275
+ var isTouch = /^touch/.test(e.type),
276
+ x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
277
+ y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
278
+ if (! moved && x === dx && y === dy) {
279
+ // Clicking in chrome on windows will trigger a mousemove event
280
+ return;
281
+ }
282
+ moved = true;
283
+ self.setHand(x, y, false, true);
284
+ });
285
+
286
+ // Mouseup on document
287
+ $doc.off(mouseupEvent).on(mouseupEvent, function(e){
288
+ $doc.off(mouseupEvent);
289
+ e.preventDefault();
290
+ var isTouch = /^touch/.test(e.type),
291
+ x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
292
+ y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
293
+ if ((space || moved) && x === dx && y === dy) {
294
+ self.setHand(x, y);
295
+ }
296
+ if (self.currentView === 'hours') {
297
+ self.toggleView('minutes', duration / 2);
298
+ } else {
299
+ if (options.autoclose) {
300
+ self.minutesView.addClass('clockpicker-dial-out');
301
+ setTimeout(function(){
302
+ self.done();
303
+ }, duration / 2);
304
+ }
305
+ }
306
+ plate.prepend(canvas);
307
+
308
+ // Reset cursor style of body
309
+ clearTimeout(movingTimer);
310
+ $body.removeClass('clockpicker-moving');
311
+
312
+ // Unbind mousemove event
313
+ $doc.off(mousemoveEvent);
314
+ });
315
+ }
316
+
317
+ if (svgSupported) {
318
+ // Draw clock hands and others
319
+ var canvas = popover.find('.clockpicker-canvas'),
320
+ svg = createSvgElement('svg');
321
+ svg.setAttribute('class', 'clockpicker-svg');
322
+ svg.setAttribute('width', diameter);
323
+ svg.setAttribute('height', diameter);
324
+ var g = createSvgElement('g');
325
+ g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
326
+ var bearing = createSvgElement('circle');
327
+ bearing.setAttribute('class', 'clockpicker-canvas-bearing');
328
+ bearing.setAttribute('cx', 0);
329
+ bearing.setAttribute('cy', 0);
330
+ bearing.setAttribute('r', 2);
331
+ var hand = createSvgElement('line');
332
+ hand.setAttribute('x1', 0);
333
+ hand.setAttribute('y1', 0);
334
+ var bg = createSvgElement('circle');
335
+ bg.setAttribute('class', 'clockpicker-canvas-bg');
336
+ bg.setAttribute('r', tickRadius);
337
+ var fg = createSvgElement('circle');
338
+ fg.setAttribute('class', 'clockpicker-canvas-fg');
339
+ fg.setAttribute('r', 3.5);
340
+ g.appendChild(hand);
341
+ g.appendChild(bg);
342
+ g.appendChild(fg);
343
+ g.appendChild(bearing);
344
+ svg.appendChild(g);
345
+ canvas.append(svg);
346
+
347
+ this.hand = hand;
348
+ this.bg = bg;
349
+ this.fg = fg;
350
+ this.bearing = bearing;
351
+ this.g = g;
352
+ this.canvas = canvas;
353
+ }
354
+
355
+ raiseCallback(this.options.init);
356
+ }
357
+
358
+ function raiseCallback(callbackFunction) {
359
+ if (callbackFunction && typeof callbackFunction === "function") {
360
+ callbackFunction();
361
+ }
362
+ }
363
+
364
+ // Default options
365
+ ClockPicker.DEFAULTS = {
366
+ 'default': '', // default time, 'now' or '13:14' e.g.
367
+ fromnow: 0, // set default time to * milliseconds from now (using with default = 'now')
368
+ placement: 'bottom', // clock popover placement
369
+ align: 'left', // popover arrow align
370
+ donetext: 'Done', // done button text
371
+ autoclose: false, // auto close when minute is selected
372
+ twelvehour: false, // change to 12 hour AM/PM clock from 24 hour
373
+ vibrate: true // vibrate the device when dragging clock hand
374
+ };
375
+
376
+ // Show or hide popover
377
+ ClockPicker.prototype.toggle = function(){
378
+ this[this.isShown ? 'hide' : 'show']();
379
+ };
380
+
381
+ // Set popover position
382
+ ClockPicker.prototype.locate = function(){
383
+ var element = this.element,
384
+ popover = this.popover,
385
+ offset = element.offset(),
386
+ width = element.outerWidth(),
387
+ height = element.outerHeight(),
388
+ placement = this.options.placement,
389
+ align = this.options.align,
390
+ styles = {},
391
+ self = this;
392
+
393
+ popover.show();
394
+
395
+ // Place the popover
396
+ switch (placement) {
397
+ case 'bottom':
398
+ styles.top = offset.top + height;
399
+ break;
400
+ case 'right':
401
+ styles.left = offset.left + width;
402
+ break;
403
+ case 'top':
404
+ styles.top = offset.top - popover.outerHeight();
405
+ break;
406
+ case 'left':
407
+ styles.left = offset.left - popover.outerWidth();
408
+ break;
409
+ }
410
+
411
+ // Align the popover arrow
412
+ switch (align) {
413
+ case 'left':
414
+ styles.left = offset.left;
415
+ break;
416
+ case 'right':
417
+ styles.left = offset.left + width - popover.outerWidth();
418
+ break;
419
+ case 'top':
420
+ styles.top = offset.top;
421
+ break;
422
+ case 'bottom':
423
+ styles.top = offset.top + height - popover.outerHeight();
424
+ break;
425
+ }
426
+
427
+ popover.css(styles);
428
+ };
429
+
430
+ // Show popover
431
+ ClockPicker.prototype.show = function(e){
432
+ // Not show again
433
+ if (this.isShown) {
434
+ return;
435
+ }
436
+
437
+ raiseCallback(this.options.beforeShow);
438
+
439
+ var self = this;
440
+
441
+ // Initialize
442
+ if (! this.isAppended) {
443
+ // Append popover to body
444
+ $body = $(document.body).append(this.popover);
445
+
446
+ // Reset position when resize
447
+ $win.on('resize.clockpicker' + this.id, function(){
448
+ if (self.isShown) {
449
+ self.locate();
450
+ }
451
+ });
452
+
453
+ this.isAppended = true;
454
+ }
455
+
456
+ // Get the time sets [hour, min]
457
+ var inputValue = ((this.input.prop('value') || this.options['default'] || '') + '');
458
+ var value = inputValue.split(":");
459
+ value[1] = parseInt(value[1]); // 2017-03-14 / dan.legrand@gmail.com: was setting "MM PM" and blanking out
460
+ console.log(inputValue);
461
+ value[2] = inputValue.match(/am/i) ? "AM" : "PM";
462
+ if (value[0] === 'now') {
463
+ var now = new Date(+ new Date() + this.options.fromnow);
464
+ value = [
465
+ now.getHours(),
466
+ now.getMinutes()
467
+ ];
468
+ }
469
+ this.hours = + value[0] || 0;
470
+ this.minutes = + value[1] || 0;
471
+ this.spanHours.html(leadingZero(this.hours));
472
+ this.spanMinutes.html(leadingZero(this.minutes));
473
+ this.amOrPm = value[2];
474
+
475
+ // $('.clockpicker-span-am-pm').empty().append(value[2]);
476
+ this.spanAmPm.text(value[2]);
477
+
478
+ // Toggle to hours view
479
+ this.toggleView('hours');
480
+
481
+ // Set position
482
+ this.locate();
483
+
484
+ this.isShown = true;
485
+
486
+ // Hide when clicking or tabbing on any element except the clock, input and addon
487
+ $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function(e){
488
+ var target = $(e.target);
489
+ if (target.closest(self.popover).length === 0 &&
490
+ target.closest(self.addon).length === 0 &&
491
+ target.closest(self.input).length === 0) {
492
+ self.hide();
493
+ }
494
+ });
495
+
496
+ // Hide when ESC is pressed
497
+ $doc.on('keyup.clockpicker.' + this.id, function(e){
498
+ if (e.keyCode === 27) {
499
+ self.hide();
500
+ }
501
+ });
502
+
503
+ raiseCallback(this.options.afterShow);
504
+ };
505
+
506
+ // Hide popover
507
+ ClockPicker.prototype.hide = function(){
508
+ raiseCallback(this.options.beforeHide);
509
+
510
+ this.isShown = false;
511
+
512
+ // Unbinding events on document
513
+ $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id);
514
+ $doc.off('keyup.clockpicker.' + this.id);
515
+
516
+ this.popover.hide();
517
+
518
+ raiseCallback(this.options.afterHide);
519
+ };
520
+
521
+ // Toggle to hours or minutes view
522
+ ClockPicker.prototype.toggleView = function(view, delay){
523
+ var raiseAfterHourSelect = false;
524
+ if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") {
525
+ raiseCallback(this.options.beforeHourSelect);
526
+ raiseAfterHourSelect = true;
527
+ }
528
+ var isHours = view === 'hours',
529
+ nextView = isHours ? this.hoursView : this.minutesView,
530
+ hideView = isHours ? this.minutesView : this.hoursView;
531
+
532
+ this.currentView = view;
533
+
534
+ this.spanHours.toggleClass('text-primary', isHours);
535
+ this.spanMinutes.toggleClass('text-primary', ! isHours);
536
+
537
+ // Let's make transitions
538
+ hideView.addClass('clockpicker-dial-out');
539
+ nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out');
540
+
541
+ // Reset clock hand
542
+ this.resetClock(delay);
543
+
544
+ // After transitions ended
545
+ clearTimeout(this.toggleViewTimer);
546
+ this.toggleViewTimer = setTimeout(function(){
547
+ hideView.css('visibility', 'hidden');
548
+ }, duration);
549
+
550
+ if (raiseAfterHourSelect) {
551
+ raiseCallback(this.options.afterHourSelect);
552
+ }
553
+ };
554
+
555
+ // Reset clock hand
556
+ ClockPicker.prototype.resetClock = function(delay){
557
+ var view = this.currentView,
558
+ value = this[view],
559
+ isHours = view === 'hours',
560
+ unit = Math.PI / (isHours ? 6 : 30),
561
+ radian = value * unit,
562
+ radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
563
+ x = Math.sin(radian) * radius,
564
+ y = - Math.cos(radian) * radius,
565
+ self = this;
566
+ if (svgSupported && delay) {
567
+ self.canvas.addClass('clockpicker-canvas-out');
568
+ setTimeout(function(){
569
+ self.canvas.removeClass('clockpicker-canvas-out');
570
+ self.setHand(x, y);
571
+ }, delay);
572
+ } else {
573
+ this.setHand(x, y);
574
+ }
575
+ };
576
+
577
+ // Set clock hand to (x, y)
578
+ ClockPicker.prototype.setHand = function(x, y, roundBy5, dragging){
579
+ var radian = Math.atan2(x, - y),
580
+ isHours = this.currentView === 'hours',
581
+ unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
582
+ z = Math.sqrt(x * x + y * y),
583
+ options = this.options,
584
+ inner = isHours && z < (outerRadius + innerRadius) / 2,
585
+ radius = inner ? innerRadius : outerRadius,
586
+ value;
587
+
588
+ if (options.twelvehour) {
589
+ radius = outerRadius;
590
+ }
591
+
592
+ // Radian should in range [0, 2PI]
593
+ if (radian < 0) {
594
+ radian = Math.PI * 2 + radian;
595
+ }
596
+
597
+ // Get the round value
598
+ value = Math.round(radian / unit);
599
+
600
+ // Get the round radian
601
+ radian = value * unit;
602
+
603
+ // Correct the hours or minutes
604
+ if (options.twelvehour) {
605
+ if (isHours) {
606
+ if (value === 0) {
607
+ value = 12;
608
+ }
609
+ } else {
610
+ if (roundBy5) {
611
+ value *= 5;
612
+ }
613
+ if (value === 60) {
614
+ value = 0;
615
+ }
616
+ }
617
+ } else {
618
+ if (isHours) {
619
+ if (value === 12) {
620
+ value = 0;
621
+ }
622
+ value = inner ? (value === 0 ? 12 : value) : value === 0 ? 0 : value + 12;
623
+ } else {
624
+ if (roundBy5) {
625
+ value *= 5;
626
+ }
627
+ if (value === 60) {
628
+ value = 0;
629
+ }
630
+ }
631
+ }
632
+
633
+ // Once hours or minutes changed, vibrate the device
634
+ if (this[this.currentView] !== value) {
635
+ if (vibrate && this.options.vibrate) {
636
+ // Do not vibrate too frequently
637
+ if (! this.vibrateTimer) {
638
+ navigator[vibrate](10);
639
+ this.vibrateTimer = setTimeout($.proxy(function(){
640
+ this.vibrateTimer = null;
641
+ }, this), 100);
642
+ }
643
+ }
644
+ }
645
+
646
+ this[this.currentView] = value;
647
+ this[isHours ? 'spanHours' : 'spanMinutes'].html(leadingZero(value));
648
+
649
+ // If svg is not supported, just add an active class to the tick
650
+ if (! svgSupported) {
651
+ this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function(){
652
+ var tick = $(this);
653
+ tick.toggleClass('active', value === + tick.html());
654
+ });
655
+ return;
656
+ }
657
+
658
+ // Place clock hand at the top when dragging
659
+ if (dragging || (! isHours && value % 5)) {
660
+ this.g.insertBefore(this.hand, this.bearing);
661
+ this.g.insertBefore(this.bg, this.fg);
662
+ this.bg.setAttribute('class', 'clockpicker-canvas-bg clockpicker-canvas-bg-trans');
663
+ } else {
664
+ // Or place it at the bottom
665
+ this.g.insertBefore(this.hand, this.bg);
666
+ this.g.insertBefore(this.fg, this.bg);
667
+ this.bg.setAttribute('class', 'clockpicker-canvas-bg');
668
+ }
669
+
670
+ // Set clock hand and others' position
671
+ var cx = Math.sin(radian) * radius,
672
+ cy = - Math.cos(radian) * radius;
673
+ this.hand.setAttribute('x2', cx);
674
+ this.hand.setAttribute('y2', cy);
675
+ this.bg.setAttribute('cx', cx);
676
+ this.bg.setAttribute('cy', cy);
677
+ this.fg.setAttribute('cx', cx);
678
+ this.fg.setAttribute('cy', cy);
679
+ };
680
+
681
+ // Hours and minutes are selected
682
+ ClockPicker.prototype.done = function() {
683
+ raiseCallback(this.options.beforeDone);
684
+ this.hide();
685
+ var last = this.input.prop('value'),
686
+ value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);
687
+ if (this.options.twelvehour) {
688
+ value = value + " " + this.amOrPm;
689
+ }
690
+
691
+ this.input.prop('value', value);
692
+ if (value !== last) {
693
+ this.input.triggerHandler('change');
694
+ if (! this.isInput) {
695
+ this.element.trigger('change');
696
+ }
697
+ }
698
+
699
+ if (this.options.autoclose) {
700
+ this.input.trigger('blur');
701
+ }
702
+
703
+ raiseCallback(this.options.afterDone);
704
+ };
705
+
706
+ // Remove clockpicker from input
707
+ ClockPicker.prototype.remove = function() {
708
+ this.element.removeData('clockpicker');
709
+ this.input.off('focus.clockpicker click.clockpicker');
710
+ this.addon.off('click.clockpicker');
711
+ if (this.isShown) {
712
+ this.hide();
713
+ }
714
+ if (this.isAppended) {
715
+ $win.off('resize.clockpicker' + this.id);
716
+ this.popover.remove();
717
+ }
718
+ };
719
+
720
+ // Extends $.fn.clockpicker
721
+ $.fn.clockpicker = function(option){
722
+ var args = Array.prototype.slice.call(arguments, 1);
723
+ return this.each(function(){
724
+ var $this = $(this),
725
+ data = $this.data('clockpicker');
726
+ if (! data) {
727
+ var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option);
728
+ $this.data('clockpicker', new ClockPicker($this, options));
729
+ } else {
730
+ // Manual operatsions. show, hide, remove, e.g.
731
+ if (typeof data[option] === 'function') {
732
+ data[option].apply(data, args);
733
+ }
734
+ }
735
+ });
736
+ };
737
+ }());