Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.71 KB | None | 0 0
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4.  
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7.  
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId])
  10. /******/ return installedModules[moduleId].exports;
  11.  
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ exports: {},
  15. /******/ id: moduleId,
  16. /******/ loaded: false
  17. /******/ };
  18.  
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21.  
  22. /******/ // Flag the module as loaded
  23. /******/ module.loaded = true;
  24.  
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28.  
  29.  
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32.  
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35.  
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38.  
  39. /******/ // Load entry module and return exports
  40. /******/ return __webpack_require__(0);
  41. /******/ })
  42. /************************************************************************/
  43. /******/ ([
  44. /* 0 */
  45. /***/ function(module, exports, __webpack_require__) {
  46.  
  47. __webpack_require__(1);
  48. module.exports = __webpack_require__(8);
  49.  
  50.  
  51. /***/ },
  52. /* 1 */
  53. /***/ function(module, exports, __webpack_require__) {
  54.  
  55. /* global moment:false */
  56.  
  57. 'use strict';
  58.  
  59. var _providersDateRangePickerProviderJs = __webpack_require__(2);
  60.  
  61. var _providersDatePickerProviderJs = __webpack_require__(3);
  62.  
  63. var _directivesDateRangePickerDateRangePickerDirective = __webpack_require__(4);
  64.  
  65. var _directivesCalendarCalendarDirective = __webpack_require__(5);
  66.  
  67. var _directivesObDateRangePickerObDateRangePickerDirectiveJs = __webpack_require__(6);
  68.  
  69. var _directivesObDayPickerObDayPickerDirective = __webpack_require__(7);
  70.  
  71. angular.module('obDateRangePicker', []).constant('moment', moment).provider('dateRangePickerConf', _providersDateRangePickerProviderJs.DateRangePickerProvider).provider('datePickerConf', _providersDatePickerProviderJs.DatePickerProvider).directive('dateRangePicker', _directivesDateRangePickerDateRangePickerDirective.DateRangePicker).directive('obDaterangepicker', _directivesObDateRangePickerObDateRangePickerDirectiveJs.ObDateRangePicker).directive('calendar', _directivesCalendarCalendarDirective.Calendar).directive('obDaypicker', _directivesObDayPickerObDayPickerDirective.ObDayPicker);
  72.  
  73. /***/ },
  74. /* 2 */
  75. /***/ function(module, exports) {
  76.  
  77. "use strict";
  78.  
  79. Object.defineProperty(exports, "__esModule", {
  80. value: true
  81. });
  82. exports.DateRangePickerProvider = DateRangePickerProvider;
  83.  
  84. function DateRangePickerProvider() {
  85. var config = {};
  86.  
  87. return {
  88. setConfig: function setConfig(userConfig) {
  89. config = userConfig;
  90. },
  91. $get: function $get() {
  92. return config;
  93. }
  94. };
  95. }
  96.  
  97. /***/ },
  98. /* 3 */
  99. /***/ function(module, exports) {
  100.  
  101. "use strict";
  102.  
  103. Object.defineProperty(exports, "__esModule", {
  104. value: true
  105. });
  106. exports.DatePickerProvider = DatePickerProvider;
  107.  
  108. function DatePickerProvider() {
  109. var config = {};
  110.  
  111. return {
  112. setConfig: function setConfig(userConfig) {
  113. config = userConfig;
  114. },
  115. $get: function $get() {
  116. return config;
  117. }
  118. };
  119. }
  120.  
  121. /***/ },
  122. /* 4 */
  123. /***/ function(module, exports) {
  124.  
  125. 'use strict';
  126.  
  127. Object.defineProperty(exports, '__esModule', {
  128. value: true
  129. });
  130.  
  131. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  132.  
  133. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  134.  
  135. exports.DateRangePicker = DateRangePicker;
  136.  
  137. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  138.  
  139. function DateRangePicker() {
  140. 'ngInject';
  141.  
  142. var directive = {
  143. restrict: 'E',
  144. scope: {
  145. weekStart: '&',
  146. range: '=?',
  147. minDay: '&',
  148. maxDay: '&',
  149. api: '&',
  150. monthFormat: '&',
  151. inputFormat: '&',
  152. weekDaysName: '&',
  153. linkedCalendars: '&',
  154. interceptors: '&'
  155. },
  156. templateUrl: 'app/directives/date-range-picker/date-range-picker.html',
  157. controller: DateRangePickerController,
  158. controllerAs: 'picker',
  159. bindToController: true,
  160. link: function link(scope, elem, attrs, ctrl) {
  161. ctrl.init();
  162. }
  163. };
  164.  
  165. return directive;
  166. }
  167.  
  168. var DateRangePickerController = (function () {
  169. DateRangePickerController.$inject = ["moment", "$scope"];
  170. function DateRangePickerController(moment, $scope) {
  171. 'ngInject';
  172.  
  173. _classCallCheck(this, DateRangePickerController);
  174.  
  175. this.Moment = moment;
  176. this.Scope = $scope;
  177. this.endCalendarApi = {};
  178. this.startCalendarApi = {};
  179. this.setInterceptors();
  180. }
  181.  
  182. _createClass(DateRangePickerController, [{
  183. key: 'init',
  184. value: function init() {
  185. this.range = this.range || {};
  186. this.setConfigurations();
  187. this.setListeners();
  188. this.setApi();
  189. this.watchRangeChange();
  190. this.interceptors = this.interceptors() || {};
  191. }
  192. }, {
  193. key: 'setApi',
  194. value: function setApi() {
  195. var _this = this;
  196.  
  197. var api = this.api() || {};
  198. _extends(api, {
  199. setCalendarPosition: function setCalendarPosition(start, end) {
  200. _this.startCalendar = start;
  201. if (_this.linkedCalendars() || start.isSame(end, 'M')) {
  202. _this.endCalendar = _this.startCalendar.clone().add(1, 'M');
  203. } else {
  204. _this.endCalendar = end;
  205. }
  206. },
  207. render: function render() {
  208. _this.startCalendarApi.render();
  209. _this.endCalendarApi.render();
  210. }
  211. });
  212. }
  213. }, {
  214. key: 'setListeners',
  215. value: function setListeners() {
  216. var _this2 = this;
  217.  
  218. this.Scope.$watchGroup([function () {
  219. return _this2.range.start;
  220. }, function () {
  221. return _this2.range.end;
  222. }], function (newRange) {
  223. if (newRange[0] && newRange[1]) {
  224. _this2.setConfigurations();
  225. }
  226. });
  227. }
  228. }, {
  229. key: 'setConfigurations',
  230. value: function setConfigurations() {
  231. var start = undefined,
  232. end = undefined;
  233. if (this.isMomentRange(this.range)) {
  234. start = this.range.start;
  235. end = this.range.end;
  236. } else {
  237. start = this.Moment(this.range.start, this.getFormat());
  238. end = this.Moment(this.range.end, this.getFormat());
  239. }
  240.  
  241. end = end.diff(start) >= 0 ? end : start.clone();
  242. this.rangeStart = start;
  243. this.rangeEnd = end;
  244. this.daysSelected = 2;
  245. this.updateRange();
  246. }
  247. }, {
  248. key: 'updateRange',
  249. value: function updateRange() {
  250. if (this.isMomentRange(this.range)) {
  251. this.range.start = this.rangeStart;
  252. this.range.end = this.rangeEnd;
  253. } else {
  254. this.range.start = this.rangeStart ? this.rangeStart.format(this.getFormat()) : null;
  255. this.range.end = this.rangeEnd ? this.rangeEnd.format(this.getFormat()) : null;
  256. }
  257. }
  258. }, {
  259. key: 'setInterceptors',
  260. value: function setInterceptors() {
  261. var _this3 = this;
  262.  
  263. this.startCalendarInterceptors = {
  264. moveToPrevClicked: function moveToPrevClicked() {
  265. _this3.moveCalenders(-1, 'start');
  266. },
  267. moveToNextClicked: function moveToNextClicked() {
  268. _this3.moveCalenders(1, 'start');
  269. },
  270. daySelected: function daySelected(day) {
  271. _this3.dayInStartSelected(day);
  272. _this3.daySelected(day);
  273. if (_this3.daysSelected == 2) {
  274. _this3.interceptors.rangeSelectedByClick && _this3.interceptors.rangeSelectedByClick();
  275. }
  276. },
  277. inputSelected: function inputSelected(day) {
  278. _this3.inputInStartSelected(day);
  279. }
  280. };
  281.  
  282. this.endCalendarInterceptors = {
  283. moveToPrevClicked: function moveToPrevClicked() {
  284. _this3.moveCalenders(-1, 'end');
  285. },
  286. moveToNextClicked: function moveToNextClicked() {
  287. _this3.moveCalenders(1, 'end');
  288. },
  289. daySelected: function daySelected(day) {
  290. _this3.dayInEndSelected(day);
  291. _this3.daySelected(day);
  292. if (_this3.daysSelected == 2) {
  293. _this3.interceptors.rangeSelectedByClick && _this3.interceptors.rangeSelectedByClick();
  294. }
  295. },
  296. inputSelected: function inputSelected(day) {
  297. _this3.inputInEndSelected(day);
  298. }
  299. };
  300. }
  301. }, {
  302. key: 'inputInStartSelected',
  303. value: function inputInStartSelected(day) {
  304. switch (this.daysSelected) {
  305. case 0:
  306. case 1:
  307. this.rangeStart = day;
  308. this.daysSelected = 1;
  309. break;
  310. case 2:
  311. if (day.diff(this.rangeStart, 'days') < 0) {
  312. this.rangeStart = day;
  313. } else if (day.isBetween(this.rangeStart, this.rangeEnd)) {
  314. this.rangeStart = day;
  315. } else if (day.diff(this.rangeEnd, 'days') >= 0) {
  316. this.rangeStart = day;
  317. this.rangeEnd = day;
  318. }
  319. this.daysSelected = 2;
  320. this.updateRange();
  321. break;
  322. }
  323. }
  324. }, {
  325. key: 'inputInEndSelected',
  326. value: function inputInEndSelected(day) {
  327. switch (this.daysSelected) {
  328. case 0:
  329. this.rangeStart = day;
  330. this.daysSelected = 1;
  331. break;
  332. case 1:
  333. case 2:
  334. if (day.diff(this.rangeStart, 'days') <= 0) {
  335. this.rangeStart = day;
  336. this.rangeEnd = day;
  337. } else if (day.isSame(this.startCalendar, 'months') || day.isSame(this.endCalendar, 'months')) {
  338. this.rangeEnd = day;
  339. } else if (!day.isSame(this.endCalendar, 'months')) {
  340. this.rangeEnd = day;
  341. }
  342.  
  343. this.daysSelected = 2;
  344. this.updateRange();
  345. break;
  346. }
  347. }
  348. }, {
  349. key: 'dayInStartSelected',
  350. value: function dayInStartSelected(day) {
  351. var nextMonth = this.startCalendar.clone().add(1, 'M');
  352.  
  353. if (day.isSame(nextMonth, 'month')) {
  354. this.dayInEndSelected(day);
  355. }
  356. }
  357. }, {
  358. key: 'dayInEndSelected',
  359. value: function dayInEndSelected(day) {
  360. var prevMonth = this.endCalendar.clone().subtract(1, 'M');
  361.  
  362. if (day.isSame(prevMonth, 'month')) {
  363. this.dayInStartSelected(day);
  364. }
  365. }
  366. }, {
  367. key: 'daySelected',
  368. value: function daySelected(day) {
  369. switch (this.daysSelected) {
  370. case 0:
  371. this.rangeStart = day;
  372. this.daysSelected = 1;
  373. break;
  374. case 1:
  375. if (day.diff(this.rangeStart, 'days') < 0) {
  376. this.rangeStart = day;
  377. } else {
  378. this.rangeEnd = day;
  379. this.daysSelected = 2;
  380. this.updateRange();
  381. }
  382. break;
  383. case 2:
  384. this.daysSelected = 1;
  385. this.rangeStart = day;
  386. this.rangeEnd = null;
  387. break;
  388. }
  389. }
  390. }, {
  391. key: 'moveCalenders',
  392. value: function moveCalenders(month, calendar) {
  393. if (this.areCalendarsLinked()) {
  394. this.startCalendar = this.startCalendar.clone().add(month, 'M');
  395. this.endCalendar = this.endCalendar.clone().add(month, 'M');
  396. } else {
  397. if (calendar === 'start') {
  398. this.startCalendar = this.startCalendar.clone().add(month, 'M');
  399. } else {
  400. this.endCalendar = this.endCalendar.clone().add(month, 'M');
  401. }
  402. }
  403. }
  404. }, {
  405. key: 'isMomentRange',
  406. value: function isMomentRange(range) {
  407. var isRange = false;
  408. if (range && range.start && range.end) {
  409. isRange = this.Moment.isMoment(this.range.start) && this.Moment.isMoment(this.range.end);
  410. }
  411.  
  412. return isRange;
  413. }
  414. }, {
  415. key: 'watchRangeChange',
  416. value: function watchRangeChange() {
  417. var _this4 = this;
  418.  
  419. this.Scope.$watchGroup([function () {
  420. return _this4.rangeStart;
  421. }, function () {
  422. return _this4.rangeEnd;
  423. }], function (newRange, oldRange) {
  424. var newStart = newRange[0];
  425. var newEnd = newRange[1];
  426. var oldStart = oldRange[0];
  427. var oldEnd = oldRange[1];
  428.  
  429. if (_this4.maxDay() && newStart.isSame(_this4.maxDay(), 'M')) {
  430. newStart = newStart.clone().subtract(1, 'M');
  431. }
  432.  
  433. if (!_this4.startCalendar && !_this4.endCalendar) {
  434. _this4.startCalendar = newStart;
  435. _this4.endCalendar = newStart.clone().add(1, 'M');
  436. }
  437.  
  438. if (_this4.areCalendarsLinked()) {
  439. if (!(newStart.isSame(_this4.startCalendar, 'M') || newStart.isSame(_this4.endCalendar, 'M'))) {
  440. if (newStart.isSame(oldStart, 'M') && newEnd && !newEnd.isSame(oldEnd, 'M')) {
  441. _this4.startCalendar = newEnd.clone().subtract(1, 'M');
  442. _this4.endCalendar = newEnd;
  443. } else {
  444. _this4.startCalendar = newStart;
  445. _this4.endCalendar = newStart.clone().add(1, 'M');
  446. }
  447. } else if (newEnd && newEnd.isAfter(_this4.endCalendar, 'M')) {
  448. _this4.startCalendar = newEnd;
  449. _this4.endCalendar = newEnd.clone().add(1, 'M');
  450. } else if (!newStart.isSame(_this4.endCalendar, 'M')) {
  451. _this4.startCalendar = newStart;
  452. _this4.endCalendar = newStart.clone().add(1, 'M');
  453. }
  454. } else {
  455. if (!(newStart.isSame(_this4.startCalendar, 'M') || newStart.isSame(_this4.endCalendar, 'M'))) {
  456. if (newStart.isBefore(_this4.startCalendar, 'M')) {
  457. _this4.startCalendar = newStart;
  458.  
  459. if (newEnd && !newEnd.isSame(_this4.endCalendar, 'M')) {
  460. if (newStart.isSame(newEnd, 'M')) {
  461. _this4.endCalendar = newStart.clone().add(1, "M");
  462. } else {
  463. _this4.endCalendar = newEnd;
  464. }
  465. }
  466. } else if (newStart.isAfter(_this4.endCalendar)) {
  467. _this4.startCalendar = newStart;
  468. _this4.endCalendar = newStart.clone().add(1, 'M');
  469. }
  470. } else if (newEnd && newEnd.isAfter(_this4.endCalendar, 'M')) {
  471. _this4.endCalendar = newEnd;
  472. }
  473. }
  474. });
  475. }
  476. }, {
  477. key: 'areCalendarsLinked',
  478. value: function areCalendarsLinked() {
  479. return angular.isDefined(this.linkedCalendars()) ? this.linkedCalendars() : true;
  480. }
  481. }]);
  482.  
  483. return DateRangePickerController;
  484. })();
  485.  
  486. /***/ },
  487. /* 5 */
  488. /***/ function(module, exports) {
  489.  
  490. 'use strict';
  491.  
  492. Object.defineProperty(exports, '__esModule', {
  493. value: true
  494. });
  495.  
  496. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  497.  
  498. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  499.  
  500. exports.Calendar = Calendar;
  501.  
  502. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  503.  
  504. function Calendar() {
  505. 'ngInject';
  506.  
  507. var directive = {
  508. restrict: 'E',
  509. scope: {
  510. minDay: '&',
  511. maxDay: '&',
  512. weekStart: '&',
  513. getMonth: '&month',
  514. getInterceptors: '&interceptors',
  515. rangeStart: '&',
  516. rangeEnd: '&',
  517. selectedDay: '&',
  518. minMonth: '&',
  519. maxMonth: '&',
  520. weekDaysName: '&',
  521. monthFormat: '&',
  522. inputFormat: '&',
  523. showInput: '&',
  524. api: '=?'
  525. },
  526. templateUrl: 'app/directives/calendar/calendar.html',
  527. controller: CalendarController,
  528. controllerAs: 'month',
  529. bindToController: true,
  530. link: function link(scope, elem, attrs, ctrl) {
  531. ctrl.init();
  532. }
  533. };
  534.  
  535. return directive;
  536. }
  537.  
  538. var CalendarController = (function () {
  539. CalendarController.$inject = ["moment", "$scope", "$attrs"];
  540. function CalendarController(moment, $scope, $attrs) {
  541. 'ngInject';
  542.  
  543. _classCallCheck(this, CalendarController);
  544.  
  545. this.Moment = moment;
  546. this.Scope = $scope;
  547. this.Attrs = $attrs;
  548. }
  549.  
  550. _createClass(CalendarController, [{
  551. key: 'init',
  552. value: function init() {
  553. this.api && this.setApi();
  554. this.render();
  555. }
  556. }, {
  557. key: 'setApi',
  558. value: function setApi() {
  559. _extends(this.api, {
  560. render: this.render.bind(this),
  561. moveToNext: this.moveToNext.bind(this),
  562. showLeftArrow: this.showLeftArrow.bind(this)
  563. });
  564. }
  565. }, {
  566. key: 'render',
  567. value: function render() {
  568. this.defaultWeekDaysNames = this.weekDaysName() || ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
  569. this.firstDayOfWeek = this.weekStart() || 'su';
  570. this.daysOfWeek = this.buildWeek(this.firstDayOfWeek);
  571. this.calendar = this.buildCalendar(this.getMonth());
  572. this.interceptors = this.getInterceptors() || {};
  573. this.setListeners();
  574. this.daysName = this.setWeekDaysNames(this.daysOfWeek);
  575. }
  576. }, {
  577. key: 'setValue',
  578. value: function setValue() {
  579. if (this.selectedDay()) {
  580. this.value = this.selectedDay().format(this.getInputFormat());
  581. }
  582. }
  583. }, {
  584. key: 'setWeekDaysNames',
  585. value: function setWeekDaysNames(weekDays) {
  586. var daysName = arguments.length <= 1 || arguments[1] === undefined ? this.defaultWeekDaysNames : arguments[1];
  587.  
  588. var weekDayNames = [];
  589. var defPosMap = this.Moment.weekdaysMin().reduce(function (obj, day, index) {
  590. obj[day.toLowerCase()] = index;
  591. return obj;
  592. }, {});
  593.  
  594. weekDays.forEach(function (day, index) {
  595. var defPos = defPosMap[day];
  596. weekDayNames[index] = daysName[defPos];
  597. });
  598.  
  599. return weekDayNames;
  600. }
  601. }, {
  602. key: 'setListeners',
  603. value: function setListeners() {
  604. var _this = this;
  605.  
  606. this.Scope.$watch(function () {
  607. return _this.getMonth();
  608. }, function (newMonth) {
  609. _this.calendar = _this.buildCalendar(newMonth);
  610. });
  611.  
  612. this.Scope.$watchGroup([function () {
  613. return _this.rangeStart();
  614. }, function () {
  615. return _this.rangeEnd();
  616. }], function () {
  617. _this.setValue();
  618. _this.updateDaysProperties(_this.calendar.monthWeeks);
  619. });
  620. }
  621. }, {
  622. key: 'updateDaysProperties',
  623. value: function updateDaysProperties(monthWeeks) {
  624. var _this2 = this;
  625.  
  626. var minDay = this.minDay();
  627. var maxDay = this.maxDay();
  628. var selectedDay = this.selectedDay();
  629. var rangeStart = this.rangeStart();
  630. var rangeEnd = this.rangeEnd();
  631. monthWeeks.forEach(function (week) {
  632. week.forEach(function (day) {
  633. day.selected = day.mo.isSame(selectedDay || null, 'day');
  634. day.inRange = _this2.isInRange(day.mo);
  635. day.rangeStart = day.mo.isSame(rangeStart || null, 'day');
  636. day.rangeEnd = day.mo.isSame(rangeEnd || null, 'day');
  637. if (minDay) {
  638. day.disabled = day.mo.isBefore(minDay, 'day');
  639. }
  640. if (maxDay && !day.disabled) {
  641. day.disabled = day.mo.isAfter(maxDay, 'day');
  642. }
  643. });
  644. });
  645. }
  646. }, {
  647. key: 'buildWeek',
  648. value: function buildWeek(firstDay) {
  649. var daysOfWeek = this.Moment.weekdaysMin().map(function (day) {
  650. return day.toLowerCase();
  651. });
  652. var pivot = daysOfWeek.indexOf(firstDay.toLowerCase());
  653. var firstHalf = daysOfWeek.slice(0, pivot);
  654. var secondHalf = daysOfWeek.slice(pivot, daysOfWeek.length);
  655. var week = secondHalf.concat(firstHalf);
  656.  
  657. return week;
  658. }
  659. }, {
  660. key: 'buildCalendar',
  661. value: function buildCalendar() {
  662. var date = arguments.length <= 0 || arguments[0] === undefined ? this.Moment() : arguments[0];
  663.  
  664. var monthWeeks = [[], [], [], [], [], []];
  665. var monthRange = this.getMonthDateRange(date.year(), date.month() + 1);
  666. var firstDayOfMonth = monthRange.start;
  667.  
  668. var pivot = this.daysOfWeek.indexOf(firstDayOfMonth.format('dd').toLowerCase());
  669. var tmpDate = firstDayOfMonth.clone().subtract(pivot, 'd');
  670.  
  671. for (var i = 0; i < 6; i++) {
  672. for (var j = 0; j < 7; j++) {
  673. monthWeeks[i][j] = {
  674. mo: tmpDate,
  675. currentDay: tmpDate.isSame(this.Moment(), 'day'),
  676. currentMonth: tmpDate.isSame(date, 'month')
  677. };
  678. tmpDate = tmpDate.clone().add(1, 'd');
  679. }
  680. }
  681.  
  682. this.updateDaysProperties(monthWeeks);
  683.  
  684. return {
  685. currentCalendar: date,
  686. selectedDate: date,
  687. firstDayOfMonth: monthRange.start.format('D'),
  688. lastDayOfMonth: monthRange.end.format('D'),
  689. monthWeeks: monthWeeks
  690. };
  691. }
  692. }, {
  693. key: 'moveCalenderByMonth',
  694. value: function moveCalenderByMonth(months) {
  695. var mo = this.calendar.currentCalendar;
  696. this.month = mo.clone().add(months, 'M');
  697. this.calendar = this.buildCalendar(this.month.clone());
  698. }
  699. }, {
  700. key: 'moveToNext',
  701. value: function moveToNext() {
  702. if (this.interceptors.moveToNextClicked) {
  703. this.interceptors.moveToNextClicked.call(this.interceptors.context);
  704. } else {
  705. this.moveCalenderByMonth(1);
  706. }
  707. }
  708. }, {
  709. key: 'moveToPrev',
  710. value: function moveToPrev() {
  711. if (this.interceptors.moveToPrevClicked) {
  712. this.interceptors.moveToPrevClicked.call(this.interceptors.context);
  713. } else {
  714. this.moveCalenderByMonth(-1);
  715. }
  716. }
  717. }, {
  718. key: 'getMonthDateRange',
  719. value: function getMonthDateRange(year, month) {
  720. var startDate = this.Moment([year, month - 1]);
  721. var endDate = this.Moment(startDate).endOf('month');
  722. return { start: startDate, end: endDate };
  723. }
  724. }, {
  725. key: 'isInRange',
  726. value: function isInRange(day) {
  727. var inRange = false;
  728. var rangeStart = this.rangeStart() || null;
  729. var rangeEnd = this.rangeEnd() || null;
  730. inRange = day.isBetween(rangeStart, rangeEnd) || day.isSame(rangeStart, 'day') || inRange || day.isSame(rangeEnd, 'day');
  731.  
  732. return inRange;
  733. }
  734. }, {
  735. key: 'daySelected',
  736. value: function daySelected(day) {
  737. if (!day.disabled) {
  738. if (this.interceptors.daySelected) {
  739. this.interceptors.daySelected.call(this.interceptors.context, day.mo);
  740. }
  741. }
  742. }
  743. }, {
  744. key: 'dateInputEntered',
  745. value: function dateInputEntered(ev, value) {
  746. if (ev.keyCode == 13) {
  747. this.dateInputSelected(ev, value);
  748.  
  749. // should prevent form submit if placed inside a form
  750. ev.preventDefault();
  751. }
  752. }
  753. }, {
  754. key: 'dateInputSelected',
  755. value: function dateInputSelected(ev, value) {
  756. var day = this.Moment(value, this.getInputFormat(), true);
  757.  
  758. if (day.isValid()) {
  759. var minDay = this.minDay();
  760. var maxDay = this.maxDay();
  761. day = minDay && day.isBefore(minDay, 'day') ? minDay : day;
  762. day = maxDay && day.isAfter(maxDay, 'day') ? maxDay : day;
  763.  
  764. if (!this.selectedDay() || !this.selectedDay().isSame(day, 'day')) {
  765. if (this.interceptors.inputSelected) {
  766. this.interceptors.inputSelected(day);
  767. } else {
  768. this.daySelected({ mo: day });
  769. }
  770. }
  771. }
  772. }
  773. }, {
  774. key: 'getFormattedMonth',
  775. value: function getFormattedMonth(day) {
  776. return this.Moment(day).format(this.getMonthFormat());
  777. }
  778. }, {
  779. key: 'getMonthFormat',
  780. value: function getMonthFormat() {
  781. return this.monthFormat() || 'MMMM YYYY';
  782. }
  783. }, {
  784. key: 'getInputFormat',
  785. value: function getInputFormat() {
  786. return this.inputFormat() || 'MMM DD, YYYY';
  787. }
  788. }, {
  789. key: 'showLeftArrow',
  790. value: function showLeftArrow() {
  791. if (this.minMonth()) {
  792. return !this.minMonth().isSame(this.calendar.currentCalendar.clone().subtract(1, 'M'), 'M');
  793. } else if (this.minDay()) {
  794. return !this.minDay().isSame(this.calendar.currentCalendar, 'M');
  795. } else {
  796. return true;
  797. }
  798. }
  799. }, {
  800. key: 'showRightArrow',
  801. value: function showRightArrow() {
  802. if (this.maxMonth()) {
  803. return !this.maxMonth().isSame(this.getMonth().clone().add(1, 'M'), 'M');
  804. } else if (this.maxDay()) {
  805. return !this.maxDay().isSame(this.getMonth(), 'M');
  806. } else {
  807. return true;
  808. }
  809. }
  810. }, {
  811. key: '_showInput',
  812. value: function _showInput() {
  813. return angular.isDefined(this.showInput()) ? this.showInput() : true;
  814. }
  815. }]);
  816.  
  817. return CalendarController;
  818. })();
  819.  
  820. /***/ },
  821. /* 6 */
  822. /***/ function(module, exports) {
  823.  
  824. 'use strict';
  825.  
  826. Object.defineProperty(exports, '__esModule', {
  827. value: true
  828. });
  829.  
  830. var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
  831.  
  832. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  833.  
  834. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  835.  
  836. exports.ObDateRangePicker = ObDateRangePicker;
  837.  
  838. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  839.  
  840. function ObDateRangePicker() {
  841. 'ngInject';
  842.  
  843. var directive = {
  844. restrict: 'E',
  845. scope: {
  846. weekStart: '&',
  847. range: '=?',
  848. weekDaysName: '&',
  849. format: '&',
  850. ranges: '&',
  851. minDay: '&',
  852. maxDay: '&',
  853. monthFormat: '&',
  854. inputFormat: '&',
  855. onApply: '&',
  856. linkedCalendars: '&',
  857. autoApply: '&',
  858. disabled: '&',
  859. calendarsAlwaysOn: '&',
  860. api: '=?'
  861. },
  862. controller: ObDateRangePickerController,
  863. templateUrl: 'app/directives/ob-date-range-picker/ob-date-range-picker.html',
  864. controllerAs: 'obDateRangePicker',
  865. bindToController: true,
  866. link: function link(scope, elem, attrs, ctrl) {
  867. ctrl.init();
  868. }
  869. };
  870.  
  871. return directive;
  872. }
  873.  
  874. var ObDateRangePickerController = (function () {
  875. ObDateRangePickerController.$inject = ["$document", "$element", "$scope", "moment", "dateRangePickerConf"];
  876. function ObDateRangePickerController($document, $element, $scope, moment, dateRangePickerConf) {
  877. 'ngInject';
  878.  
  879. _classCallCheck(this, ObDateRangePickerController);
  880.  
  881. this.Element = $element;
  882. this.Document = $document;
  883. this.Scope = $scope;
  884. this.Moment = moment;
  885. this.dateRangePickerConf = dateRangePickerConf;
  886. this.pickerApi = {};
  887. }
  888.  
  889. _createClass(ObDateRangePickerController, [{
  890. key: 'init',
  891. value: function init() {
  892. var _this = this;
  893.  
  894. this.range = this.range || this.dateRangePickerConf.range || {};
  895.  
  896. //config setup
  897. this.weekStart = this.weekStart() ? this.weekStart : function () {
  898. return _this.dateRangePickerConf.weekStart;
  899. };
  900. this.weekDaysName = this.weekDaysName() ? this.weekDaysName : function () {
  901. return _this.dateRangePickerConf.weekDaysName;
  902. };
  903. this.format = this.format() ? this.format : function () {
  904. return _this.dateRangePickerConf.format;
  905. };
  906. this.ranges = this.ranges() ? this.ranges : function () {
  907. return _this.dateRangePickerConf.ranges;
  908. };
  909. this.minDay = this.minDay() ? this.minDay : function () {
  910. return _this.dateRangePickerConf.minDay;
  911. };
  912. this.maxDay = this.maxDay() ? this.maxDay : function () {
  913. return _this.dateRangePickerConf.maxDay;
  914. };
  915. this.monthFormat = this.monthFormat() ? this.monthFormat : function () {
  916. return _this.dateRangePickerConf.monthFormat;
  917. };
  918. this.inputFormat = this.inputFormat() ? this.inputFormat : function () {
  919. return _this.dateRangePickerConf.inputFormat;
  920. };
  921. this.linkedCalendars = angular.isDefined(this.linkedCalendars()) ? this.linkedCalendars : function () {
  922. return _this.dateRangePickerConf.linkedCalendars;
  923. };
  924. this.autoApply = angular.isDefined(this.autoApply()) ? this.autoApply : function () {
  925. return _this.dateRangePickerConf.autoApply;
  926. };
  927. this.disabled = angular.isDefined(this.disabled()) ? this.disabled : function () {
  928. return _this.dateRangePickerConf.disabled;
  929. };
  930. this.calendarsAlwaysOn = angular.isDefined(this.calendarsAlwaysOn()) ? this.calendarsAlwaysOn : function () {
  931. return _this.dateRangePickerConf.calendarsAlwaysOn;
  932. };
  933.  
  934. this.isCustomVisible = this.calendarsAlwaysOn();
  935.  
  936. this.setOpenCloseLogic();
  937. this.setWatchers();
  938. this.value = 'Select a Range';
  939.  
  940. this.api && _extends(this.api, {
  941. setDateRange: this.setDateRange.bind(this),
  942. togglePicker: this.togglePicker.bind(this),
  943. render: function render() {
  944. _this.render();
  945. _this.pickerApi.render();
  946. }
  947. });
  948. this.preRanges = this.ranges() || [];
  949. if (this.preRanges.length) {
  950. this.preRanges.push({
  951. name: 'Custom',
  952. isCustom: true
  953. });
  954. } else {
  955. this.isCustomVisible = true;
  956. }
  957.  
  958. this.render();
  959. this.setListeners();
  960. }
  961. }, {
  962. key: 'render',
  963. value: function render() {
  964. this._range = {
  965. start: this.Moment(),
  966. end: this.Moment()
  967. };
  968. this.setPredefinedStatus();
  969.  
  970. if (this.range.start && this.range.end && !this.Moment.isMoment(this.range.start) && !this.Moment.isMoment(this.range.end) && this.format()) {
  971. this._range = {
  972. start: this.Moment(this.range.start, this.getFormat()),
  973. end: this.Moment(this.range.end, this.getFormat())
  974. };
  975. } else if (this.Moment.isMoment(this.range.start) && this.Moment.isMoment(this.range.end)) {
  976. this._range = {
  977. start: this.range.start,
  978. end: this.range.end
  979. };
  980. } else if (this.preRanges.length > 1) {
  981. var firstPreRange = this.preRanges[0];
  982. this._range.start = firstPreRange.start;
  983. this._range.end = firstPreRange.end;
  984. }
  985.  
  986. if (this._range.start.isAfter(this._range.end)) {
  987. this._range.start = this._range.end.clone();
  988. } else if (this._range.end.isBefore(this._range.start)) {
  989. this._range.end = this._range.start.clone();
  990. }
  991.  
  992. this.applyMinMaxDaysToRange();
  993. this.setRange();
  994. this.markPredefined(this._range.start, this._range.end);
  995. this.setPickerInterceptors();
  996. this.isCustomVisible = this.calendarsAlwaysOn();
  997. }
  998. }, {
  999. key: 'applyMinMaxDaysToRange',
  1000. value: function applyMinMaxDaysToRange() {
  1001. if (this.minDay()) {
  1002. var minDay = this._getMinDay();
  1003. this._range.start = this._range.start.isBefore(minDay, 'd') ? minDay : this._range.start;
  1004. this._range.end = this._range.end.isBefore(minDay, 'd') ? minDay : this._range.end;
  1005. }
  1006.  
  1007. if (this.maxDay()) {
  1008. var maxDay = this._getMaxDay();
  1009. this._range.start = this._range.start.isAfter(maxDay) ? maxDay : this._range.start;
  1010. this._range.end = this._range.end.isAfter(maxDay) ? maxDay : this._range.end;
  1011. }
  1012. }
  1013. }, {
  1014. key: 'setPickerInterceptors',
  1015. value: function setPickerInterceptors() {
  1016. var _this2 = this;
  1017.  
  1018. this.pickerInterceptors = {
  1019. rangeSelectedByClick: function rangeSelectedByClick() {
  1020. if (_this2.autoApply()) {
  1021. _this2.applyChanges();
  1022. }
  1023. }
  1024. };
  1025. }
  1026. }, {
  1027. key: 'setPredefinedStatus',
  1028. value: function setPredefinedStatus() {
  1029. var _this3 = this;
  1030.  
  1031. this.preRanges.forEach(function (range) {
  1032. if (!range.isCustom) {
  1033. range.disabled = false;
  1034.  
  1035. if (_this3.minDay()) {
  1036. var minDay = _this3._getMinDay();
  1037. range.disabled = range.start.isBefore(minDay, 'd');
  1038. }
  1039.  
  1040. if (!range.disabled && _this3.maxDay()) {
  1041. var maxDay = _this3._getMaxDay();
  1042. range.disabled = range.end.isAfter(maxDay, 'd');
  1043. }
  1044. }
  1045. });
  1046. }
  1047. }, {
  1048. key: 'setWatchers',
  1049. value: function setWatchers() {
  1050. var _this4 = this;
  1051.  
  1052. this.Scope.$watchGroup([function () {
  1053. return _this4._range.start;
  1054. }, function () {
  1055. return _this4._range.end;
  1056. }], function (_ref) {
  1057. var _ref2 = _slicedToArray(_ref, 2);
  1058.  
  1059. var start = _ref2[0];
  1060. var end = _ref2[1];
  1061.  
  1062. if (!_this4.selfChange) {
  1063. if (start && end) {
  1064. if (_this4.preRanges.length) {
  1065. _this4.preRanges[_this4.preRanges.length - 1].start = start;
  1066. _this4.preRanges[_this4.preRanges.length - 1].end = end;
  1067. _this4.markPredefined(start, end);
  1068. }
  1069. _this4.value = _this4.getRangeValue();
  1070. }
  1071. }
  1072.  
  1073. _this4.selfChange = false;
  1074. });
  1075. }
  1076. }, {
  1077. key: 'setOpenCloseLogic',
  1078. value: function setOpenCloseLogic() {
  1079. this.isPickerVisible = false;
  1080. this.pickerPopup = angular.element(this.Element[0].querySelector('.picker'));
  1081. this.elemClickFlag = false;
  1082. }
  1083. }, {
  1084. key: 'setListeners',
  1085. value: function setListeners() {
  1086. var _this5 = this;
  1087.  
  1088. var events = {
  1089. documentClick: function documentClick() {
  1090. if (_this5.elemClickFlag) {
  1091. _this5.elemClickFlag = false;
  1092. } else if (_this5.isPickerVisible) {
  1093. _this5.discardChanges();
  1094. _this5.Scope.$apply();
  1095. }
  1096. },
  1097. documentEsc: function documentEsc(e) {
  1098. if (e.keyCode == 27 && _this5.isPickerVisible) {
  1099. _this5.discardChanges();
  1100. _this5.hidePicker();
  1101. _this5.Scope.$apply();
  1102. }
  1103. },
  1104. pickerClick: function pickerClick() {
  1105. _this5.elemClickFlag = true;
  1106. _this5.Scope.$apply();
  1107. }
  1108. };
  1109.  
  1110. this.pickerPopup.on('click', events.pickerClick.bind(this));
  1111. this.Document.on('click', events.documentClick.bind(this));
  1112. this.Document.on('keydown', events.documentEsc.bind(this));
  1113.  
  1114. this.Scope.$on('$destroy', function () {
  1115. _this5.pickerPopup.off('click', events.pickerClick);
  1116. _this5.Document.off('click', events.documentClick);
  1117. _this5.Document.off('keydown', events.documentClick);
  1118. });
  1119. }
  1120. }, {
  1121. key: 'togglePicker',
  1122. value: function togglePicker() {
  1123. var disabled = angular.isDefined(this.disabled()) ? this.disabled() : false;
  1124. if (!disabled && !this.isPickerVisible) {
  1125. this.isPickerVisible = true;
  1126. this.elemClickFlag = true;
  1127. } else {
  1128. this.isPickerVisible = false;
  1129. }
  1130. }
  1131. }, {
  1132. key: 'hidePicker',
  1133. value: function hidePicker() {
  1134. this.isPickerVisible = false;
  1135. }
  1136. }, {
  1137. key: 'setRange',
  1138. value: function setRange() {
  1139. var range = arguments.length <= 0 || arguments[0] === undefined ? this._range : arguments[0];
  1140.  
  1141. if (this.format()) {
  1142. this.range.start = range.start.format(this.getFormat());
  1143. this.range.end = range.end.format(this.getFormat());
  1144. } else {
  1145. this.range.start = range.start;
  1146. this.range.end = range.end;
  1147. }
  1148. }
  1149. }, {
  1150. key: 'predefinedRangeSelected',
  1151. value: function predefinedRangeSelected(range, index) {
  1152. if (!range.disabled) {
  1153. if (!range.isCustom) {
  1154. this.selfChange = true;
  1155. this.selectedRengeIndex = index;
  1156. this.value = range.name;
  1157. this._range.start = range.start;
  1158. this._range.end = range.end;
  1159. this.isCustomVisible = this.calendarsAlwaysOn() || false;
  1160. this.applyChanges();
  1161. } else {
  1162. this.isCustomVisible = true;
  1163. }
  1164. }
  1165. }
  1166. }, {
  1167. key: 'getFormat',
  1168. value: function getFormat() {
  1169. return this.format() || 'MM-DD-YYYY';
  1170. }
  1171. }, {
  1172. key: 'discardChanges',
  1173. value: function discardChanges() {
  1174. var format = this.getFormat();
  1175. var start = this.Moment(this.range.start, format);
  1176. var end = this.Moment(this.range.end, format);
  1177. this._range.start = start;
  1178. this._range.end = end;
  1179. this.value = this.getRangeValue();
  1180. this.pickerApi.setCalendarPosition(start, end);
  1181. this.hidePicker();
  1182. }
  1183. }, {
  1184. key: 'markPredefined',
  1185. value: function markPredefined(start, end) {
  1186. this.selectedRengeIndex = this.preRanges.findIndex(function (range) {
  1187. return start.isSame(range.start, 'day') && end.isSame(range.end, 'day');
  1188. });
  1189. }
  1190. }, {
  1191. key: 'getRangeValue',
  1192. value: function getRangeValue() {
  1193. var _this6 = this;
  1194.  
  1195. var value = undefined;
  1196. var format = this.getInputFormat();
  1197. if (this.preRanges.length) {
  1198. var index = this.preRanges.findIndex(function (range) {
  1199. return _this6._range.start.isSame(range.start, 'day') && _this6._range.end.isSame(range.end, 'day');
  1200. });
  1201.  
  1202. if (index !== -1) {
  1203. if (this.preRanges[index].isCustom) {
  1204. value = this.preRanges[index].start.format(format) + ' - ' + this.preRanges[index].end.format(format);
  1205. } else {
  1206. value = this.preRanges[index].name;
  1207. }
  1208. }
  1209. } else {
  1210. value = this._range.start.format(format) + ' - ' + this._range.end.format(format);
  1211. }
  1212.  
  1213. return value;
  1214. }
  1215. }, {
  1216. key: 'applyChanges',
  1217. value: function applyChanges() {
  1218. var callApply = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
  1219.  
  1220. this.setRange();
  1221. this.hidePicker();
  1222. this.pickerApi.setCalendarPosition && this.pickerApi.setCalendarPosition(this._range.start, this._range.end);
  1223. if (callApply && this.onApply) {
  1224. this.onApply({ start: this._range.start, end: this._range.end });
  1225. }
  1226. }
  1227. }, {
  1228. key: 'getInputFormat',
  1229. value: function getInputFormat() {
  1230. return this.inputFormat() || 'MMM DD, YYYY';
  1231. }
  1232. }, {
  1233. key: 'setDateRange',
  1234. value: function setDateRange(range) {
  1235. this._range.start = range.start;
  1236. this._range.end = range.end;
  1237. this.applyChanges(false);'';
  1238. }
  1239. }, {
  1240. key: '_getMinDay',
  1241. value: function _getMinDay() {
  1242. return this.minDay() ? this.Moment(this.minDay(), this.getFormat()) : undefined;
  1243. }
  1244. }, {
  1245. key: '_getMaxDay',
  1246. value: function _getMaxDay() {
  1247. return this.maxDay() ? this.Moment(this.maxDay(), this.getFormat()) : undefined;
  1248. }
  1249. }]);
  1250.  
  1251. return ObDateRangePickerController;
  1252. })();
  1253.  
  1254. /***/ },
  1255. /* 7 */
  1256. /***/ function(module, exports) {
  1257.  
  1258. 'use strict';
  1259.  
  1260. Object.defineProperty(exports, '__esModule', {
  1261. value: true
  1262. });
  1263.  
  1264. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  1265.  
  1266. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  1267.  
  1268. exports.ObDayPicker = ObDayPicker;
  1269.  
  1270. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  1271.  
  1272. function ObDayPicker() {
  1273. 'ngInject';
  1274.  
  1275. var directive = {
  1276. restrict: 'E',
  1277. scope: {
  1278. weekStart: '&',
  1279. selectedDay: '=?',
  1280. weekDaysName: '&',
  1281. format: '&',
  1282. minDay: '&',
  1283. maxDay: '&',
  1284. monthFormat: '&',
  1285. inputFormat: '&',
  1286. onApply: '&',
  1287. disabled: '&',
  1288. formName: '@name',
  1289. isValidDateEnabled: '&validDay',
  1290. autoApply: '&',
  1291. api: '=?'
  1292. },
  1293. controller: ObDayPickerController,
  1294. templateUrl: 'app/directives/ob-day-picker/ob-day-picker.html',
  1295. controllerAs: 'dayPicker',
  1296. bindToController: true,
  1297. link: function link(scope, elem, attrs, ctrl) {
  1298. ctrl.init();
  1299. }
  1300. };
  1301.  
  1302. return directive;
  1303. }
  1304.  
  1305. var ObDayPickerController = (function () {
  1306. ObDayPickerController.$inject = ["$document", "$element", "$scope", "$timeout", "moment", "datePickerConf"];
  1307. function ObDayPickerController($document, $element, $scope, $timeout, moment, datePickerConf) {
  1308. 'ngInject';
  1309.  
  1310. _classCallCheck(this, ObDayPickerController);
  1311.  
  1312. this.Element = $element;
  1313. this.Document = $document;
  1314. this.Scope = $scope;
  1315. this.$timeout = $timeout;
  1316. this.Moment = moment;
  1317. this.datePickerConf = datePickerConf;
  1318. }
  1319.  
  1320. _createClass(ObDayPickerController, [{
  1321. key: 'init',
  1322. value: function init() {
  1323. var _this = this;
  1324.  
  1325. //config setup
  1326. this.weekStart = this.weekStart() ? this.weekStart : function () {
  1327. return _this.datePickerConf.weekStart;
  1328. };
  1329. this.weekDaysName = this.weekDaysName() ? this.weekDaysName : function () {
  1330. return _this.datePickerConf.weekDaysName;
  1331. };
  1332. this.format = this.format() ? this.format : function () {
  1333. return _this.datePickerConf.format;
  1334. };
  1335. this.minDay = this.minDay() ? this.minDay : function () {
  1336. return _this.datePickerConf.minDay;
  1337. };
  1338. this.maxDay = this.maxDay() ? this.maxDay : function () {
  1339. return _this.datePickerConf.maxDay;
  1340. };
  1341. this.monthFormat = this.monthFormat() ? this.monthFormat : function () {
  1342. return _this.datePickerConf.monthFormat;
  1343. };
  1344. this.inputFormat = this.inputFormat() ? this.inputFormat : function () {
  1345. return _this.datePickerConf.inputFormat;
  1346. };
  1347. this.autoApply = angular.isDefined(this.autoApply()) ? this.autoApply : function () {
  1348. return _this.datePickerConf.autoApply;
  1349. };
  1350. this.disabled = angular.isDefined(this.disabled()) ? this.disabled : function () {
  1351. return _this.datePickerConf.disabled;
  1352. };
  1353. this.isValidDateEnabled = angular.isDefined(this.isValidDateEnabled()) ? this.isValidDateEnabled : function () {
  1354. return _this.datePickerConf.isValidDateEnabled;
  1355. };
  1356.  
  1357. this.formName = this.formName || 'dayPickerInput';
  1358.  
  1359. this.setOpenCloseLogic();
  1360. this._selectedDay = this.getSelectedDay();
  1361. this.value = this.Moment(this._selectedDay).format(this.getFormat());
  1362. this.setCalendarInterceptors();
  1363. this.calendarApi = {};
  1364.  
  1365. this.api && _extends(this.api, {
  1366. render: function render() {
  1367. _this.render();
  1368. }
  1369. });
  1370.  
  1371. this.setListeners();
  1372. this.dayValidity = this.checkIfDayIsValid(this._selectedDay);
  1373. this.$timeout(function () {
  1374. _this.applyValidity(_this.dayValidity);
  1375. });
  1376. }
  1377. }, {
  1378. key: 'render',
  1379. value: function render() {
  1380. this.dayValidity = this.checkIfDayIsValid(this._selectedDay);
  1381. this.applyValidity(this.dayValidity);
  1382. this.calendarApi.render && this.calendarApi.render();
  1383. }
  1384. }, {
  1385. key: 'setOpenCloseLogic',
  1386. value: function setOpenCloseLogic() {
  1387. this.isPickerVisible = false;
  1388. this.pickerPopup = angular.element(this.Element[0].querySelector('.picker'));
  1389. this.elemClickFlag = false;
  1390. }
  1391. }, {
  1392. key: 'setCalendarInterceptors',
  1393. value: function setCalendarInterceptors() {
  1394. this.calendarInterceptors = {
  1395. daySelected: this.daySelected.bind(this)
  1396. };
  1397. }
  1398. }, {
  1399. key: 'setListeners',
  1400. value: function setListeners() {
  1401. var _this2 = this;
  1402.  
  1403. var events = {
  1404. documentClick: function documentClick() {
  1405. if (_this2.elemClickFlag) {
  1406. _this2.elemClickFlag = false;
  1407. } else {
  1408. _this2.onBlur();
  1409. _this2.Scope.$digest();
  1410. }
  1411. },
  1412. pickerClick: function pickerClick() {
  1413. _this2.elemClickFlag = true;
  1414. _this2.Scope.$digest();
  1415. }
  1416. };
  1417.  
  1418. this.pickerPopup.on('click', events.pickerClick.bind(this));
  1419. this.Document.on('click', events.documentClick.bind(this));
  1420.  
  1421. this.Scope.$on('$destroy', function () {
  1422. _this2.pickerPopup.off('click', events.pickerClick);
  1423. _this2.Document.off('click', events.documentClick);
  1424. });
  1425.  
  1426. this.Scope.$watchGroup([function () {
  1427. return _this2.Moment(_this2.minDay(), _this2.getFormat()).format();
  1428. }, function () {
  1429. return _this2.Moment(_this2.maxDay(), _this2.getFormat()).format();
  1430. }], function (min, max) {
  1431. if (min && min[0] || max && max[0]) {
  1432. _this2.render();
  1433. }
  1434. });
  1435. }
  1436. }, {
  1437. key: 'showPicker',
  1438. value: function showPicker() {
  1439. var disabled = angular.isDefined(this.disabled()) ? this.disabled() : false;
  1440. if (!disabled && !this.isPickerVisible) {
  1441. this.isPickerVisible = true;
  1442. }
  1443. this.elemClickFlag = true;
  1444. }
  1445. }, {
  1446. key: 'hidePicker',
  1447. value: function hidePicker() {
  1448. this.isPickerVisible = false;
  1449. }
  1450. }, {
  1451. key: 'daySelected',
  1452. value: function daySelected(day) {
  1453. var _this3 = this;
  1454.  
  1455. var timeout = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1];
  1456.  
  1457. this.applyValidity(this.checkIfDayIsValid(day));
  1458. if (!day.isSame(this._selectedDay, 'day')) {
  1459. this.calendarApi.render();
  1460. this.value = this.Moment(day).format(this.getFormat());
  1461. this._selectedDay = day;
  1462.  
  1463. this.$timeout(function () {
  1464. _this3.hidePicker();
  1465. _this3.updateSelectedDate(day);
  1466. }, timeout);
  1467. } else {
  1468. this.hidePicker();
  1469. }
  1470. }
  1471. }, {
  1472. key: 'dateInputEntered',
  1473. value: function dateInputEntered(e, value) {
  1474. var isDaySelectable = this.checkIfDayIsValid(value);
  1475. switch (e.keyCode) {
  1476. case 9:
  1477. case 13:
  1478. var day = this.getInputValue();
  1479. if (isDaySelectable) {
  1480. this.daySelected(day, 0);
  1481. } else {
  1482. this.hidePicker();
  1483.  
  1484. // should prevent form submit if placed inside a form
  1485. e.keyCode === 13 && e.preventDefault();
  1486. }
  1487. break;
  1488. case 40:
  1489. this.isPickerVisible = true;
  1490. break;
  1491. case 27:
  1492. this.isPickerVisible = false;
  1493. this.value = this._selectedDay.format(this.getFormat());
  1494. break;
  1495. default:
  1496. break;
  1497. }
  1498. }
  1499. }, {
  1500. key: 'getInputValue',
  1501. value: function getInputValue() {
  1502. return this.Moment(this.value, this.getFormat(), true);
  1503. }
  1504. }, {
  1505. key: 'onBlur',
  1506. value: function onBlur() {
  1507. var currentValue = this.getInputValue();
  1508. var isValid = this.checkIfDayIsValid(currentValue);
  1509. if (isValid) {
  1510. this.daySelected(currentValue);
  1511. } else {
  1512. this.hidePicker();
  1513. }
  1514. }
  1515. }, {
  1516. key: 'updateValidity',
  1517. value: function updateValidity() {
  1518. var day = this.getInputValue();
  1519. var isValid = this.checkIfDayIsValid(day);
  1520. this.applyValidity(isValid);
  1521.  
  1522. if (isValid && this.autoApply() && !day.isSame(this._selectedDay, 'day')) {
  1523. this._selectedDay = day;
  1524. this.updateSelectedDate(day);
  1525. }
  1526. }
  1527. }, {
  1528. key: 'checkIfDayIsValid',
  1529. value: function checkIfDayIsValid(value) {
  1530. var day = this.Moment(value, this.getFormat(), true);
  1531. var minDay = this._getMinDay();
  1532. var maxDay = this._getMaxDay();
  1533. var isValid = day.isValid();
  1534.  
  1535. if (isValid && minDay) {
  1536. isValid = day.isAfter(minDay, 'day') || day.isSame(minDay, 'day');
  1537. }
  1538.  
  1539. if (isValid && maxDay) {
  1540. isValid = day.isBefore(maxDay, 'day') || day.isSame(maxDay, 'day');
  1541. }
  1542.  
  1543. return isValid;
  1544. }
  1545. }, {
  1546. key: 'applyValidity',
  1547. value: function applyValidity(isDateValid) {
  1548. if (this.Scope[this.formName]) {
  1549. if (this.disabled && this.disabled()) {
  1550. this.Scope[this.formName].$setValidity('validDay', true);
  1551. this.dayValidity = true;
  1552. } else if (this.isValidDateEnabled() && this.Scope[this.formName]) {
  1553. this.Scope[this.formName].$setValidity('validDay', isDateValid);
  1554. this.dayValidity = isDateValid;
  1555. }
  1556. }
  1557. }
  1558. }, {
  1559. key: 'updateSelectedDate',
  1560. value: function updateSelectedDate() {
  1561. var day = arguments.length <= 0 || arguments[0] === undefined ? this._selectedDay : arguments[0];
  1562.  
  1563. if (this.format()) {
  1564. this.selectedDay = day.format(this.getFormat());
  1565. } else {
  1566. this.selectedDay = day;
  1567. }
  1568.  
  1569. this.onApply({ day: this.selectedDay });
  1570. }
  1571. }, {
  1572. key: 'getSelectedDay',
  1573. value: function getSelectedDay() {
  1574. return this.Moment(this.selectedDay || this.Moment(), this.getFormat());
  1575. }
  1576. }, {
  1577. key: 'getFormat',
  1578. value: function getFormat() {
  1579. return this.format() || 'MMM DD, YYYY';
  1580. }
  1581. }, {
  1582. key: '_getMinDay',
  1583. value: function _getMinDay() {
  1584. return this.minDay() ? this.Moment(this.minDay(), this.getFormat()) : undefined;
  1585. }
  1586. }, {
  1587. key: '_getMaxDay',
  1588. value: function _getMaxDay() {
  1589. return this.maxDay() ? this.Moment(this.maxDay(), this.getFormat()) : undefined;
  1590. }
  1591. }]);
  1592.  
  1593. return ObDayPickerController;
  1594. })();
  1595.  
  1596. /***/ },
  1597. /* 8 */
  1598. /***/ function(module, exports) {
  1599.  
  1600. /*eslint-disable */
  1601. 'use strict';
  1602.  
  1603. if (!Array.prototype.findIndex) {
  1604. Array.prototype.findIndex = function (predicate) {
  1605. if (this === null) {
  1606. throw new TypeError('Array.prototype.findIndex called on null or undefined');
  1607. }
  1608. if (typeof predicate !== 'function') {
  1609. throw new TypeError('predicate must be a function');
  1610. }
  1611. var list = Object(this);
  1612. var length = list.length >>> 0;
  1613. var thisArg = arguments[1];
  1614. var value;
  1615.  
  1616. for (var i = 0; i < length; i++) {
  1617. value = list[i];
  1618. if (predicate.call(thisArg, value, i, list)) {
  1619. return i;
  1620. }
  1621. }
  1622. return -1;
  1623. };
  1624. }
  1625. /*eslint-enable */
  1626.  
  1627. /***/ }
  1628. /******/ ]);
  1629. angular.module("obDateRangePicker").run(["$templateCache", function($templateCache) {$templateCache.put("app/directives/calendar/calendar.html","<div class=\"input-container\" ng-if=\"month._showInput()\"><label>{{month.Attrs.label}}</label> <input type=\"text\" ng-model=\"month.value\" ng-keypress=\"month.dateInputEntered($event, month.value)\" ng-blur=\"month.dateInputSelected($event, month.value)\"></div><div class=\"header\"><span class=\"arrow-btn left\" ng-if=\"month.showLeftArrow()\" ng-click=\"month.moveToPrev()\"></span> <span class=\"date\">{{month.getFormattedMonth(month.calendar.currentCalendar)}}</span> <span class=\"arrow-btn right\" ng-if=\"month.showRightArrow()\" ng-click=\"month.moveToNext(1)\"></span></div><div class=\"board\"><div class=\"days-of-week\"><span class=\"day-name\" ng-repeat=\"day in month.daysName track by $index\">{{day}}</span></div><div class=\"weeks\"><div ng-repeat=\"week in month.calendar.monthWeeks track by $index\"><span class=\"day\" ng-repeat=\"day in week track by $index\" ng-class=\"{ \'selected\': day.selected, \'current\': day.currentDay, \'other-month\': !day.currentMonth, \'in-range\': day.inRange, \'range-start\': day.rangeStart, \'range-end\': day.rangeEnd, \'disabled\': day.disabled }\" ng-click=\"month.daySelected(day)\">{{day.mo.format(\'D\')}}</span></div></div></div>");
  1630. $templateCache.put("app/directives/date-range-picker/date-range-picker.html","<calendar class=\"calendar\" api=\"picker.startCalendarApi\" min-day=\"picker.minDay()\" max-day=\"picker.maxDay()\" week-start=\"picker.weekStart()\" month=\"picker.startCalendar\" interceptors=\"picker.startCalendarInterceptors\" range-start=\"picker.rangeStart\" range-end=\"picker.rangeEnd\" selected-day=\"picker.rangeStart\" max-month=\"picker.endCalendar\" week-days-name=\"picker.weekDaysName()\" month-format=\"picker.monthFormat()\" input-format=\"picker.inputFormat()\" label=\"Start Date\"></calendar><calendar class=\"calendar\" api=\"picker.endCalendarApi\" min-day=\"picker.minDay()\" max-day=\"picker.maxDay()\" week-start=\"picker.weekStart()\" month=\"picker.endCalendar\" interceptors=\"picker.endCalendarInterceptors\" range-start=\"picker.rangeStart\" range-end=\"picker.rangeEnd\" selected-day=\"picker.rangeEnd\" min-month=\"picker.startCalendar\" week-days-name=\"picker.weekDaysName()\" month-format=\"picker.monthFormat()\" input-format=\"picker.inputFormat()\" label=\"End Date\"></calendar>");
  1631. $templateCache.put("app/directives/ob-date-range-picker/ob-date-range-picker.html","<div class=\"picker-dropdown-container\" ng-class=\"{\'disabled\': obDateRangePicker.disabled()}\"><div class=\"picker-dropdown\" ng-class=\"{\'open\': obDateRangePicker.isPickerVisible}\" ng-click=\"obDateRangePicker.togglePicker()\"><span>{{obDateRangePicker.value}}</span></div><div class=\"picker\" ng-class=\"{\'open\': obDateRangePicker.isPickerVisible}\" ng-show=\"obDateRangePicker.isPickerVisible\"><div class=\"date-range\" ng-show=\"obDateRangePicker.isCustomVisible\"><date-range-picker ng-if=\"obDateRangePicker.isPickerVisible\" api=\"obDateRangePicker.pickerApi\" interceptors=\"obDateRangePicker.pickerInterceptors\" linked-calendars=\"obDateRangePicker.linkedCalendars()\" week-start=\"obDateRangePicker.weekStart()\" range=\"obDateRangePicker._range\" week-days-name=\"obDateRangePicker.weekDaysName()\" min-day=\"obDateRangePicker._getMinDay()\" max-day=\"obDateRangePicker._getMaxDay()\" month-format=\"obDateRangePicker.monthFormat()\" input-format=\"obDateRangePicker.inputFormat()\"></date-range-picker></div><div class=\"ranges-actions\" ng-class=\"{\'custom-open\': obDateRangePicker.isCustomVisible}\"><div class=\"ranges\"><div class=\"range\" ng-repeat=\"range in obDateRangePicker.preRanges track by $index\" ng-class=\"{\'selected\': obDateRangePicker.selectedRengeIndex === $index, \'disabled\': range.disabled}\" ng-click=\"obDateRangePicker.predefinedRangeSelected(range, $index)\" ng-if=\"!$last || ($last && !obDateRangePicker.calendarsAlwaysOn())\">{{range.name}}</div></div><div class=\"actions\" ng-if=\"!obDateRangePicker.autoApply()\"><div class=\"drp_btn cancel\" ng-click=\"obDateRangePicker.discardChanges()\">Cancel</div><div class=\"drp_btn apply\" ng-click=\"obDateRangePicker.applyChanges()\">APPLY</div></div></div></div></div>");
  1632. $templateCache.put("app/directives/ob-day-picker/ob-day-picker.html","<div ng-form=\"{{::dayPicker.formName}}\" class=\"picker-dropdown-container\" ng-class=\"{\'open\': dayPicker.isPickerVisible, \'disabled\': dayPicker.disabled(), \'invalid\': !dayPicker.dayValidity}\"><input class=\"picker-input\" ng-model=\"dayPicker.value\" ng-change=\"dayPicker.updateValidity()\" ng-keydown=\"dayPicker.dateInputEntered($event, dayPicker.value)\" ng-click=\"dayPicker.showPicker()\" ng-disabled=\"dayPicker.disabled()\"><div class=\"picker\" ng-show=\"dayPicker.isPickerVisible\"><calendar class=\"calendar\" api=\"dayPicker.calendarApi\" min-day=\"dayPicker._getMinDay()\" max-day=\"dayPicker._getMaxDay()\" week-start=\"dayPicker.weekStart()\" month=\"dayPicker._selectedDay\" interceptors=\"dayPicker.calendarInterceptors\" selected-day=\"dayPicker._selectedDay\" min-month=\"dayPicker.startCalendar\" week-days-name=\"dayPicker.weekDaysName()\" month-format=\"dayPicker.monthFormat()\" show-input=\"false\"></calendar></div></div>");}]);
  1633. //# sourceMappingURL=../maps/scripts/ob-daterangepicker.js.map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement