index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
  8. <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
  9. <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
  10. <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
  11. <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
  12. <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
  13. <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
  14. <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
  15. <link rel="icon" type="image/png" href="/favicon-196x196.png" sizes="196x196">
  16. <link rel="icon" type="image/png" href="/favicon-160x160.png" sizes="160x160">
  17. <link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
  18. <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
  19. <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
  20. <meta name="msapplication-TileColor" content="#2b5797">
  21. <meta name="msapplication-TileImage" content="/mstile-144x144.png">
  22. <title></title>
  23. <link rel="stylesheet" type="text/css" media="screen"
  24. href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
  25. <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  26. <link href="../css/prettify-1.0.css" rel="stylesheet">
  27. <link href="../css/base.css" rel="stylesheet">
  28. <link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
  29. <script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  30. <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
  31. <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
  32. <script src="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
  33. </head>
  34. <body>
  35. <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  36. <div class="container">
  37. <!-- Collapsed navigation -->
  38. <div class="navbar-header">
  39. <!-- Expander button -->
  40. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
  41. <span class="sr-only">Toggle navigation</span>
  42. <span class="icon-bar"></span>
  43. <span class="icon-bar"></span>
  44. <span class="icon-bar"></span>
  45. </button>
  46. <!-- Main title -->
  47. <a class="navbar-brand" href=""></a>
  48. </div>
  49. <!-- Expanded navigation -->
  50. <div class="navbar-collapse collapse">
  51. <!-- Main navigation -->
  52. <ul class="nav navbar-nav">
  53. <li >
  54. <a href="..">Usage</a>
  55. </li>
  56. <li >
  57. <a href="../Installing/">Installing</a>
  58. </li>
  59. <li >
  60. <a href="../Functions/">Functions</a>
  61. </li>
  62. <li >
  63. <a href="../Options/">Options</a>
  64. </li>
  65. <li >
  66. <a href="../Events/">Events</a>
  67. </li>
  68. <li >
  69. <a href="../Changelog.md">Change Log</a>
  70. </li>
  71. <li class="active">
  72. <a href="./">Dev Guide</a>
  73. </li>
  74. <li >
  75. <a href="../Extras/">Extras</a>
  76. </li>
  77. <li >
  78. <a href="../FAQ/">FAQs</a>
  79. </li>
  80. </ul>
  81. <!-- Search, Navigation and Repo links -->
  82. <ul class="nav navbar-nav navbar-right">
  83. </ul>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="container">
  88. <div class="row">
  89. <div class="col-md-3"><script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CK7DC5QN&placement=eonasdangithubio" id="_carbonads_js"></script>
  90. <div class="bs-sidebar hidden-print affix well" role="complementary"> <ul class="nav bs-sidenav">
  91. <li class="main active"><a href="#introduction">Introduction</a></li>
  92. <li class="main "><a href="#code">Code</a></li>
  93. <li><a href="#private-variables">Private variables</a></li>
  94. <li><a href="#private-functions">Private functions</a></li>
  95. </ul>
  96. </div></div>
  97. <div class="col-md-8" role="main">
  98. <div class="alert alert-danger" style="font-size:1.5em;">
  99. <strong>Important!</strong>
  100. Please read this <a href="https://eonasdan.com/posts/state-of-my-picker" target="_blank">blog post</a>
  101. </div>
  102. <p>This guide is aimed to contributors wishing to understand the internals of the code in order to change/evolve the component. </p>
  103. <p><strong>Note:</strong> this guide refers to <strong>version 4</strong> which is currently in beta and will be updated as we progress</p>
  104. <h2 id="introduction">Introduction</h2>
  105. <p>This component consists actually of 2 subcomponent UI widgets one for the date and one for the time selection process. The developers can configure which of those are needed and also the granularity that the component will allow the users to select a date/time. Developers also choose the format that the selected datetime will be displayed in the input field.
  106. The component uses on <code>jQuery</code>, <code>moment.js</code> and <code>bootstrap</code> libraries.</p>
  107. <h2 id="code">Code</h2>
  108. <h3 id="private-variables">Private variables</h3>
  109. <ul>
  110. <li>
  111. <p><code>element</code> - Holds the DOM element this instance is attached to</p>
  112. </li>
  113. <li>
  114. <p><code>options</code> - Holds an object with the curently set options for the specific instance of the component. Don't directly change the properties of that object use the public API methods instead. DO NOT expose this object or its properties outside of the component.</p>
  115. </li>
  116. <li>
  117. <p><code>picker</code> - Reference variable to the created instance <code>(this)</code></p>
  118. </li>
  119. <li>
  120. <p><code>date</code> - Holds the moment object for the model value of the component. <strong>DON'T</strong> directly change this variable unless you <strong>REALLY</strong> know what you are doing. Use <code>setValue()</code> function to set it. It handles all component logic for updating the model value and emitting all the appropriate events</p>
  121. </li>
  122. <li>
  123. <p><code>viewDate</code> - Holds the currently selected value that the user has selected through the widget. This is not the model value this is the view value. Changing this usually requires a subsequent call to <code>update()</code> function</p>
  124. </li>
  125. <li>
  126. <p><code>unset</code> - A <code>boolean</code> variable that holds wheather the components model value is set or not. Model's value starts as <code>unset = true</code> and if is either set by the user or programmatically through the api to a valid value then it is set to <code>false</code>. If subsequent events lead to an invalid value then this variable is set to <code>true</code> again. Setting this variable usually takes place in the <code>setValue()</code> function.</p>
  127. </li>
  128. <li>
  129. <p><code>input</code> - Hold the DOM input element this instance is attached to</p>
  130. </li>
  131. <li>
  132. <p><code>component</code> - Holds a reference to the .input-group DOM element that the widget is attached or false if it is attached directly on an input field</p>
  133. </li>
  134. <li>
  135. <p><code>widget</code> - Holds a reference to the DOM element containing the widget or <code>false</code> if the widget is hidden</p>
  136. </li>
  137. <li>
  138. <p><code>use24hours</code> - Holds whether the component uses 24 hours format or not. This is initialized on the <code>format()</code> function</p>
  139. </li>
  140. <li>
  141. <p><code>minViewModeNumber</code> - Holds the Numeric equivelant of the options.minViewMode parameter</p>
  142. </li>
  143. <li>
  144. <p><code>format</code> - Holds the current format string that is used for formating the date model value. Note this is not the same thing as the <code>options.format</code> as the second could be set to <code>false</code> in which case the first takes the locale's <code>L</code> or <code>LT</code> value</p>
  145. </li>
  146. <li>
  147. <p><code>currentViewMode</code> - Hold the state of the current viewMode for the DatePicker subcomponent</p>
  148. </li>
  149. <li>
  150. <p><code>actions</code> - An object containing all the functions that can be called when the users clicks on the widget</p>
  151. </li>
  152. <li>
  153. <p><code>datePickerModes</code> - An array of objects with configuration parameters for the different views of the DatePicker subcomponent</p>
  154. </li>
  155. <li>
  156. <p><code>viewModes</code> - An array of strings containing all the possible strings that <code>options.viewMode</code> can take through <code>viewMode()</code> public api function</p>
  157. </li>
  158. <li>
  159. <p><code>directionModes</code> - An array of strings containing all the possible strings that <code>options.direction</code> can take through <code>direction()</code> public api function</p>
  160. </li>
  161. <li>
  162. <p><code>orientationModes</code> - An array of strings containing all the possible strings that <code>options.orientation</code> can take through <code>orientation()</code> public api function</p>
  163. </li>
  164. </ul>
  165. <h3 id="private-functions">Private functions</h3>
  166. <h4 id="widget-related">Widget related</h4>
  167. <ul>
  168. <li>
  169. <p><code>getDatePickerTemplate()</code> - returns a string containing the html code for the date picker subcomponent</p>
  170. </li>
  171. <li>
  172. <p><code>getTimePickerTemplate()</code> - returns a string containing the html code for the time picker subcomponent</p>
  173. </li>
  174. <li>
  175. <p><code>getTemplate()</code> - returns a string with containing the html code for all the DateTimePicker component</p>
  176. </li>
  177. <li>
  178. <p><code>place()</code> - handles the placement of the widget's dropdown</p>
  179. </li>
  180. <li>
  181. <p><code>updateMonths()</code> - updates the html subpage related to the months for Date picker view</p>
  182. </li>
  183. <li>
  184. <p><code>updateYears()</code> - updates the html subpage related to the years for Date picker view</p>
  185. </li>
  186. <li>
  187. <p><code>fillDate()</code> - updates the html subpage related to the days for Date picker view</p>
  188. </li>
  189. <li>
  190. <p><code>fillHours()</code> - Creates the hours spans for the hours subview of the Time subcomponent</p>
  191. </li>
  192. <li>
  193. <p><code>fillMinutes()</code> - Creates the minutes spans for the hours subview of the Time subcomponent</p>
  194. </li>
  195. <li>
  196. <p><code>fillSeconds()</code> - Creates the seconds spans for the hours subview of the Time subcomponent</p>
  197. </li>
  198. <li>
  199. <p><code>fillTime()</code> - Creates the main subview of the Time subcomponent</p>
  200. </li>
  201. <li>
  202. <p><code>update()</code> - updates the UI of part of the widget</p>
  203. </li>
  204. <li>
  205. <p><code>fillDow()</code> - Creates the day names in the days subview on the Date subcomponent</p>
  206. </li>
  207. <li>
  208. <p><code>fillMonths()</code> - Creates the month spans for the months subview of the Date subcomponent</p>
  209. </li>
  210. <li>
  211. <p><code>createWidget()</code> - creates the UI widget end attaches widget event listeners</p>
  212. </li>
  213. <li>
  214. <p><code>destroyWidget()</code> - destroys the UI widget DOM element and detaches widget event listeners</p>
  215. </li>
  216. <li>
  217. <p><code>showMode(dir)</code> - toggles between the various subpage related views of the DateTimePicker</p>
  218. </li>
  219. </ul>
  220. <h4 id="events-related">Events related</h4>
  221. <ul>
  222. <li>
  223. <p><code>notifyEvent(e)</code> - Use this function when you want to send en event to listener this could be used as a filter later</p>
  224. </li>
  225. <li>
  226. <p><code>stopEvent(e)</code> - Shortcut for stopping propagation of events</p>
  227. </li>
  228. <li>
  229. <p><code>doAction(e)</code> - Proxy function to call all the UI related click events</p>
  230. </li>
  231. <li>
  232. <p><code>keydown(e)</code> - Function to trap </p>
  233. </li>
  234. <li>
  235. <p><code>change(e)</code> - Listener function to track change events occuring on the <code>input</code> dom element the component is attached to</p>
  236. </li>
  237. <li>
  238. <p><code>attachDatePickerElementEvents()</code> - Attaches listeners to the existing DOM elements the component is attached to. Called upon construction of each datetimepicker instance</p>
  239. </li>
  240. <li>
  241. <p><code>detachDatePickerElementEvents()</code> - Detaches listeners from the DOM element the component is attached to. Called on <code>destroy()</code></p>
  242. </li>
  243. <li>
  244. <p><code>attachDatePickerWidgetEvents()</code> - Attaches listeners on the components widget. Called on <code>show()</code></p>
  245. </li>
  246. <li>
  247. <p><code>detachDatePickerWidgetEvents()</code> - Detaches listeners on the components widget. Called on <code>hide()</code></p>
  248. </li>
  249. </ul>
  250. <h4 id="model-related">Model related</h4>
  251. <ul>
  252. <li>
  253. <p><code>setValue(targetMoment)</code> - Sets the model value of the component takes a moment object. An <code>error</code> event will be emmited if the <code>targetMoment</code> does not pass the configured validations. Otherwise the <code>date</code> variable will be set and the relevant events will be fired.</p>
  254. </li>
  255. <li>
  256. <p><code>isValid(targetMoment, granularity)</code> - returns <code>true</code> if the <code>targetMoment</code> moment object is valid according to the components set validation rules (<code>min/maxDates</code>, <code>disabled/enabledDates</code> and <code>daysOfWeekDisabled</code>). You may pass a second variable to check only up the the specific granularity <code>year, month, day, hour, minute, second</code></p>
  257. </li>
  258. </ul>
  259. <h4 id="utilities">Utilities</h4>
  260. <ul>
  261. <li>
  262. <p><code>indexGivenDates (givenDatesArray)</code> - Function that takes the array from <code>enabledDates()</code> and <code>disabledDates()</code> public functions and stores them as object keys to enable quick lookup</p>
  263. </li>
  264. <li>
  265. <p><code>isInEnableDates(date)</code> - Checks whether if the given moment object exists in the <code>options.enabledDates</code> object</p>
  266. </li>
  267. <li>
  268. <p><code>isInDisableDates(date)</code> - Checks whether if the given moment object exists in the <code>options.disabledDates</code> array</p>
  269. </li>
  270. <li>
  271. <p><code>dataToOptions()</code> - Parses <code>data-date-*</code> options set on the input dom element the component is attached to and returns an object with them</p>
  272. </li>
  273. <li>
  274. <p><code>isInFixed()</code> - Checks if the dom element or its parents has a fixed position css rule.</p>
  275. </li>
  276. <li>
  277. <p><code>parseInputDate(date)</code> - Parses a date parameter with moment using the component's <code>options.format</code> and <code>options.useStrict</code>. It returns a <code>moment</code> object or false if <code>parsedMoment#isValid()</code> returns <code>false</code>. Use this to parse date inputs from outside the component (public API calls).</p>
  278. </li>
  279. <li>
  280. <p><code>init()</code> - Initializes the component. Called when the component instance is created</p>
  281. </li>
  282. </ul>
  283. </div>
  284. </div>
  285. </div>
  286. <script src="../js/prettify-1.0.min.js"></script>
  287. <script src="../js/base.js"></script>
  288. <script>
  289. if (top != self) {
  290. top.location.replace(self.location.href);
  291. }
  292. (function (i, s, o, g, r, a, m) {
  293. i['GoogleAnalyticsObject'] = r;
  294. i[r] = i[r] || function () {
  295. (i[r].q = i[r].q || []).push(arguments)
  296. }, i[r].l = 1 * new Date();
  297. a = s.createElement(o),
  298. m = s.getElementsByTagName(o)[0];
  299. a.async = 1;
  300. a.src = g;
  301. m.parentNode.insertBefore(a, m)
  302. })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
  303. ga('create', 'UA-47462200-1', 'eonasdan.github.io');
  304. ga('send', 'pageview');
  305. </script>
  306. </body>
  307. </html>