From aac68b252405b7b04f3867bfd5ff3c8f4d99a161 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 15 Nov 2018 20:41:58 -0800 Subject: [PATCH] Beta8 (#50) * Beta 8! * Apply fixes from StyleCI (#44) * Beta 8 composer * Updated * Add events * Changed on event * Apply fixes from StyleCI (#45) * Extend.php * Delete convert.sh * Some routes refactoring (BREAKS API COMPATIBILITY) & fix copyright link --- README.md | 3 +- bootstrap.php | 23 - composer.json | 4 +- extend.php | 43 + js/admin.js | 11 + js/admin/Gulpfile.js | 10 - js/admin/dist/extension.js | 144 -- js/admin/package.json | 7 - js/dist/admin.js | 210 +++ js/dist/admin.js.map | 1 + js/dist/forum.js | 1603 +++++++++++++++++ js/dist/forum.js.map | 1 + js/forum.js | 11 + js/forum/Gulpfile.js | 13 - js/forum/dist/extension.js | 1235 ------------- js/forum/package.json | 10 - js/package.json | 14 + js/{admin/src/main.js => src/admin/index.js} | 8 +- js/src/common/index.js | 0 js/{lib => src/common}/models/Answer.js | 3 + js/{lib => src/common}/models/Question.js | 10 +- js/{lib => src/common}/models/Vote.js | 3 + js/{forum/src => src/forum}/PollControl.js | 8 +- js/{forum/src => src/forum}/PollDiscussion.js | 2 +- js/{forum/src => src/forum}/addPollBadge.js | 2 +- .../forum}/components/EditPollModal.js | 17 +- .../src => src/forum}/components/PollModal.js | 3 +- .../src => src/forum}/components/PollVote.js | 4 +- .../forum}/components/ShowVotersModal.js | 0 js/{forum/src/main.js => src/forum/index.js} | 8 +- js/webpack.config.js | 3 + ...27_203645_add_default_poll_permissions.php | 42 +- {css/forum => resources/css}/Gulpfile.js | 0 .../css}/dist/DateTimePicker.min.css | 0 {css/forum => resources/css}/package.json | 0 src/Answer.php | 2 +- .../Controllers/CreateAnswerController.php | 4 +- src/Api/Controllers/CreateVoteController.php | 15 +- .../Controllers/DeleteAnswerController.php | 4 +- src/Api/Controllers/DeletePollController.php | 4 +- src/Api/Controllers/ListPollController.php | 8 +- src/Api/Controllers/ListVotesController.php | 6 +- .../Controllers/UpdateAnswerController.php | 4 +- .../Controllers/UpdateEndDateController.php | 8 +- src/Api/Controllers/UpdatePollController.php | 8 +- src/Api/Controllers/UpdateVoteController.php | 23 +- src/Api/Serializers/AnswerSerializer.php | 2 +- src/Api/Serializers/QuestionSerializer.php | 2 +- src/Api/Serializers/VoteSerializer.php | 2 +- src/Events/PollWasCreated.php | 39 + src/Events/PollWasVoted.php | 56 + src/Listeners/AddApiRoutes.php | 104 -- src/Listeners/AddClientAssets.php | 68 - .../AddDiscussionPollRelationship.php | 20 +- src/Listeners/AddForumFieldRelationship.php | 10 +- src/Listeners/SavePollToDatabase.php | 28 +- src/Question.php | 4 +- src/Repositories/AnswerRepository.php | 2 +- src/Repositories/QuestionRepository.php | 2 +- src/Repositories/VoteRepository.php | 2 +- src/Validators/AnswerValidator.php | 4 +- src/Vote.php | 2 +- 62 files changed, 2137 insertions(+), 1752 deletions(-) delete mode 100644 bootstrap.php create mode 100644 extend.php create mode 100644 js/admin.js delete mode 100644 js/admin/Gulpfile.js delete mode 100644 js/admin/dist/extension.js delete mode 100644 js/admin/package.json create mode 100644 js/dist/admin.js create mode 100644 js/dist/admin.js.map create mode 100644 js/dist/forum.js create mode 100644 js/dist/forum.js.map create mode 100644 js/forum.js delete mode 100644 js/forum/Gulpfile.js delete mode 100644 js/forum/dist/extension.js delete mode 100644 js/forum/package.json create mode 100644 js/package.json rename js/{admin/src/main.js => src/admin/index.js} (88%) create mode 100644 js/src/common/index.js rename js/{lib => src/common}/models/Answer.js (70%) rename js/{lib => src/common}/models/Question.js (70%) rename js/{lib => src/common}/models/Vote.js (71%) rename js/{forum/src => src/forum}/PollControl.js (87%) rename js/{forum/src => src/forum}/PollDiscussion.js (89%) rename js/{forum/src => src/forum}/addPollBadge.js (92%) rename js/{forum/src => src/forum}/components/EditPollModal.js (93%) rename js/{forum/src => src/forum}/components/PollModal.js (98%) rename js/{forum/src => src/forum}/components/PollVote.js (98%) rename js/{forum/src => src/forum}/components/ShowVotersModal.js (100%) rename js/{forum/src/main.js => src/forum/index.js} (93%) create mode 100644 js/webpack.config.js rename {css/forum => resources/css}/Gulpfile.js (100%) rename {css/forum => resources/css}/dist/DateTimePicker.min.css (100%) rename {css/forum => resources/css}/package.json (100%) create mode 100644 src/Events/PollWasCreated.php create mode 100644 src/Events/PollWasVoted.php delete mode 100644 src/Listeners/AddApiRoutes.php delete mode 100644 src/Listeners/AddClientAssets.php diff --git a/README.md b/README.md index c5e0793..b36911d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ - # Polls by ReFlar -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ReFlar/polls/blob/master/LICENSE) [![Latest Stable Version](https://img.shields.io/packagist/v/reflar/polls.svg)](https://github.com/ReFlar/polls) +[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ReFlar/polls/blob/master/LICENSE) [![Latest Stable Version](https://img.shields.io/packagist/v/reflar/polls.svg)](https://github.com/ReFlar/polls) A Flarum extension that adds polls to your discussions. diff --git a/bootstrap.php b/bootstrap.php deleted file mode 100644 index b061921..0000000 --- a/bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -subscribe(Listeners\AddApiRoutes::class); - $events->subscribe(Listeners\AddClientAssets::class); - $events->subscribe(Listeners\AddDiscussionPollRelationship::class); - $events->subscribe(Listeners\AddForumFieldRelationship::class); - $events->subscribe(Listeners\SavePollToDatabase::class); -}; diff --git a/composer.json b/composer.json index eb1efe6..efd7edc 100644 --- a/composer.json +++ b/composer.json @@ -23,13 +23,13 @@ "source": "https://github.com/ReFlar/polls" }, "require": { - "flarum/core": "^0.1.0-beta.7" + "flarum/core": "^0.1.0-beta.8" }, "extra": { "flarum-extension": { "title": "ReFlar Polls", "icon": { - "name": "signal", + "name": "fa fa-signal", "backgroundColor": "#263238", "color": "#ffffff" } diff --git a/extend.php b/extend.php new file mode 100644 index 0000000..b833fa9 --- /dev/null +++ b/extend.php @@ -0,0 +1,43 @@ +js(__DIR__.'/js/dist/admin.js'), + (new Extend\Frontend('forum')) + ->js(__DIR__.'/js/dist/forum.js') + ->css(__DIR__.'/resources/less/forum.less') + ->css(__DIR__.'/resources/css/dist/DateTimePicker.min.css'), + new Extend\Locales(__DIR__.'/resources/locale'), + (new Extend\Routes('api')) + ->get('/reflar/polls', 'polls.index', Controllers\ListPollController::class) + ->patch('/reflar/polls/{id}', 'polls.update', Controllers\UpdatePollController::class) + ->patch('/reflar/polls/{id}/endDate', 'polls.endDate.update', Controllers\UpdateEndDateController::class) + ->delete('/reflar/polls/{id}', 'polls.delete', Controllers\DeletePollController::class) + ->get('/reflar/polls/votes', 'polls.votes.index', Controllers\ListVotesController::class) + ->post('/reflar/polls/votes', 'polls.votes.create', Controllers\CreateVoteController::class) + ->patch('/reflar/polls/votes/{id}', 'polls.votes.update', Controllers\UpdateVoteController::class) + ->post('/reflar/polls/answers', 'polls.answers.create', Controllers\CreateAnswerController::class) + ->patch('/reflar/polls/answers/{id}', 'polls.answers.update', Controllers\UpdateAnswerController::class) + ->delete('/reflar/polls/answers/{id}', 'polls.answers.delete', Controllers\DeleteAnswerController::class), + function (Dispatcher $events) { + $events->subscribe(Listeners\AddDiscussionPollRelationship::class); + $events->subscribe(Listeners\AddForumFieldRelationship::class); + $events->subscribe(Listeners\SavePollToDatabase::class); + }, +]; diff --git a/js/admin.js b/js/admin.js new file mode 100644 index 0000000..9f8151e --- /dev/null +++ b/js/admin.js @@ -0,0 +1,11 @@ +/* + * This file is part of Flarum. + * + * (c) Toby Zerner + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +export * from './src/common'; +export * from './src/admin'; \ No newline at end of file diff --git a/js/admin/Gulpfile.js b/js/admin/Gulpfile.js deleted file mode 100644 index eaf337a..0000000 --- a/js/admin/Gulpfile.js +++ /dev/null @@ -1,10 +0,0 @@ -var gulp = require('flarum-gulp'); - -gulp({ - modules: { - 'reflar/polls': [ - '../lib/**/*.js', - 'src/**/*.js' - ] - } -}); diff --git a/js/admin/dist/extension.js b/js/admin/dist/extension.js deleted file mode 100644 index 028955f..0000000 --- a/js/admin/dist/extension.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -System.register('reflar/polls/main', ['flarum/app', 'flarum/extend', 'flarum/components/PermissionGrid'], function (_export, _context) { - "use strict"; - - var app, extend, override, PermissionGrid; - return { - setters: [function (_flarumApp) { - app = _flarumApp.default; - }, function (_flarumExtend) { - extend = _flarumExtend.extend; - override = _flarumExtend.override; - }, function (_flarumComponentsPermissionGrid) { - PermissionGrid = _flarumComponentsPermissionGrid.default; - }], - execute: function () { - - app.initializers.add('reflar-polls', function (app) { - extend(PermissionGrid.prototype, 'moderateItems', function (items) { - items.add('reflar-polls', { - icon: 'pencil', - label: app.translator.trans('reflar-polls.admin.permissions.moderate'), - permission: 'discussion.polls' - }, 95); - }); - extend(PermissionGrid.prototype, 'startItems', function (items) { - items.add('reflar-polls-start', { - icon: 'signal', - label: app.translator.trans('reflar-polls.admin.permissions.start'), - permission: 'startPolls' - }, 95); - }); - extend(PermissionGrid.prototype, 'replyItems', function (items) { - items.add('reflar-polls-edit', { - icon: 'pencil', - label: app.translator.trans('reflar-polls.admin.permissions.self_edit'), - permission: 'selfEditPolls' - }, 70); - items.add('reflar-polls-vote', { - icon: 'signal', - label: app.translator.trans('reflar-polls.admin.permissions.vote'), - permission: 'votePolls' - }, 80); - }); - }); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Answer', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Answer; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Answer = function (_mixin) { - babelHelpers.inherits(Answer, _mixin); - - function Answer() { - babelHelpers.classCallCheck(this, Answer); - return babelHelpers.possibleConstructorReturn(this, (Answer.__proto__ || Object.getPrototypeOf(Answer)).apply(this, arguments)); - } - - return Answer; - }(mixin(Model, { - answer: Model.attribute('answer'), - votes: Model.attribute('votes'), - percent: Model.attribute('percent') - })); - - _export('default', Answer); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Question', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Question; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Question = function (_mixin) { - babelHelpers.inherits(Question, _mixin); - - function Question() { - babelHelpers.classCallCheck(this, Question); - return babelHelpers.possibleConstructorReturn(this, (Question.__proto__ || Object.getPrototypeOf(Question)).apply(this, arguments)); - } - - return Question; - }(mixin(Model, { - question: Model.attribute('question'), - answers: Model.hasMany('answers'), - votes: Model.hasMany('votes') - })); - - _export('default', Question); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Vote', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Vote; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Vote = function (_mixin) { - babelHelpers.inherits(Vote, _mixin); - - function Vote() { - babelHelpers.classCallCheck(this, Vote); - return babelHelpers.possibleConstructorReturn(this, (Vote.__proto__ || Object.getPrototypeOf(Vote)).apply(this, arguments)); - } - - return Vote; - }(mixin(Model, { - poll_id: Model.attribute('poll_id'), - user_id: Model.attribute('user_id'), - option_id: Model.attribute('option_id') - })); - - _export('default', Vote); - } - }; -}); \ No newline at end of file diff --git a/js/admin/package.json b/js/admin/package.json deleted file mode 100644 index 0c40ef6..0000000 --- a/js/admin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "private": true, - "devDependencies": { - "gulp": "^3.8.11", - "flarum-gulp": "^0.2.0" - } -} diff --git a/js/dist/admin.js b/js/dist/admin.js new file mode 100644 index 0000000..f4e14c9 --- /dev/null +++ b/js/dist/admin.js @@ -0,0 +1,210 @@ +module.exports = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./admin.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./admin.js": +/*!******************!*\ + !*** ./admin.js ***! + \******************/ +/*! no static exports found */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _src_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/common */ "./src/common/index.js"); +/* harmony import */ var _src_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_src_common__WEBPACK_IMPORTED_MODULE_0__); +/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _src_common__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _src_common__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__)); +/* harmony import */ var _src_admin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./src/admin */ "./src/admin/index.js"); +/* empty/unused harmony star reexport *//* + * This file is part of Flarum. + * + * (c) Toby Zerner + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + + +/***/ }), + +/***/ "./src/admin/index.js": +/*!****************************!*\ + !*** ./src/admin/index.js ***! + \****************************/ +/*! no exports provided */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var flarum_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/app */ "flarum/app"); +/* harmony import */ var flarum_app__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_app__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/PermissionGrid */ "flarum/components/PermissionGrid"); +/* harmony import */ var flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2__); + + + +flarum_app__WEBPACK_IMPORTED_MODULE_0___default.a.initializers.add('reflar-polls', function (app) { + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'moderateItems', function (items) { + items.add('reflar-polls', { + icon: 'fa fa-pencil-alt', + label: app.translator.trans('reflar-polls.admin.permissions.moderate'), + permission: 'discussion.polls' + }, 95); + }); + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'startItems', function (items) { + items.add('reflar-polls-start', { + icon: 'fa fa-signal', + label: app.translator.trans('reflar-polls.admin.permissions.start'), + permission: 'startPolls' + }, 95); + }); + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_PermissionGrid__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'replyItems', function (items) { + items.add('reflar-polls-edit', { + icon: 'fa fa-pencil-alt', + label: app.translator.trans('reflar-polls.admin.permissions.self_edit'), + permission: 'selfEditPolls' + }, 70); + items.add('reflar-polls-vote', { + icon: 'fa fa-signal', + label: app.translator.trans('reflar-polls.admin.permissions.vote'), + permission: 'votePolls' + }, 80); + }); +}); + +/***/ }), + +/***/ "./src/common/index.js": +/*!*****************************!*\ + !*** ./src/common/index.js ***! + \*****************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + + + +/***/ }), + +/***/ "flarum/app": +/*!********************************************!*\ + !*** external "flarum.core.compat['app']" ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['app']; + +/***/ }), + +/***/ "flarum/components/PermissionGrid": +/*!******************************************************************!*\ + !*** external "flarum.core.compat['components/PermissionGrid']" ***! + \******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/PermissionGrid']; + +/***/ }), + +/***/ "flarum/extend": +/*!***********************************************!*\ + !*** external "flarum.core.compat['extend']" ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['extend']; + +/***/ }) + +/******/ }); +//# sourceMappingURL=admin.js.map \ No newline at end of file diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map new file mode 100644 index 0000000..f152ba2 --- /dev/null +++ b/js/dist/admin.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://@reflar/polls/webpack/bootstrap","webpack://@reflar/polls/./admin.js","webpack://@reflar/polls/./src/admin/index.js","webpack://@reflar/polls/external \"flarum.core.compat['app']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/PermissionGrid']\"","webpack://@reflar/polls/external \"flarum.core.compat['extend']\""],"names":["app","initializers","add","extend","PermissionGrid","prototype","items","icon","label","translator","trans","permission"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AAeC,KAAf,CAAqB,sCAArB,CAFqB;AAG5BC,gBAAU,EAAE;AAHgB,KAAhC,EAIG,EAJH;AAKH,GANK,CAAN;AAOAR,8DAAM,CAACC,uEAAc,CAACC,SAAhB,EAA2B,YAA3B,EAAyC,UAAAC,KAAK,EAAI;AACpDA,SAAK,CAACJ,GAAN,CAAU,mBAAV,EAA+B;AAC3BK,UAAI,EAAE,kBADqB;AAE3BC,WAAK,EAAER,GAAG,CAACS,UAAJ,CAAeC,KAAf,CAAqB,0CAArB,CAFoB;AAG3BC,gBAAU,EAAE;AAHe,KAA/B,EAIG,EAJH;AAKAL,SAAK,CAACJ,GAAN,CAAU,mBAAV,EAA+B;AAC3BK,UAAI,EAAE,cADqB;AAE3BC,WAAK,EAAER,GAAG,CAACS,UAAJ,CAAeC,KAAf,CAAqB,qCAArB,CAFoB;AAG3BC,gBAAU,EAAE;AAHe,KAA/B,EAIG,EAJH;AAKH,GAXK,CAAN;AAYH,CA3BD,E;;;;;;;;;;;;;;;;;;;;;;ACLA,2C;;;;;;;;;;;ACAA,iE;;;;;;;;;;;ACAA,8C","file":"admin.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./admin.js\");\n","/*\n * This file is part of Flarum.\n *\n * (c) Toby Zerner \n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport * from './src/common';\nexport * from './src/admin';","import app from 'flarum/app';\nimport { extend, override } from 'flarum/extend';\n\nimport PermissionGrid from 'flarum/components/PermissionGrid';\n\napp.initializers.add('reflar-polls', app => {\n extend(PermissionGrid.prototype, 'moderateItems', items => {\n items.add('reflar-polls', {\n icon: 'fa fa-pencil-alt',\n label: app.translator.trans('reflar-polls.admin.permissions.moderate'),\n permission: 'discussion.polls'\n }, 95);\n });\n extend(PermissionGrid.prototype, 'startItems', items => {\n items.add('reflar-polls-start', {\n icon: 'fa fa-signal',\n label: app.translator.trans('reflar-polls.admin.permissions.start'),\n permission: 'startPolls'\n }, 95);\n });\n extend(PermissionGrid.prototype, 'replyItems', items => {\n items.add('reflar-polls-edit', {\n icon: 'fa fa-pencil-alt',\n label: app.translator.trans('reflar-polls.admin.permissions.self_edit'),\n permission: 'selfEditPolls'\n }, 70);\n items.add('reflar-polls-vote', {\n icon: 'fa fa-signal',\n label: app.translator.trans('reflar-polls.admin.permissions.vote'),\n permission: 'votePolls'\n }, 80);\n });\n});\n","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['components/PermissionGrid'];","module.exports = flarum.core.compat['extend'];"],"sourceRoot":""} \ No newline at end of file diff --git a/js/dist/forum.js b/js/dist/forum.js new file mode 100644 index 0000000..0cc81a2 --- /dev/null +++ b/js/dist/forum.js @@ -0,0 +1,1603 @@ +module.exports = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./forum.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./forum.js": +/*!******************!*\ + !*** ./forum.js ***! + \******************/ +/*! no static exports found */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _src_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/common */ "./src/common/index.js"); +/* harmony import */ var _src_common__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_src_common__WEBPACK_IMPORTED_MODULE_0__); +/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _src_common__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _src_common__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__)); +/* harmony import */ var _src_forum__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./src/forum */ "./src/forum/index.js"); +/* empty/unused harmony star reexport *//* + * This file is part of Flarum. + * + * (c) Toby Zerner + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js": +/*!******************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***! + \******************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _inheritsLoose; }); +function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; +} + +/***/ }), + +/***/ "./node_modules/DateTimePicker/dist/DateTimePicker.min.js": +/*!****************************************************************!*\ + !*** ./node_modules/DateTimePicker/dist/DateTimePicker.min.js ***! + \****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* ----------------------------------------------------------------------------- + + jQuery DateTimePicker - Responsive flat design jQuery DateTime Picker plugin for Web & Mobile + Version 0.1.38 + Copyright (c)2017 Lajpat Shah + Contributors : https://github.com/nehakadam/DateTimePicker/contributors + Repository : https://github.com/nehakadam/DateTimePicker + Documentation : https://nehakadam.github.io/DateTimePicker + + ----------------------------------------------------------------------------- */ + +Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),$.DateTimePicker=$.DateTimePicker||{name:"DateTimePicker",i18n:{},defaults:{mode:"date",defaultDate:null,dateSeparator:"-",timeSeparator:":",timeMeridiemSeparator:" ",dateTimeSeparator:" ",monthYearSeparator:" ",dateTimeFormat:"dd-MM-yyyy HH:mm",dateFormat:"dd-MM-yyyy",timeFormat:"HH:mm",maxDate:null,minDate:null,maxTime:null,minTime:null,maxDateTime:null,minDateTime:null,shortDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],fullDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fullMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],labels:null,minuteInterval:1,roundOffMinutes:!0,secondsInterval:1,roundOffSeconds:!0,showHeader:!0,titleContentDate:"Set Date",titleContentTime:"Set Time",titleContentDateTime:"Set Date & Time",buttonsToDisplay:["HeaderCloseButton","SetButton","ClearButton"],setButtonContent:"Set",clearButtonContent:"Clear",incrementButtonContent:"+",decrementButtonContent:"-",setValueInTextboxOnEveryClick:!1,readonlyInputs:!1,animationDuration:400,touchHoldInterval:300,captureTouchHold:!1,mouseHoldInterval:50,captureMouseHold:!1,isPopup:!0,parentElement:"body",isInline:!1,inputElement:null,language:"",init:null,addEventHandlers:null,beforeShow:null,afterShow:null,beforeHide:null,afterHide:null,buttonClicked:null,settingValueOfElement:null,formatHumanDate:null,parseDateTimeString:null,formatDateTimeString:null},dataObject:{dCurrentDate:new Date,iCurrentDay:0,iCurrentMonth:0,iCurrentYear:0,iCurrentHour:0,iCurrentMinutes:0,iCurrentSeconds:0,sCurrentMeridiem:"",iMaxNumberOfDays:0,sDateFormat:"",sTimeFormat:"",sDateTimeFormat:"",dMinValue:null,dMaxValue:null,sArrInputDateFormats:[],sArrInputTimeFormats:[],sArrInputDateTimeFormats:[],bArrMatchFormat:[],bDateMode:!1,bTimeMode:!1,bDateTimeMode:!1,oInputElement:null,iTabIndex:0,bElemFocused:!1,bIs12Hour:!1,sTouchButton:null,iTouchStart:null,oTimeInterval:null,bIsTouchDevice:"ontouchstart"in document.documentElement}},$.cf={_isValid:function(a){return void 0!==a&&null!==a&&""!==a},_compare:function(a,b){var c=void 0!==a&&null!==a,d=void 0!==b&&null!==b;return!(!c||!d)&&a.toLowerCase()===b.toLowerCase()}},function(a){ true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "jquery")], __WEBPACK_AMD_DEFINE_FACTORY__ = (a), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):undefined}(function(a){"use strict";function b(b,c){this.element=b;var d="";d=a.cf._isValid(c)&&a.cf._isValid(c.language)?c.language:a.DateTimePicker.defaults.language,this.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[d],c),this.options=c,this.oData=a.extend({},a.DateTimePicker.dataObject),this._defaults=a.DateTimePicker.defaults,this._name=a.DateTimePicker.name,this.init()}a.fn.DateTimePicker=function(c){var d,e,f=a(this).data(),g=f?Object.keys(f):[];if("string"!=typeof c)return this.each(function(){a.removeData(this,"plugin_DateTimePicker"),a.data(this,"plugin_DateTimePicker")||a.data(this,"plugin_DateTimePicker",new b(this,c))});if(a.cf._isValid(f))if("destroy"===c){if(g.length>0)for(d in g)if(e=g[d],e.search("plugin_DateTimePicker")!==-1){a(document).unbind("click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker"),a(this).children().remove(),a(this).removeData(),a(this).unbind(),a(this).removeClass("dtpicker-overlay dtpicker-mobile dtpicker-inline"),f=f[e];break}}else if("object"===c&&g.length>0)for(d in g)if(e=g[d],e.search("plugin_DateTimePicker")!==-1)return f[e]},b.prototype={init:function(){var b=this;b._setDateFormatArray(),b._setTimeFormatArray(),b._setDateTimeFormatArray(),void 0!==a(b.element).data("parentelement")&&(b.settings.parentElement=a(b.element).data("parentelement")),b.settings.isPopup&&!b.settings.isInline&&(b._createPicker(),a(b.element).addClass("dtpicker-mobile")),b.settings.isInline&&(b._createPicker(),b._showPicker(b.settings.inputElement)),b.settings.init&&b.settings.init.call(b),b._addEventHandlersForInput()},_setDateFormatArray:function(){var a=this;a.oData.sArrInputDateFormats=[];var b="";b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",a.oData.sArrInputDateFormats.push(b),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MMM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MMMM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="yyyy"+a.settings.monthYearSeparator+"MM",a.oData.sArrInputDateFormats.push(b)},_setTimeFormatArray:function(){var a=this;a.oData.sArrInputTimeFormats=[];var b="";b="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",a.oData.sArrInputTimeFormats.push(b),b="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",a.oData.sArrInputTimeFormats.push(b),b="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",a.oData.sArrInputTimeFormats.push(b),b="HH"+a.settings.timeSeparator+"mm",a.oData.sArrInputTimeFormats.push(b)},_setDateTimeFormatArray:function(){var a=this;a.oData.sArrInputDateTimeFormats=[];var b="",c="",d="";b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d)},_matchFormat:function(b,c){var d=this;d.oData.bArrMatchFormat=[],d.oData.bDateMode=!1,d.oData.bTimeMode=!1,d.oData.bDateTimeMode=!1;var e,f=[];for(b=a.cf._isValid(b)?b:d.settings.mode,a.cf._compare(b,"date")?(c=a.cf._isValid(c)?c:d.oData.sDateFormat,d.oData.bDateMode=!0,f=d.oData.sArrInputDateFormats):a.cf._compare(b,"time")?(c=a.cf._isValid(c)?c:d.oData.sTimeFormat,d.oData.bTimeMode=!0,f=d.oData.sArrInputTimeFormats):a.cf._compare(b,"datetime")&&(c=a.cf._isValid(c)?c:d.oData.sDateTimeFormat,d.oData.bDateTimeMode=!0,f=d.oData.sArrInputDateTimeFormats),e=0;e0&&d._matchFormat(b,c)},_createPicker:function(){var b=this;b.settings.isInline?a(b.element).addClass("dtpicker-inline"):(a(b.element).addClass("dtpicker-overlay"),a(".dtpicker-overlay").click(function(a){b._hidePicker("")}));var c="";c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",a(b.element).html(c)},_addEventHandlersForInput:function(){var b=this;if(!b.settings.isInline){b.oData.oInputElement=null,a(b.settings.parentElement).find("input[type='date'], input[type='time'], input[type='datetime']").each(function(){a(this).attr("data-field",a(this).attr("type")),a(this).attr("type","text")});var c="[data-field='date'], [data-field='time'], [data-field='datetime']";a(b.settings.parentElement).off("focus",c,b._inputFieldFocus).on("focus",c,{obj:b},b._inputFieldFocus),a(b.settings.parentElement).off("click",c,b._inputFieldClick).on("click",c,{obj:b},b._inputFieldClick)}b.settings.addEventHandlers&&b.settings.addEventHandlers.call(b)},_inputFieldFocus:function(a){var b=a.data.obj;b.showDateTimePicker(this),b.oData.bMouseDown=!1},_inputFieldClick:function(b){var c=b.data.obj;a.cf._compare(a(this).prop("tagName"),"input")||c.showDateTimePicker(this),b.stopPropagation()},getDateObjectForInputField:function(b){var c=this;if(a.cf._isValid(b)){var d,e=c._getValueOfElement(b),f=a(b).data("field"),g="";return a.cf._isValid(f)||(f=c.settings.mode),c.settings.formatDateTimeString?d=c.settings.parseDateTimeString.call(c,e,f,g,a(b)):(g=a(b).data("format"),a.cf._isValid(g)||(a.cf._compare(f,"date")?g=c.settings.dateFormat:a.cf._compare(f,"time")?g=c.settings.timeFormat:a.cf._compare(f,"datetime")&&(g=c.settings.dateTimeFormat)),c._matchFormat(f,g),a.cf._compare(f,"date")?d=c._parseDate(e):a.cf._compare(f,"time")?d=c._parseTime(e):a.cf._compare(f,"datetime")&&(d=c._parseDateTime(e))),d}},setDateTimeStringInInputField:function(b,c){var d=this;c=c||d.oData.dCurrentDate;var e;a.cf._isValid(b)?(e=[],"string"==typeof b?e.push(b):"object"==typeof b&&(e=b)):e=a.cf._isValid(d.settings.parentElement)?a(d.settings.parentElement).find("[data-field='date'], [data-field='time'], [data-field='datetime']"):a("[data-field='date'], [data-field='time'], [data-field='datetime']"),e.each(function(){var b,e,f,g,h=this;b=a(h).data("field"),a.cf._isValid(b)||(b=d.settings.mode),e="Custom",f=!1,d.settings.formatDateTimeString||(e=a(h).data("format"),a.cf._isValid(e)||(a.cf._compare(b,"date")?e=d.settings.dateFormat:a.cf._compare(b,"time")?e=d.settings.timeFormat:a.cf._compare(b,"datetime")&&(e=d.settings.dateTimeFormat)),f=d.getIs12Hour(b,e)),g=d._setOutput(b,e,f,c,h),d._setValueOfElement(g,a(h))})},getDateTimeStringInFormat:function(a,b,c){var d=this;return d._setOutput(a,b,d.getIs12Hour(a,b),c)},showDateTimePicker:function(a){var b=this;null!==b.oData.oInputElement?b.settings.isInline||b._hidePicker(0,a):b._showPicker(a)},_setButtonAction:function(a){var b=this;null!==b.oData.oInputElement&&(b._setValueOfElement(b._setOutput()),a?(b.settings.buttonClicked&&b.settings.buttonClicked.call(b,"TAB",b.oData.oInputElement),b.settings.isInline||b._hidePicker(0)):b.settings.isInline||b._hidePicker(""))},_setOutput:function(b,c,d,e,f){var g=this;e=a.cf._isValid(e)?e:g.oData.dCurrentDate,d=d||g.oData.bIs12Hour;var h,i=g._setVariablesForDate(e,!0,!0),j="",k=g._formatDate(i),l=g._formatTime(i),m=a.extend({},k,l),n="",o="",p=Function.length;return g.settings.formatDateTimeString?j=g.settings.formatDateTimeString.call(g,m,b,c,f):(g._setMatchFormat(p,b,c),g.oData.bDateMode?g.oData.bArrMatchFormat[0]?j=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[1]?j=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]?j=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:g.oData.bArrMatchFormat[3]?j=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]?j=m.MM+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[5]?j=m.monthShort+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[6]?j=m.month+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[7]&&(j=m.yyyy+g.settings.monthYearSeparator+m.MM):g.oData.bTimeMode?g.oData.bArrMatchFormat[0]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[1]?j=m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:g.oData.bArrMatchFormat[2]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[3]&&(j=m.HH+g.settings.timeSeparator+m.mm):g.oData.bDateTimeMode&&(g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[8]||g.oData.bArrMatchFormat[9]?n=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[10]||g.oData.bArrMatchFormat[11]?n=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[12]||g.oData.bArrMatchFormat[13]?n=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:(g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7]||g.oData.bArrMatchFormat[14]||g.oData.bArrMatchFormat[15])&&(n=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy),h=g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7],o=d?h?m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:h?m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:m.HH+g.settings.timeSeparator+m.mm,""!==n&&""!==o&&(j=n+g.settings.dateTimeSeparator+o)),g._setMatchFormat(p)),j},_clearButtonAction:function(){var a=this;null!==a.oData.oInputElement&&a._setValueOfElement(""),a.settings.isInline||a._hidePicker("")},_setOutputOnIncrementOrDecrement:function(){var b=this;a.cf._isValid(b.oData.oInputElement)&&b.settings.setValueInTextboxOnEveryClick&&b._setValueOfElement(b._setOutput())},_showPicker:function(b){var c=this;if(null===c.oData.oInputElement){c.oData.oInputElement=b,c.oData.iTabIndex=parseInt(a(b).attr("tabIndex"));var d=a(b).data("field")||"",e=a(b).data("min")||"",f=a(b).data("max")||"",g=a(b).data("format")||"",h=a(b).data("view")||"",i=a(b).data("startend")||"",j=a(b).data("startendelem")||"",k=c._getValueOfElement(b)||"";if(""!==h&&(a.cf._compare(h,"Popup")?c.setIsPopup(!0):c.setIsPopup(!1)),!c.settings.isPopup&&!c.settings.isInline){c._createPicker();var l=a(c.oData.oInputElement).offset().top+a(c.oData.oInputElement).outerHeight(),m=a(c.oData.oInputElement).offset().left,n=a(c.oData.oInputElement).outerWidth();a(c.element).css({position:"absolute",top:l,left:m,width:n,height:"auto"})}c.settings.beforeShow&&c.settings.beforeShow.call(c,b),d=a.cf._isValid(d)?d:c.settings.mode,c.settings.mode=d,a.cf._isValid(g)||(a.cf._compare(d,"date")?g=c.settings.dateFormat:a.cf._compare(d,"time")?g=c.settings.timeFormat:a.cf._compare(d,"datetime")&&(g=c.settings.dateTimeFormat)),c._matchFormat(d,g),c.oData.dMinValue=null,c.oData.dMaxValue=null,c.oData.bIs12Hour=!1;var o,p,q,r,s,t,u,v;c.oData.bDateMode?(o=e||c.settings.minDate,p=f||c.settings.maxDate,c.oData.sDateFormat=g,a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDate(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDate(p)),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(q=c._getValueOfElement(a(j)),""!==q&&(r=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,q,d,g,a(j)):c._parseDate(q),a.cf._compare(i,"start")?a.cf._isValid(p)?c._compareDates(r,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(r)):c.oData.dMaxValue=new Date(r):a.cf._compare(i,"end")&&(a.cf._isValid(o)?c._compareDates(r,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(r)):c.oData.dMinValue=new Date(r)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDate(k),c.oData.dCurrentDate.setHours(0),c.oData.dCurrentDate.setMinutes(0),c.oData.dCurrentDate.setSeconds(0)):c.oData.bTimeMode?(o=e||c.settings.minTime,p=f||c.settings.maxTime,c.oData.sTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseTime(o),a.cf._isValid(p)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?p="11:59:59 PM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?p="23:59:59":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?p="11:59 PM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(p="23:59"),c.oData.dMaxValue=c._parseTime(p))),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseTime(p),a.cf._isValid(o)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?o="12:00:00 AM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?o="00:00:00":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?o="12:00 AM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(o="00:00"),c.oData.dMinValue=c._parseTime(o))),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(s=c._getValueOfElement(a(j)),""!==s&&(c.settings.parseDateTimeString?r=c.settings.parseDateTimeString.call(c,s,d,g,a(j)):t=c._parseTime(s),a.cf._compare(i,"start")?(t.setMinutes(t.getMinutes()-1),a.cf._isValid(p)?2===c._compareTime(t,c.oData.dMaxValue)&&(c.oData.dMaxValue=new Date(t)):c.oData.dMaxValue=new Date(t)):a.cf._compare(i,"end")&&(t.setMinutes(t.getMinutes()+1),a.cf._isValid(o)?3===c._compareTime(t,c.oData.dMinValue)&&(c.oData.dMinValue=new Date(t)):c.oData.dMinValue=new Date(t)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseTime(k)):c.oData.bDateTimeMode&&(o=e||c.settings.minDateTime,p=f||c.settings.maxDateTime,c.oData.sDateTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDateTime(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDateTime(p)),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(u=c._getValueOfElement(a(j)),""!==u&&(v=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,u,d,g,a(j)):c._parseDateTime(u),a.cf._compare(i,"start")?a.cf._isValid(p)?c._compareDateTime(v,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(v)):c.oData.dMaxValue=new Date(v):a.cf._compare(i,"end")&&(a.cf._isValid(o)?c._compareDateTime(v,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(v)):c.oData.dMinValue=new Date(v)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDateTime(k)),c._setVariablesForDate(),c._modifyPicker(),a(c.element).fadeIn(c.settings.animationDuration),c.settings.afterShow&&setTimeout(function(){c.settings.afterShow.call(c,b)},c.settings.animationDuration)}},_hidePicker:function(b,c){var d=this,e=d.oData.oInputElement;d.settings.beforeHide&&d.settings.beforeHide.call(d,e),a.cf._isValid(b)||(b=d.settings.animationDuration),a.cf._isValid(d.oData.oInputElement)&&(a(d.oData.oInputElement).blur(),d.oData.oInputElement=null),a(d.element).fadeOut(b),0===b?a(d.element).find(".dtpicker-subcontent").html(""):setTimeout(function(){a(d.element).find(".dtpicker-subcontent").html("")},b),a(document).unbind("click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker"),d.settings.afterHide&&(0===b?d.settings.afterHide.call(d,e):setTimeout(function(){d.settings.afterHide.call(d,e)},b)),a.cf._isValid(c)&&d._showPicker(c)},_modifyPicker:function(){var b,c,d=this,e=[];d.oData.bDateMode?(b=d.settings.titleContentDate,c=3,d.oData.bArrMatchFormat[0]?e=["day","month","year"]:d.oData.bArrMatchFormat[1]?e=["month","day","year"]:d.oData.bArrMatchFormat[2]?e=["year","month","day"]:d.oData.bArrMatchFormat[3]?e=["day","month","year"]:d.oData.bArrMatchFormat[4]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[5]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[6]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[7]&&(c=2,e=["year","month"])):d.oData.bTimeMode?(b=d.settings.titleContentTime,d.oData.bArrMatchFormat[0]?(c=4,e=["hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[1]?(c=3,e=["hour","minutes","seconds"]):d.oData.bArrMatchFormat[2]?(c=3,e=["hour","minutes","meridiem"]):d.oData.bArrMatchFormat[3]&&(c=2,e=["hour","minutes"])):d.oData.bDateTimeMode&&(b=d.settings.titleContentDateTime,d.oData.bArrMatchFormat[0]?(c=6,e=["day","month","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[1]?(c=7,e=["day","month","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[2]?(c=6,e=["month","day","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[3]?(c=7,e=["month","day","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[4]?(c=6,e=["year","month","day","hour","minutes","seconds"]):d.oData.bArrMatchFormat[5]?(c=7,e=["year","month","day","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[6]?(c=6,e=["day","month","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[7]?(c=7,e=["day","month","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[8]?(c=5,e=["day","month","year","hour","minutes"]):d.oData.bArrMatchFormat[9]?(c=6,e=["day","month","year","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[10]?(c=5,e=["month","day","year","hour","minutes"]):d.oData.bArrMatchFormat[11]?(c=6,e=["month","day","year","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[12]?(c=5,e=["year","month","day","hour","minutes"]):d.oData.bArrMatchFormat[13]?(c=6,e=["year","month","day","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[14]?(c=5,e=["day","month","year","hour","minutes"]):d.oData.bArrMatchFormat[15]&&(c=6,e=["day","month","year","hour","minutes","meridiem"]));var f,g="dtpicker-comp"+c,h=!1,i=!1,j=!1;for(f=0;f",h&&(k+="×"),k+="
",k+="");var l="";for(l+="
",f=0;f",l+="
",l+=""+d.settings.incrementButtonContent+"",l+=d.settings.readonlyInputs?"":"",l+=""+d.settings.decrementButtonContent+"",d.settings.labels&&(l+="
"+d.settings.labels[m]+"
"),l+="
",l+="
"}l+="";var n="";n=i&&j?" dtpicker-twoButtons":" dtpicker-singleButton";var o="";o+="";var p=k+l+o;a(d.element).find(".dtpicker-subcontent").html(p),d._setCurrentDate(),d._addEventHandlersForPicker()},_addEventHandlersForPicker:function(){var b,c,d=this;if(d.settings.isInline||a(document).on("click.DateTimePicker",function(a){d._hidePicker("")}),a(document).on("keydown.DateTimePicker",function(e){if(c=parseInt(e.keyCode?e.keyCode:e.which),!a(".dtpicker-compValue").is(":focus")&&9===c)return d._setButtonAction(!0),a("[tabIndex="+(d.oData.iTabIndex+1)+"]").focus(),!1;if(a(".dtpicker-compValue").is(":focus")){if(38===c)return b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"inc"),!1;if(40===c)return b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"dec"),!1}}),d.settings.isInline||a(document).on("keydown.DateTimePicker",function(b){c=parseInt(b.keyCode?b.keyCode:b.which),a(".dtpicker-compValue").is(":focus")||9===c||d._hidePicker("")}),a(".dtpicker-cont *").click(function(a){a.stopPropagation()}),d.settings.readonlyInputs||(a(".dtpicker-compValue").not(".month .dtpicker-compValue, .meridiem .dtpicker-compValue").keyup(function(){this.value=this.value.replace(/[^0-9\.]/g,"")}),a(".dtpicker-compValue").focus(function(){d.oData.bElemFocused=!0,a(this).select()}),a(".dtpicker-compValue").blur(function(){d._getValuesFromInputBoxes(),d._setCurrentDate(),d.oData.bElemFocused=!1;var b=a(this).parent().parent();setTimeout(function(){b.is(":last-child")&&!d.oData.bElemFocused&&d._setButtonAction(!1)},50)}),a(".dtpicker-compValue").keyup(function(b){var c,d=a(this),e=d.val(),f=e.length;d.parent().hasClass("day")||d.parent().hasClass("hour")||d.parent().hasClass("minutes")||d.parent().hasClass("meridiem")?f>2&&(c=e.slice(0,2),d.val(c)):d.parent().hasClass("month")?f>3&&(c=e.slice(0,3),d.val(c)):d.parent().hasClass("year")&&f>4&&(c=e.slice(0,4),d.val(c)),9===parseInt(b.keyCode?b.keyCode:b.which)&&a(this).select()})),a(d.element).find(".dtpicker-compValue").on("mousewheel DOMMouseScroll onmousewheel",function(c){if(a(".dtpicker-compValue").is(":focus")){var e=Math.max(-1,Math.min(1,c.originalEvent.wheelDelta));return e>0?(b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"inc")):(b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"dec")),!1}}),a(d.element).find(".dtpicker-close").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"CLOSE",d.oData.oInputElement),d.settings.isInline||d._hidePicker("")}),a(d.element).find(".dtpicker-buttonSet").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"SET",d.oData.oInputElement),d._setButtonAction(!1)}),a(d.element).find(".dtpicker-buttonClear").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"CLEAR",d.oData.oInputElement),d._clearButtonAction()}),d.settings.captureTouchHold||d.settings.captureMouseHold){var e="";d.settings.captureTouchHold&&d.oData.bIsTouchDevice&&(e+="touchstart touchmove touchend "),d.settings.captureMouseHold&&(e+="mousedown mouseup"),a(".dtpicker-cont *").on(e,function(a){d._clearIntervalForTouchEvents()}),d._bindTouchEvents("day"),d._bindTouchEvents("month"),d._bindTouchEvents("year"),d._bindTouchEvents("hour"),d._bindTouchEvents("minutes"),d._bindTouchEvents("seconds")}else a(d.element).find(".day .increment, .day .increment *").click(function(a){d.oData.iCurrentDay++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".day .decrement, .day .decrement *").click(function(a){d.oData.iCurrentDay--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".month .increment, .month .increment *").click(function(a){d.oData.iCurrentMonth++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".month .decrement, .month .decrement *").click(function(a){d.oData.iCurrentMonth--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".year .increment, .year .increment *").click(function(a){d.oData.iCurrentYear++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".year .decrement, .year .decrement *").click(function(a){d.oData.iCurrentYear--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".hour .increment, .hour .increment *").click(function(a){d.oData.iCurrentHour++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".hour .decrement, .hour .decrement *").click(function(a){d.oData.iCurrentHour--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".minutes .increment, .minutes .increment *").click(function(a){d.oData.iCurrentMinutes+=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".minutes .decrement, .minutes .decrement *").click(function(a){d.oData.iCurrentMinutes-=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".seconds .increment, .seconds .increment *").click(function(a){d.oData.iCurrentSeconds+=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".seconds .decrement, .seconds .decrement *").click(function(a){d.oData.iCurrentSeconds-=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()});a(d.element).find(".meridiem .dtpicker-compButton, .meridiem .dtpicker-compButton *").click(function(b){a.cf._compare(d.oData.sCurrentMeridiem,"AM")?(d.oData.sCurrentMeridiem="PM",d.oData.iCurrentHour+=12):a.cf._compare(d.oData.sCurrentMeridiem,"PM")&&(d.oData.sCurrentMeridiem="AM",d.oData.iCurrentHour-=12),d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()})},_adjustMinutes:function(a){var b=this;return b.settings.roundOffMinutes&&1!==b.settings.minuteInterval&&(a=a%b.settings.minuteInterval?a-a%b.settings.minuteInterval+b.settings.minuteInterval:a),a},_adjustSeconds:function(a){var b=this;return b.settings.roundOffSeconds&&1!==b.settings.secondsInterval&&(a=a%b.settings.secondsInterval?a-a%b.settings.secondsInterval+b.settings.secondsInterval:a),a},_getValueOfElement:function(b){var c="";return c=a.cf._compare(a(b).prop("tagName"),"INPUT")?a(b).val():a(b).html()},_setValueOfElement:function(b,c){var d=this;a.cf._isValid(c)||(c=a(d.oData.oInputElement)),a.cf._compare(c.prop("tagName"),"INPUT")?c.val(b):c.html(b);var e=d.getDateObjectForInputField(c);return d.settings.settingValueOfElement&&d.settings.settingValueOfElement.call(d,b,e,c),c.change(),b},_bindTouchEvents:function(b){var c=this;a(c.element).find("."+b+" .increment, ."+b+" .increment *").on("touchstart mousedown",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(), +c.oData.sTouchButton=b+"-inc",c._setIntervalForTouchEvents())}),a(c.element).find("."+b+" .increment, ."+b+" .increment *").on("touchend mouseup",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()}),a(c.element).find("."+b+" .decrement, ."+b+" .decrement *").on("touchstart mousedown",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(),c.oData.sTouchButton=b+"-dec",c._setIntervalForTouchEvents())}),a(c.element).find("."+b+" .decrement, ."+b+" .decrement *").on("touchend mouseup",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()})},_setIntervalForTouchEvents:function(){var b=this,c=b.oData.bIsTouchDevice?b.settings.touchHoldInterval:b.settings.mouseHoldInterval;if(!a.cf._isValid(b.oData.oTimeInterval)){var d;b.oData.oTimeInterval=setInterval(function(){d=(new Date).getTime()-b.oData.iTouchStart,d>c&&a.cf._isValid(b.oData.sTouchButton)&&("day-inc"===b.oData.sTouchButton?b.oData.iCurrentDay++:"day-dec"===b.oData.sTouchButton?b.oData.iCurrentDay--:"month-inc"===b.oData.sTouchButton?b.oData.iCurrentMonth++:"month-dec"===b.oData.sTouchButton?b.oData.iCurrentMonth--:"year-inc"===b.oData.sTouchButton?b.oData.iCurrentYear++:"year-dec"===b.oData.sTouchButton?b.oData.iCurrentYear--:"hour-inc"===b.oData.sTouchButton?b.oData.iCurrentHour++:"hour-dec"===b.oData.sTouchButton?b.oData.iCurrentHour--:"minute-inc"===b.oData.sTouchButton?b.oData.iCurrentMinutes+=b.settings.minuteInterval:"minute-dec"===b.oData.sTouchButton?b.oData.iCurrentMinutes-=b.settings.minuteInterval:"second-inc"===b.oData.sTouchButton?b.oData.iCurrentSeconds+=b.settings.secondsInterval:"second-dec"===b.oData.sTouchButton&&(b.oData.iCurrentSeconds-=b.settings.secondsInterval),b._setCurrentDate(),b._setOutputOnIncrementOrDecrement(),b.oData.iTouchStart=(new Date).getTime())},c)}},_clearIntervalForTouchEvents:function(){var b=this;clearInterval(b.oData.oTimeInterval),a.cf._isValid(b.oData.sTouchButton)&&(b.oData.sTouchButton=null,b.oData.iTouchStart=0),b.oData.oTimeInterval=null},_incrementDecrementActionsUsingArrowAndMouse:function(a,b){var c=this;a.includes("day")?"inc"===b?c.oData.iCurrentDay++:"dec"===b&&c.oData.iCurrentDay--:a.includes("month")?"inc"===b?c.oData.iCurrentMonth++:"dec"===b&&c.oData.iCurrentMonth--:a.includes("year")?"inc"===b?c.oData.iCurrentYear++:"dec"===b&&c.oData.iCurrentYear--:a.includes("hour")?"inc"===b?c.oData.iCurrentHour++:"dec"===b&&c.oData.iCurrentHour--:a.includes("minutes")?"inc"===b?c.oData.iCurrentMinutes+=c.settings.minuteInterval:"dec"===b&&(c.oData.iCurrentMinutes-=c.settings.minuteInterval):a.includes("seconds")&&("inc"===b?c.oData.iCurrentSeconds+=c.settings.secondsInterval:"dec"===b&&(c.oData.iCurrentSeconds-=c.settings.secondsInterval)),c._setCurrentDate(),c._setOutputOnIncrementOrDecrement()},_parseDate:function(b){var c=this,d=c.settings.defaultDate?new Date(c.settings.defaultDate):new Date,e=d.getDate(),f=d.getMonth(),g=d.getFullYear();if(a.cf._isValid(b))if("string"==typeof b){var h;h=c.oData.bArrMatchFormat[4]||c.oData.bArrMatchFormat[5]||c.oData.bArrMatchFormat[6]?b.split(c.settings.monthYearSeparator):b.split(c.settings.dateSeparator),c.oData.bArrMatchFormat[0]?(e=parseInt(h[0]),f=parseInt(h[1]-1),g=parseInt(h[2])):c.oData.bArrMatchFormat[1]?(f=parseInt(h[0]-1),e=parseInt(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[2]?(g=parseInt(h[0]),f=parseInt(h[1]-1),e=parseInt(h[2])):c.oData.bArrMatchFormat[3]?(e=parseInt(h[0]),f=c._getShortMonthIndex(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[4]?(e=1,f=parseInt(h[0])-1,g=parseInt(h[1])):c.oData.bArrMatchFormat[5]?(e=1,f=c._getShortMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[6]?(e=1,f=c._getFullMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[7]&&(e=1,f=parseInt(h[1])-1,g=parseInt(h[0]))}else e=b.getDate(),f=b.getMonth(),g=b.getFullYear();return d=new Date(g,f,e,0,0,0,0)},_parseTime:function(b){var c,d,e,f=this,g=f.settings.defaultDate?new Date(f.settings.defaultDate):new Date,h=g.getDate(),i=g.getMonth(),j=g.getFullYear(),k=g.getHours(),l=g.getMinutes(),m=g.getSeconds(),n=f.oData.bArrMatchFormat[0]||f.oData.bArrMatchFormat[1];return m=n?f._adjustSeconds(m):0,a.cf._isValid(b)&&("string"==typeof b?(f.oData.bIs12Hour&&(c=b.split(f.settings.timeMeridiemSeparator),b=c[0],d=c[1],a.cf._compare(d,"AM")||a.cf._compare(d,"PM")||(d="")),e=b.split(f.settings.timeSeparator),k=parseInt(e[0]),l=parseInt(e[1]),n&&(m=parseInt(e[2]),m=f._adjustSeconds(m)),12===k&&a.cf._compare(d,"AM")?k=0:k<12&&a.cf._compare(d,"PM")&&(k+=12)):(k=b.getHours(),l=b.getMinutes(),n&&(m=b.getSeconds(),m=f._adjustSeconds(m)))),l=f._adjustMinutes(l),g=new Date(j,i,h,k,l,m,0)},_parseDateTime:function(b){var c,d,e,f,g,h=this,i=h.settings.defaultDate?new Date(h.settings.defaultDate):new Date,j=i.getDate(),k=i.getMonth(),l=i.getFullYear(),m=i.getHours(),n=i.getMinutes(),o=i.getSeconds(),p="",q=h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7];return o=q?h._adjustSeconds(o):0,a.cf._isValid(b)&&("string"==typeof b?(c=b.split(h.settings.dateTimeSeparator),d=c[0].split(h.settings.dateSeparator),h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[8]||h.oData.bArrMatchFormat[9]?(j=parseInt(d[0]),k=parseInt(d[1]-1),l=parseInt(d[2])):h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[10]||h.oData.bArrMatchFormat[11]?(k=parseInt(d[0]-1),j=parseInt(d[1]),l=parseInt(d[2])):h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[12]||h.oData.bArrMatchFormat[13]?(l=parseInt(d[0]),k=parseInt(d[1]-1),j=parseInt(d[2])):(h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7]||h.oData.bArrMatchFormat[14]||h.oData.bArrMatchFormat[15])&&(j=parseInt(d[0]),k=h._getShortMonthIndex(d[1]),l=parseInt(d[2])),e=c[1],a.cf._isValid(e)&&(h.oData.bIs12Hour&&(a.cf._compare(h.settings.dateTimeSeparator,h.settings.timeMeridiemSeparator)&&3===c.length?p=c[2]:(f=e.split(h.settings.timeMeridiemSeparator),e=f[0],p=f[1]),a.cf._compare(p,"AM")||a.cf._compare(p,"PM")||(p="")),g=e.split(h.settings.timeSeparator),m=parseInt(g[0]),n=parseInt(g[1]),q&&(o=parseInt(g[2])),12===m&&a.cf._compare(p,"AM")?m=0:m<12&&a.cf._compare(p,"PM")&&(m+=12))):(j=b.getDate(),k=b.getMonth(),l=b.getFullYear(),m=b.getHours(),n=b.getMinutes(),q&&(o=b.getSeconds(),o=h._adjustSeconds(o)))),n=h._adjustMinutes(n),i=new Date(l,k,j,m,n,o,0)},_getShortMonthIndex:function(b){for(var c=this,d=0;d1&&(c=c.charAt(0).toUpperCase()+c.slice(1)),d=b.settings.shortMonthNames.indexOf(c),d!==-1?b.oData.iCurrentMonth=parseInt(d):c.match("^[+|-]?[0-9]+$")&&(b.oData.iCurrentMonth=parseInt(c-1)),b.oData.iCurrentDay=parseInt(a(b.element).find(".day .dtpicker-compValue").val())||b.oData.iCurrentDay,b.oData.iCurrentYear=parseInt(a(b.element).find(".year .dtpicker-compValue").val())||b.oData.iCurrentYear}if(b.oData.bTimeMode||b.oData.bDateTimeMode){var e,f,g,h;e=parseInt(a(b.element).find(".hour .dtpicker-compValue").val()),f=b._adjustMinutes(parseInt(a(b.element).find(".minutes .dtpicker-compValue").val())),g=b._adjustMinutes(parseInt(a(b.element).find(".seconds .dtpicker-compValue").val())),b.oData.iCurrentHour=isNaN(e)?b.oData.iCurrentHour:e,b.oData.iCurrentMinutes=isNaN(f)?b.oData.iCurrentMinutes:f,b.oData.iCurrentSeconds=isNaN(g)?b.oData.iCurrentSeconds:g,b.oData.iCurrentSeconds>59&&(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60),b.oData.iCurrentMinutes>59&&(b.oData.iCurrentHour+=b.oData.iCurrentMinutes/60,b.oData.iCurrentMinutes=b.oData.iCurrentMinutes%60),b.oData.bIs12Hour?b.oData.iCurrentHour>12&&(b.oData.iCurrentHour=b.oData.iCurrentHour%12):b.oData.iCurrentHour>23&&(b.oData.iCurrentHour=b.oData.iCurrentHour%23),b.oData.bIs12Hour&&(h=a(b.element).find(".meridiem .dtpicker-compValue").val(),(a.cf._compare(h,"AM")||a.cf._compare(h,"PM"))&&(b.oData.sCurrentMeridiem=h),a.cf._compare(b.oData.sCurrentMeridiem,"PM")&&12!==b.oData.iCurrentHour&&b.oData.iCurrentHour<13&&(b.oData.iCurrentHour+=12),a.cf._compare(b.oData.sCurrentMeridiem,"AM")&&12===b.oData.iCurrentHour&&(b.oData.iCurrentHour=0))}},_setCurrentDate:function(){var b=this;(b.oData.bTimeMode||b.oData.bDateTimeMode)&&(b.oData.iCurrentSeconds>59?(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60):b.oData.iCurrentSeconds<0&&(b.oData.iCurrentMinutes-=b.settings.minuteInterval,b.oData.iCurrentSeconds+=60),b.oData.iCurrentMinutes=b._adjustMinutes(b.oData.iCurrentMinutes),b.oData.iCurrentSeconds=b._adjustSeconds(b.oData.iCurrentSeconds));var c,d,e,f,g,h,i,j=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),k=!1,l=!1;if(null!==b.oData.dMaxValue&&(k=j.getTime()>b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(l=j.getTime()b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(n=b.oData.dCurrentDate.getTime()12&&(e-=12),"00"===g&&(e=12),f=e<10?"0"+e:e,j.oData.bIs12Hour&&(g=f),h=k.iCurrentMinutes,h=h<10?"0"+h:h,i=k.iCurrentSeconds,i=i<10?"0"+i:i,{H:c,HH:d,h:e,hh:f,hour:g,m:k.iCurrentMinutes,mm:h,s:k.iCurrentSeconds,ss:i,ME:k.sCurrentMeridiem}},_setButtons:function(){var b=this;a(b.element).find(".dtpicker-compButton").removeClass("dtpicker-compButtonDisable").addClass("dtpicker-compButtonEnable");var c;if(null!==b.oData.dMaxValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour+1>b.oData.dMaxValue.getHours()||b.oData.iCurrentHour+1===b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes>b.oData.dMaxValue.getMinutes())&&a(b.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),b.oData.iCurrentHour>=b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes+1>b.oData.dMaxValue.getMinutes()&&a(b.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")):(c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay+1,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".day .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth+1,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".month .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear+1,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".year .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour+1,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes+1,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds+1,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".seconds .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"))),null!==b.oData.dMinValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour-1b.oData.dMaxValue.getHours()||d===b.oData.dMaxValue.getHours()&&e>b.oData.dMaxValue.getMinutes())&&a(b.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")):c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")),null!==b.oData.dMinValue&&(b.oData.bTimeMode?(e=b.oData.iCurrentMinutes,(db.getHours()?c=3:a.getHours()===b.getHours()&&(a.getMinutes()b.getMinutes()&&(c=3)),c},_compareDateTime:function(a,b){var c=(a.getTime()-b.getTime())/6e4;return 0===c?c:c/Math.abs(c)},_determineMeridiemFromHourAndMinutes:function(a,b){return a>12||12===a&&b>=0?"PM":"AM"},setLanguage:function(b){var c=this;return c.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[b],c.options),c.settings.language=b,c._setDateFormatArray(),c._setTimeFormatArray(),c._setDateTimeFormatArray(),c}}}); + +/***/ }), + +/***/ "./src/common/index.js": +/*!*****************************!*\ + !*** ./src/common/index.js ***! + \*****************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + + + +/***/ }), + +/***/ "./src/common/models/Answer.js": +/*!*************************************!*\ + !*** ./src/common/models/Answer.js ***! + \*************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Answer; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/Model */ "flarum/Model"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_Model__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/utils/mixin */ "flarum/utils/mixin"); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__); + + + + +var Answer = +/*#__PURE__*/ +function (_mixin) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(Answer, _mixin); + + function Answer() { + return _mixin.apply(this, arguments) || this; + } + + var _proto = Answer.prototype; + + _proto.apiEndpoint = function apiEndpoint() { + return "/reflar/polls/answers" + (this.exists ? "/" + this.data.id : ''); + }; + + return Answer; +}(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default()(flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a, { + answer: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('answer'), + votes: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('votes'), + percent: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('percent') +})); + + + +/***/ }), + +/***/ "./src/common/models/Question.js": +/*!***************************************!*\ + !*** ./src/common/models/Question.js ***! + \***************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Question; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/Model */ "flarum/Model"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_Model__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/utils/mixin */ "flarum/utils/mixin"); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__); + + + + +var Question = +/*#__PURE__*/ +function (_mixin) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(Question, _mixin); + + function Question() { + return _mixin.apply(this, arguments) || this; + } + + var _proto = Question.prototype; + + _proto.apiEndpoint = function apiEndpoint() { + return "/reflar/polls" + (this.exists ? "/" + this.data.id : ''); + }; + + return Question; +}(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default()(flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a, { + question: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('question'), + isEnded: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('isEnded'), + endDate: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('endDate'), + isPublic: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('isPublic'), + answers: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.hasMany('answers'), + votes: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.hasMany('votes') +})); + + + +/***/ }), + +/***/ "./src/common/models/Vote.js": +/*!***********************************!*\ + !*** ./src/common/models/Vote.js ***! + \***********************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Vote; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/Model */ "flarum/Model"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_Model__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/utils/mixin */ "flarum/utils/mixin"); +/* harmony import */ var flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2__); + + + + +var Vote = +/*#__PURE__*/ +function (_mixin) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(Vote, _mixin); + + function Vote() { + return _mixin.apply(this, arguments) || this; + } + + var _proto = Vote.prototype; + + _proto.apiEndpoint = function apiEndpoint() { + return "/reflar/polls/votes" + (this.exists ? "/" + this.data.id : ''); + }; + + return Vote; +}(flarum_utils_mixin__WEBPACK_IMPORTED_MODULE_2___default()(flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a, { + poll_id: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('poll_id'), + user_id: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('user_id'), + option_id: flarum_Model__WEBPACK_IMPORTED_MODULE_1___default.a.attribute('option_id') +})); + + + +/***/ }), + +/***/ "./src/forum/PollControl.js": +/*!**********************************!*\ + !*** ./src/forum/PollControl.js ***! + \**********************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var flarum_utils_PostControls__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/utils/PostControls */ "flarum/utils/PostControls"); +/* harmony import */ var flarum_utils_PostControls__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_utils_PostControls__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/Button */ "flarum/components/Button"); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Button__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _components_EditPollModal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/EditPollModal */ "./src/forum/components/EditPollModal.js"); + + + + +/* harmony default export */ __webpack_exports__["default"] = (function () { + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_0__["extend"])(flarum_utils_PostControls__WEBPACK_IMPORTED_MODULE_1___default.a, 'moderationControls', function (items, post) { + var discussion = post.discussion(); + var poll = discussion.Poll(); + var user = app.session.user; + + if (discussion.Poll() && (user !== undefined && user.canEditPolls() || post.user().canSelfEditPolls() && post.user().id() === user.id()) && post.number() === 1) { + if (!poll.isEnded()) { + items.add('editPoll', [m(flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default.a, { + icon: 'fa fa-check-square', + className: 'reflar-PollButton', + onclick: function onclick() { + app.modal.show(new _components_EditPollModal__WEBPACK_IMPORTED_MODULE_3__["default"]({ + post: post, + poll: poll + })); + } + }, app.translator.trans('reflar-polls.forum.moderation.edit'))]); + } + + items.add('removePoll', [m(flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default.a, { + icon: 'fa fa-trash', + className: 'reflar-PollButton', + onclick: function onclick() { + if (confirm(app.translator.trans('reflar-polls.forum.moderation.delete_confirm'))) { + app.request({ + url: app.forum.attribute('apiUrl') + "/reflar/polls/" + poll.id(), + method: 'DELETE', + data: poll.store.data.users[Object.keys(poll.store.data.users)[0]].id() + }).then(function () { + location.reload(); + }); + } + } + }, app.translator.trans('reflar-polls.forum.moderation.delete'))]); + } + }); +}); + +/***/ }), + +/***/ "./src/forum/PollDiscussion.js": +/*!*************************************!*\ + !*** ./src/forum/PollDiscussion.js ***! + \*************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var flarum_components_CommentPost__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/components/CommentPost */ "flarum/components/CommentPost"); +/* harmony import */ var flarum_components_CommentPost__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_components_CommentPost__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _components_PollVote__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/PollVote */ "./src/forum/components/PollVote.js"); + + + +/* harmony default export */ __webpack_exports__["default"] = (function () { + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_0__["extend"])(flarum_components_CommentPost__WEBPACK_IMPORTED_MODULE_1___default.a.prototype, 'content', function (content) { + var discussion = this.props.post.discussion(); + + if (discussion.Poll() && this.props.post.number() === 1 && !this.props.post.isHidden()) { + this.subtree.invalidate(); + content.push(_components_PollVote__WEBPACK_IMPORTED_MODULE_2__["default"].component({ + poll: discussion.Poll() + })); + } + }); +}); + +/***/ }), + +/***/ "./src/forum/addPollBadge.js": +/*!***********************************!*\ + !*** ./src/forum/addPollBadge.js ***! + \***********************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return addPollBadge; }); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/models/Discussion */ "flarum/models/Discussion"); +/* harmony import */ var flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_Badge__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/Badge */ "flarum/components/Badge"); +/* harmony import */ var flarum_components_Badge__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Badge__WEBPACK_IMPORTED_MODULE_2__); + + + +function addPollBadge() { + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_0__["extend"])(flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_1___default.a.prototype, 'badges', function (badges) { + if (this.Poll()) { + badges.add('poll', flarum_components_Badge__WEBPACK_IMPORTED_MODULE_2___default.a.component({ + type: 'poll', + label: app.translator.trans('reflar-polls.forum.tooltip.badge'), + icon: 'fa fa-signal' + }), 5); + } + }); +} + +/***/ }), + +/***/ "./src/forum/components/EditPollModal.js": +/*!***********************************************!*\ + !*** ./src/forum/components/EditPollModal.js ***! + \***********************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return EditPollModal; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/Modal */ "flarum/components/Modal"); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/components/Button */ "flarum/components/Button"); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Button__WEBPACK_IMPORTED_MODULE_3__); + + + + + +var EditPollModal = +/*#__PURE__*/ +function (_Modal) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(EditPollModal, _Modal); + + function EditPollModal() { + return _Modal.apply(this, arguments) || this; + } + + var _proto = EditPollModal.prototype; + + _proto.init = function init() { + _Modal.prototype.init.call(this); + + this.answers = this.props.poll.answers(); + this.question = m.prop(this.props.poll.question()); + this.pollCreator = this.props.poll.store.data.users[Object.keys(this.props.poll.store.data.users)[0]]; + this.newAnswer = m.prop(''); + this.endDate = m.prop(this.props.poll.endDate() === ' UTC' ? '' : this.getDateTime(new Date(this.props.poll.endDate()))); + }; + + _proto.className = function className() { + return 'PollDiscussionModal Modal--small'; + }; + + _proto.title = function title() { + return app.translator.trans('reflar-polls.forum.modal.edit_title'); + }; + + _proto.getDateTime = function getDateTime(date) { + if (date === void 0) { + date = new Date(); + } + + if (isNaN(date)) { + date = new Date(); + } + + var checkTargets = [date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes()]; + checkTargets.forEach(function (target, i) { + if (target < 10) { + checkTargets[i] = "0" + target; + } + }); + return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]; + }; + + _proto.config = function config(isInitalized) { + var _this = this; + + if (isInitalized) return; + var oDTP1; + $('#dtBox').DateTimePicker({ + init: function init() { + oDTP1 = this; + }, + dateTimeFormat: "yyyy-MM-dd HH:mm", + minDateTime: this.getDateTime(), + settingValueOfElement: function settingValueOfElement(value) { + _this.endDate(value); + + app.request({ + method: 'PATCH', + url: app.forum.attribute('apiUrl') + "/reflar/polls/" + _this.props.poll.id() + "/endDate", + data: { + date: new Date(value), + user_id: _this.pollCreator.id() + } + }); + } + }); + }; + + _proto.content = function content() { + var _this2 = this; + + return [m("div", { + className: "Modal-body" + }, m("div", { + className: "PollDiscussionModal-form" + }, m("div", null, m("fieldset", null, m("input", { + type: "text", + name: "question", + className: "FormControl", + value: this.question(), + oninput: m.withAttr('value', this.updateQuestion.bind(this)), + placeholder: app.translator.trans('reflar-polls.forum.modal.question_placeholder') + }))), m("h4", null, app.translator.trans('reflar-polls.forum.modal.answers')), this.answers.map(function (answer, i) { + return m("div", { + className: "Form-group" + }, m("fieldset", { + className: "Poll-answer-input" + }, m("input", { + className: "FormControl", + type: "text", + oninput: m.withAttr('value', _this2.updateAnswer.bind(_this2, answer)), + value: answer.answer(), + placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (i + 1) + })), i + 1 >= 3 ? flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + type: 'button', + className: 'Button Button--warning Poll-answer-button', + icon: 'fa fa-minus', + onclick: i + 1 >= 3 ? _this2.removeOption.bind(_this2, answer) : '' + }) : '', m("div", { + className: "clear" + })); + }), m("div", { + className: "Form-group" + }, m("fieldset", { + className: "Poll-answer-input" + }, m("input", { + className: "FormControl", + type: "text", + oninput: m.withAttr('value', this.newAnswer), + placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (this.answers.length + 1) + })), flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + type: 'button', + className: 'Button Button--warning Poll-answer-button', + icon: 'fa fa-plus', + onclick: this.addAnswer.bind(this) + })), m("div", { + className: "clear" + }), m("div", { + style: "margin-top: 20px", + className: "Form-group" + }, m("fieldset", { + style: "margin-bottom: 15px", + className: "Poll-answer-input" + }, m("input", { + style: "opacity: 1", + className: "FormControl", + type: "text", + "data-field": "datetime", + value: this.endDate() || app.translator.trans('reflar-polls.forum.modal.date_placeholder'), + id: "dtInput", + "data-min": this.getDateTime(), + readonly: true + }), m("div", { + id: "dtBox" + }))), m("div", { + className: "clear" + })), flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + className: 'Button Button--primary PollModal-SubmitButton', + children: app.translator.trans('reflar-polls.forum.modal.submit'), + onclick: function onclick() { + app.modal.close(); + } + }))]; + }; + + _proto.onhide = function onhide() { + this.props.poll.answers = m.prop(this.answers); + this.props.poll.question = this.question; + + if (this.endDate() !== '') { + this.props.poll.endDate = this.endDate; + } + + m.redraw.strategy('all'); + }; + + _proto.addAnswer = function addAnswer(answer) { + var _this3 = this; + + var data = { + answer: this.newAnswer(), + poll_id: this.props.poll.id(), + user_id: this.pollCreator.id() + }; + + if (this.answers.length < 10) { + app.store.createRecord('answers').save(data).then(function (answer) { + _this3.answers.push(answer); + + _this3.newAnswer(''); + + m.redraw.strategy('all'); + m.redraw(); + }); + } else { + alert(app.translator.trans('reflar-polls.forum.modal.max')); + } + }; + + _proto.removeOption = function removeOption(option) { + var _this4 = this; + + app.request({ + method: 'DELETE', + url: app.forum.attribute('apiUrl') + "/reflar/polls/answers/" + option.data.id, + data: this.pollCreator.id() + }); + this.answers.some(function (answer, i) { + if (answer.data.id === option.data.id) { + _this4.answers.splice(i, 1); + + return true; + } + }); + }; + + _proto.updateAnswer = function updateAnswer(answerToUpdate, value) { + app.request({ + method: 'PATCH', + url: app.forum.attribute('apiUrl') + "/reflar/polls/answers/" + answerToUpdate.data.id, + data: { + answer: value, + user_id: this.pollCreator.id() + } + }); + this.answers.some(function (answer) { + if (answer.data.id === answerToUpdate.data.id) { + answer.data.attributes.answer = value; + return true; + } + }); + }; + + _proto.updateQuestion = function updateQuestion(question) { + if (question === '') { + alert(app.translator.trans('reflar-polls.forum.modal.include_question')); + this.question(''); + return; + } + + app.request({ + method: 'PATCH', + url: app.forum.attribute('apiUrl') + "/reflar/polls/" + this.props.poll.id(), + data: { + question: question, + user_id: this.pollCreator.id() + } + }); + this.question = m.prop(question); + m.redraw(); + }; + + return EditPollModal; +}(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2___default.a); + + + +/***/ }), + +/***/ "./src/forum/components/PollModal.js": +/*!*******************************************!*\ + !*** ./src/forum/components/PollModal.js ***! + \*******************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return PollModal; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/Modal */ "flarum/components/Modal"); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/components/Button */ "flarum/components/Button"); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Button__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/components/DiscussionComposer */ "flarum/components/DiscussionComposer"); +/* harmony import */ var flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var flarum_components_Switch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/components/Switch */ "flarum/components/Switch"); +/* harmony import */ var flarum_components_Switch__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Switch__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var DateTimePicker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! DateTimePicker */ "./node_modules/DateTimePicker/dist/DateTimePicker.min.js"); +/* harmony import */ var DateTimePicker__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(DateTimePicker__WEBPACK_IMPORTED_MODULE_6__); + + + + + + + + +var PollModal = +/*#__PURE__*/ +function (_Modal) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PollModal, _Modal); + + function PollModal() { + return _Modal.apply(this, arguments) || this; + } + + var _proto = PollModal.prototype; + + _proto.init = function init() { + _Modal.prototype.init.call(this); + + this.answer = []; + this.question = m.prop(''); + this.answer[0] = m.prop(''); + this.answer[1] = m.prop(''); + this.endDate = m.prop(); + this.publicPoll = m.prop(false); + + if (this.props.poll) { + var poll = this.props.poll; + this.answer = Object.values(poll.answers); + this.question(poll.question); + this.endDate(isNaN(poll.endDate) ? '' : this.getDateTime(poll.endDate)); + this.publicPoll(poll.publicPoll); + } + }; + + _proto.className = function className() { + return 'PollDiscussionModal Modal--small'; + }; + + _proto.getDateTime = function getDateTime(date) { + if (date === void 0) { + date = new Date(); + } + + if (isNaN(date)) { + date = new Date(); + } + + var checkTargets = [date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes()]; + checkTargets.forEach(function (target, i) { + if (target < 10) { + checkTargets[i] = "0" + target; + } + }); + return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]; + }; + + _proto.title = function title() { + return app.translator.trans('reflar-polls.forum.modal.add_title'); + }; + + _proto.config = function config() { + var _this = this; + + var oDTP1; + $('#dtBox').DateTimePicker({ + init: function init() { + oDTP1 = this; + }, + dateTimeFormat: "yyyy-MM-dd HH:mm", + minDateTime: this.getDateTime(), + settingValueOfElement: function settingValueOfElement(value) { + _this.endDate(value); + } + }); + }; + + _proto.content = function content() { + var _this2 = this; + + return [m("div", { + className: "Modal-body" + }, m("div", { + className: "PollDiscussionModal-form" + }, m("div", null, m("fieldset", null, m("input", { + type: "text", + name: "question", + className: "FormControl", + bidi: this.question, + placeholder: app.translator.trans('reflar-polls.forum.modal.question_placeholder') + }))), m("h4", null, app.translator.trans('reflar-polls.forum.modal.answers')), Object.keys(this.answer).map(function (el, i) { + return m("div", { + className: _this2.answer[i + 1] === '' ? 'Form-group hide' : 'Form-group' + }, m("fieldset", { + className: "Poll-answer-input" + }, m("input", { + className: "FormControl", + type: "text", + name: 'answer' + (i + 1), + bidi: _this2.answer[i], + placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (i + 1) + }), m("div", { + id: "dtBox" + })), i + 1 >= 3 ? flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + type: 'button', + className: 'Button Button--warning Poll-answer-button', + icon: 'fa fa-minus', + onclick: i + 1 >= 3 ? _this2.removeOption.bind(_this2, i) : '' + }) : '', m("div", { + className: "clear" + })); + }), flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + className: 'Button Button--primary PollModal-Button', + children: app.translator.trans('reflar-polls.forum.modal.add'), + onclick: this.addOption.bind(this) + }), m("div", { + className: "Form-group" + }, m("fieldset", { + style: "margin-bottom: 15px", + className: "Poll-answer-input" + }, m("input", { + style: "opacity: 1; color: inherit", + className: "FormControl", + type: "text", + "data-field": "datetime", + value: this.endDate() || app.translator.trans('reflar-polls.forum.modal.date_placeholder'), + id: "dtInput", + "data-min": this.getDateTime(), + readonly: true + })), m("div", { + className: "clear" + }), flarum_components_Switch__WEBPACK_IMPORTED_MODULE_5___default.a.component({ + state: this.publicPoll() || false, + children: app.translator.trans('reflar-polls.forum.modal.switch'), + onchange: this.publicPoll + }), m("div", { + className: "clear" + }), flarum_components_Button__WEBPACK_IMPORTED_MODULE_3___default.a.component({ + type: 'submit', + className: 'Button Button--primary PollModal-SubmitButton', + children: app.translator.trans('reflar-polls.forum.modal.submit') + }))))]; + }; + + _proto.addOption = function addOption() { + if (this.answer.length < 11) { + this.answer.push(m.prop('')); + } else { + alert(app.translator.trans('reflar-polls.forum.modal.max')); + } + }; + + _proto.removeOption = function removeOption(option) { + var _this3 = this; + + this.answer.forEach(function (answer, i) { + if (i === option) { + _this3.answer.splice(i, 1); + } + }); + }; + + _proto.objectSize = function objectSize(obj) { + var size = 0, + key; + + for (key in obj) { + if (obj[key] !== '') size++; + } + + return size; + }; + + _proto.onsubmit = function onsubmit(e) { + e.preventDefault(); + var pollArray = { + question: this.question(), + answers: {}, + endDate: new Date(this.endDate()), + publicPoll: this.publicPoll() + }; + + if (this.question() === '') { + alert(app.translator.trans('reflar-polls.forum.modal.include_question')); + return; + } // Add answers to PollArray + + + this.answer.map(function (answer, i) { + if (answer() !== '') { + pollArray['answers'][i] = answer; + } + }); + + if (this.objectSize(pollArray.answers) < 2) { + alert(app.translator.trans('reflar-polls.forum.modal.min')); + return; + } // Add data to DiscussionComposer post data + + + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_4___default.a.prototype, 'data', function (data) { + data.poll = pollArray; + }); + app.modal.close(); + m.redraw.strategy('none'); + }; + + return PollModal; +}(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_2___default.a); + + + +/***/ }), + +/***/ "./src/forum/components/PollVote.js": +/*!******************************************!*\ + !*** ./src/forum/components/PollVote.js ***! + \******************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return PollVote; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/Button */ "flarum/components/Button"); +/* harmony import */ var flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Button__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var flarum_Component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/Component */ "flarum/Component"); +/* harmony import */ var flarum_Component__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_Component__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var flarum_components_LogInModal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/components/LogInModal */ "flarum/components/LogInModal"); +/* harmony import */ var flarum_components_LogInModal__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_components_LogInModal__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _ShowVotersModal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShowVotersModal */ "./src/forum/components/ShowVotersModal.js"); + + + + + + + +var PollVote = +/*#__PURE__*/ +function (_Component) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PollVote, _Component); + + function PollVote() { + return _Component.apply(this, arguments) || this; + } + + var _proto = PollVote.prototype; + + _proto.init = function init() { + var _this = this; + + this.poll = this.props.poll; + this.votes = this.poll.votes(); + this.voted = m.prop(false); + this.user = app.session.user; + this.answers = []; + this.poll.answers().forEach(function (answer) { + _this.answers[answer.id()] = answer; + }); + + if (this.user !== undefined) { + if (!this.user.canVote()) { + this.voted(true); + } else { + app.store.find('reflar/polls/votes', { + poll_id: this.poll.id(), + user_id: this.user.id() + }).then(function (data) { + if (data[0] !== undefined) { + _this.voted(data[0]); + } else if (_this.poll.isEnded()) { + _this.voted(true); + } + + m.redraw(); + }); + } + } + }; + + _proto.showVoters = function showVoters() { + app.modal.show(new _ShowVotersModal__WEBPACK_IMPORTED_MODULE_5__["default"](this.poll)); + }; + + _proto.onError = function onError(el, error) { + el.srcElement.checked = false; + app.alerts.show(error.alert); + }; + + _proto.changeVote = function changeVote(answer, el) { + var _this2 = this; + + var oldVoteId = this.voted().id(); + var oldAnswerId = this.voted().option_id(); + app.request({ + method: 'PATCH', + url: app.forum.attribute('apiUrl') + "/reflar/polls/votes/" + answer.id(), + errorHandler: this.onError.bind(this, el), + data: { + option_id: answer.id(), + poll_id: this.poll.id() + } + }).then(function (response) { + _this2.answers[answer.id()].data.attributes.votes++; + _this2.answers[oldAnswerId].data.attributes.votes--; + + _this2.votes.some(function (vote, i) { + if (vote.data.id === oldVoteId) { + _this2.votes[i].data.attributes.option_id = response.data.attributes.option_id; + } + }); + + _this2.poll.data.relationships.votes.data.some(function (vote) { + if (typeof vote.id === "function") { + var id = vote.id(); + } else { + var id = vote.id; + } + + if (oldVoteId === parseInt(id)) { + vote.option_id = m.prop(response.data.attributes.option_id); + return true; + } + }); + + _this2.poll.votes = m.prop(_this2.votes); + m.redraw.strategy('all'); + m.redraw(); + }); + }; + + _proto.view = function view() { + var _this3 = this; + + if (this.voted() !== false) { + return m("div", null, m("h3", null, this.poll.question()), this.answers.map(function (item) { + var voted = false; + + if (_this3.voted() !== true) { + voted = parseInt(_this3.voted().option_id()) === item.data.attributes.id; + m.redraw(); + } + + var percent = Math.round(item.votes() / _this3.poll.votes().length * 100); + return m("div", { + className: "PollOption PollVoted" + }, m("div", { + title: item.votes() >= 1 ? item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.vote') : item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.votes'), + className: "PollBar", + "data-selected": voted, + config: function config(element) { + $(element).tooltip({ + placement: 'right' + }); + } + }, !_this3.poll.isEnded() && _this3.voted !== true ? m("label", { + className: "checkbox" + }, voted ? m("input", { + onchange: _this3.changeVote.bind(_this3, item), + type: "checkbox", + checked: true + }) : m("input", { + onchange: _this3.changeVote.bind(_this3, item), + type: "checkbox" + }), m("span", { + className: "checkmark" + })) : '', m("div", { + style: '--width: ' + percent + '%', + className: "PollOption-active" + }), m("label", { + style: !_this3.poll.isEnded() ? "margin-left: 25px" : '', + className: "PollAnswer" + }, m("span", null, item.answer())), m("label", null, m("span", { + className: percent !== 100 ? 'PollPercent PollPercent--option' : 'PollPercent' + }, percent, "%")))); + }), m("div", { + className: "clear" + }), this.poll.isPublic() ? flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default.a.component({ + className: 'Button Button--primary PublicPollButton', + children: app.translator.trans('reflar-polls.forum.public_poll'), + onclick: function onclick() { + app.modal.show(new _ShowVotersModal__WEBPACK_IMPORTED_MODULE_5__["default"]({ + votes: _this3.votes, + answers: _this3.answers + })); + } + }) : '', m("div", { + className: "clear" + }), !this.user.canVote() ? m("div", { + className: "helpText PollInfoText" + }, app.translator.trans('reflar-polls.forum.no_permission')) : this.poll.isEnded() ? m("div", { + className: "helpText PollInfoText" + }, app.translator.trans('reflar-polls.forum.poll_ended')) : !isNaN(new Date(this.poll.endDate())) ? m("div", { + className: "helpText PollInfoText" + }, m("i", { + class: "icon fa fa-clock-o" + }), " ", app.translator.trans('reflar-polls.forum.days_remaining', { + time: moment(this.poll.endDate()).fromNow() + })) : '', m("div", { + className: "clear" + })); + } else { + return m("div", null, m("h3", null, this.poll.question()), this.answers.map(function (item) { + return m("div", { + className: "PollOption" + }, m("div", { + className: "PollBar" + }, m("label", { + className: "checkbox" + }, m("input", { + type: "checkbox", + onchange: _this3.addVote.bind(_this3, item) + }), m("span", null, item.answer()), m("span", { + className: "checkmark" + })))); + }), m("div", { + className: "clear" + }), this.poll.isPublic() && app.session.user !== undefined ? flarum_components_Button__WEBPACK_IMPORTED_MODULE_2___default.a.component({ + className: 'Button Button--primary PublicPollButton', + children: app.translator.trans('reflar-polls.forum.public_poll'), + onclick: function onclick() { + app.modal.show(new _ShowVotersModal__WEBPACK_IMPORTED_MODULE_5__["default"](_this3.poll)); + } + }) : '', this.poll.isEnded() ? m("div", { + className: "helpText PollInfoText" + }, app.translator.trans('reflar-polls.forum.poll_ended')) : !isNaN(new Date(this.poll.endDate())) ? m("div", { + className: "helpText PollInfoText" + }, m("i", { + class: "icon fa fa-clock-o" + }), " ", app.translator.trans('reflar-polls.forum.days_remaining', { + time: moment(this.poll.endDate()).fromNow() + })) : ''); + } + }; + + _proto.addVote = function addVote(answer, el) { + var _this4 = this; + + if (this.user === undefined) { + app.modal.show(new flarum_components_LogInModal__WEBPACK_IMPORTED_MODULE_4___default.a()); + el.srcElement.checked = false; + } else { + app.store.createRecord('votes').save({ + poll_id: this.poll.id(), + option_id: answer.id() + }).then(function (vote) { + _this4.answers[answer.id()].data.attributes.votes++; + + _this4.voted(vote); + + _this4.poll.data.relationships.votes.data.push(vote); + + _this4.votes.push(vote); + + m.redraw(); + }); + } + }; + + return PollVote; +}(flarum_Component__WEBPACK_IMPORTED_MODULE_3___default.a); + + + +/***/ }), + +/***/ "./src/forum/components/ShowVotersModal.js": +/*!*************************************************!*\ + !*** ./src/forum/components/ShowVotersModal.js ***! + \*************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ShowVotersModal; }); +/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/components/Modal */ "flarum/components/Modal"); +/* harmony import */ var flarum_components_Modal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_utils_ItemList__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/utils/ItemList */ "flarum/utils/ItemList"); +/* harmony import */ var flarum_utils_ItemList__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_utils_ItemList__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var flarum_helpers_avatar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/helpers/avatar */ "flarum/helpers/avatar"); +/* harmony import */ var flarum_helpers_avatar__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_helpers_avatar__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var flarum_helpers_username__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/helpers/username */ "flarum/helpers/username"); +/* harmony import */ var flarum_helpers_username__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_helpers_username__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var flarum_helpers_listItems__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/helpers/listItems */ "flarum/helpers/listItems"); +/* harmony import */ var flarum_helpers_listItems__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_helpers_listItems__WEBPACK_IMPORTED_MODULE_5__); + + + + + + + +var ShowVotersModal = +/*#__PURE__*/ +function (_Modal) { + Object(_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(ShowVotersModal, _Modal); + + function ShowVotersModal() { + return _Modal.apply(this, arguments) || this; + } + + var _proto = ShowVotersModal.prototype; + + _proto.className = function className() { + return 'Modal--small'; + }; + + _proto.title = function title() { + return app.translator.trans('reflar-polls.forum.votes_modal.title'); + }; + + _proto.getUsers = function getUsers(answer) { + var votes = []; + + if (typeof this.props.votes === 'function') { + votes = this.props.votes(); + } else { + votes = this.props.votes; + } + + var items = new flarum_utils_ItemList__WEBPACK_IMPORTED_MODULE_2___default.a(); + var counter = 0; + votes.map(function (vote) { + var user = app.store.getById('users', vote.data.attributes.user_id); + + if (parseInt(answer.id()) === parseInt(vote.data.attributes.option_id)) { + counter++; + items.add(user.id(), m("a", { + href: app.route.user(user), + config: m.route + }, flarum_helpers_avatar__WEBPACK_IMPORTED_MODULE_3___default()(user), " ", ' ', flarum_helpers_username__WEBPACK_IMPORTED_MODULE_4___default()(user))); + } + }); + + if (counter === 0) { + items.add('none', m("h4", { + style: "color: #000" + }, app.translator.trans('reflar-polls.forum.modal.no_voters'))); + } + + return items; + }; + + _proto.content = function content() { + var _this = this; + + if (typeof this.props.answers === 'function') { + this.answers = this.props.answers(); + } else { + this.answers = this.props.answers; + } + + return m("div", { + className: "Modal-body" + }, m("ul", { + className: "VotesModal-list" + }, this.answers.map(function (answer) { + return m("div", null, m("h2", null, answer.answer() + ':'), flarum_helpers_listItems__WEBPACK_IMPORTED_MODULE_5___default()(_this.getUsers(answer).toArray())); + }))); + }; + + return ShowVotersModal; +}(flarum_components_Modal__WEBPACK_IMPORTED_MODULE_1___default.a); + + + +/***/ }), + +/***/ "./src/forum/index.js": +/*!****************************!*\ + !*** ./src/forum/index.js ***! + \****************************/ +/*! no exports provided */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var flarum_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/app */ "flarum/app"); +/* harmony import */ var flarum_app__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_app__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/extend */ "flarum/extend"); +/* harmony import */ var flarum_extend__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_extend__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/components/DiscussionComposer */ "flarum/components/DiscussionComposer"); +/* harmony import */ var flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/Model */ "flarum/Model"); +/* harmony import */ var flarum_Model__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_Model__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _common_models_Question__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/models/Question */ "./src/common/models/Question.js"); +/* harmony import */ var _common_models_Answer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/models/Answer */ "./src/common/models/Answer.js"); +/* harmony import */ var _common_models_Vote__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/models/Vote */ "./src/common/models/Vote.js"); +/* harmony import */ var flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! flarum/models/Discussion */ "flarum/models/Discussion"); +/* harmony import */ var flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var flarum_models_User__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! flarum/models/User */ "flarum/models/User"); +/* harmony import */ var flarum_models_User__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(flarum_models_User__WEBPACK_IMPORTED_MODULE_8__); +/* harmony import */ var _addPollBadge__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./addPollBadge */ "./src/forum/addPollBadge.js"); +/* harmony import */ var _PollControl__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./PollControl */ "./src/forum/PollControl.js"); +/* harmony import */ var _PollDiscussion__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./PollDiscussion */ "./src/forum/PollDiscussion.js"); +/* harmony import */ var _components_PollModal__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./components/PollModal */ "./src/forum/components/PollModal.js"); + + + + + + + + + + + + + +flarum_app__WEBPACK_IMPORTED_MODULE_0___default.a.initializers.add('reflar-polls', function (app) { + // Relationships + app.store.models.answers = _common_models_Answer__WEBPACK_IMPORTED_MODULE_5__["default"]; + app.store.models.questions = _common_models_Question__WEBPACK_IMPORTED_MODULE_4__["default"]; + app.store.models.votes = _common_models_Vote__WEBPACK_IMPORTED_MODULE_6__["default"]; + flarum_models_Discussion__WEBPACK_IMPORTED_MODULE_7___default.a.prototype.Poll = flarum_Model__WEBPACK_IMPORTED_MODULE_3___default.a.hasOne('Poll'); + flarum_models_User__WEBPACK_IMPORTED_MODULE_8___default.a.prototype.canEditPolls = flarum_Model__WEBPACK_IMPORTED_MODULE_3___default.a.attribute('canEditPolls'); + flarum_models_User__WEBPACK_IMPORTED_MODULE_8___default.a.prototype.canStartPolls = flarum_Model__WEBPACK_IMPORTED_MODULE_3___default.a.attribute('canStartPolls'); + flarum_models_User__WEBPACK_IMPORTED_MODULE_8___default.a.prototype.canSelfEditPolls = flarum_Model__WEBPACK_IMPORTED_MODULE_3___default.a.attribute('canSelfEditPolls'); + flarum_models_User__WEBPACK_IMPORTED_MODULE_8___default.a.prototype.canVote = flarum_Model__WEBPACK_IMPORTED_MODULE_3___default.a.attribute('canVote'); + + flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2___default.a.prototype.addPoll = function (data) { + app.modal.show(new _components_PollModal__WEBPACK_IMPORTED_MODULE_12__["default"](data)); + }; // Add button to DiscussionComposer header + + + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'headerItems', function (items) { + if (app.session.user.canStartPolls()) { + items.add('polls', m("a", { + className: "DiscussionComposer-poll", + onclick: this.addPoll.bind(this, this.data()) + }, this.data().poll ? m("span", { + className: "PollLabel" + }, app.translator.trans('reflar-polls.forum.composer_discussion.edit')) : m("span", { + className: "PollLabel" + }, app.translator.trans('reflar-polls.forum.composer_discussion.add_poll'))), 1); + } + }); + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'onsubmit', function () { + Object(flarum_extend__WEBPACK_IMPORTED_MODULE_1__["extend"])(flarum_components_DiscussionComposer__WEBPACK_IMPORTED_MODULE_2___default.a.prototype, 'data', function (data) { + data.poll = undefined; + }); + }); + Object(_addPollBadge__WEBPACK_IMPORTED_MODULE_9__["default"])(); + Object(_PollDiscussion__WEBPACK_IMPORTED_MODULE_11__["default"])(); + Object(_PollControl__WEBPACK_IMPORTED_MODULE_10__["default"])(); +}); + +/***/ }), + +/***/ "flarum/Component": +/*!**************************************************!*\ + !*** external "flarum.core.compat['Component']" ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['Component']; + +/***/ }), + +/***/ "flarum/Model": +/*!**********************************************!*\ + !*** external "flarum.core.compat['Model']" ***! + \**********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['Model']; + +/***/ }), + +/***/ "flarum/app": +/*!********************************************!*\ + !*** external "flarum.core.compat['app']" ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['app']; + +/***/ }), + +/***/ "flarum/components/Badge": +/*!*********************************************************!*\ + !*** external "flarum.core.compat['components/Badge']" ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/Badge']; + +/***/ }), + +/***/ "flarum/components/Button": +/*!**********************************************************!*\ + !*** external "flarum.core.compat['components/Button']" ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/Button']; + +/***/ }), + +/***/ "flarum/components/CommentPost": +/*!***************************************************************!*\ + !*** external "flarum.core.compat['components/CommentPost']" ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/CommentPost']; + +/***/ }), + +/***/ "flarum/components/DiscussionComposer": +/*!**********************************************************************!*\ + !*** external "flarum.core.compat['components/DiscussionComposer']" ***! + \**********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/DiscussionComposer']; + +/***/ }), + +/***/ "flarum/components/LogInModal": +/*!**************************************************************!*\ + !*** external "flarum.core.compat['components/LogInModal']" ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/LogInModal']; + +/***/ }), + +/***/ "flarum/components/Modal": +/*!*********************************************************!*\ + !*** external "flarum.core.compat['components/Modal']" ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/Modal']; + +/***/ }), + +/***/ "flarum/components/Switch": +/*!**********************************************************!*\ + !*** external "flarum.core.compat['components/Switch']" ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['components/Switch']; + +/***/ }), + +/***/ "flarum/extend": +/*!***********************************************!*\ + !*** external "flarum.core.compat['extend']" ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['extend']; + +/***/ }), + +/***/ "flarum/helpers/avatar": +/*!*******************************************************!*\ + !*** external "flarum.core.compat['helpers/avatar']" ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['helpers/avatar']; + +/***/ }), + +/***/ "flarum/helpers/listItems": +/*!**********************************************************!*\ + !*** external "flarum.core.compat['helpers/listItems']" ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['helpers/listItems']; + +/***/ }), + +/***/ "flarum/helpers/username": +/*!*********************************************************!*\ + !*** external "flarum.core.compat['helpers/username']" ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['helpers/username']; + +/***/ }), + +/***/ "flarum/models/Discussion": +/*!**********************************************************!*\ + !*** external "flarum.core.compat['models/Discussion']" ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['models/Discussion']; + +/***/ }), + +/***/ "flarum/models/User": +/*!****************************************************!*\ + !*** external "flarum.core.compat['models/User']" ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['models/User']; + +/***/ }), + +/***/ "flarum/utils/ItemList": +/*!*******************************************************!*\ + !*** external "flarum.core.compat['utils/ItemList']" ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['utils/ItemList']; + +/***/ }), + +/***/ "flarum/utils/PostControls": +/*!***********************************************************!*\ + !*** external "flarum.core.compat['utils/PostControls']" ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['utils/PostControls']; + +/***/ }), + +/***/ "flarum/utils/mixin": +/*!****************************************************!*\ + !*** external "flarum.core.compat['utils/mixin']" ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = flarum.core.compat['utils/mixin']; + +/***/ }), + +/***/ "jquery": +/*!*************************!*\ + !*** external "jQuery" ***! + \*************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +module.exports = jQuery; + +/***/ }) + +/******/ }); +//# sourceMappingURL=forum.js.map \ No newline at end of file diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map new file mode 100644 index 0000000..3ac0558 --- /dev/null +++ b/js/dist/forum.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://@reflar/polls/webpack/bootstrap","webpack://@reflar/polls/./forum.js","webpack://@reflar/polls/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@reflar/polls/./node_modules/DateTimePicker/dist/DateTimePicker.min.js","webpack://@reflar/polls/./src/common/models/Answer.js","webpack://@reflar/polls/./src/common/models/Question.js","webpack://@reflar/polls/./src/common/models/Vote.js","webpack://@reflar/polls/./src/forum/PollControl.js","webpack://@reflar/polls/./src/forum/PollDiscussion.js","webpack://@reflar/polls/./src/forum/addPollBadge.js","webpack://@reflar/polls/./src/forum/components/EditPollModal.js","webpack://@reflar/polls/./src/forum/components/PollModal.js","webpack://@reflar/polls/./src/forum/components/PollVote.js","webpack://@reflar/polls/./src/forum/components/ShowVotersModal.js","webpack://@reflar/polls/./src/forum/index.js","webpack://@reflar/polls/external \"flarum.core.compat['Component']\"","webpack://@reflar/polls/external \"flarum.core.compat['Model']\"","webpack://@reflar/polls/external \"flarum.core.compat['app']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/Badge']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/Button']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/CommentPost']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/DiscussionComposer']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/LogInModal']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/Modal']\"","webpack://@reflar/polls/external \"flarum.core.compat['components/Switch']\"","webpack://@reflar/polls/external \"flarum.core.compat['extend']\"","webpack://@reflar/polls/external \"flarum.core.compat['helpers/avatar']\"","webpack://@reflar/polls/external \"flarum.core.compat['helpers/listItems']\"","webpack://@reflar/polls/external \"flarum.core.compat['helpers/username']\"","webpack://@reflar/polls/external \"flarum.core.compat['models/Discussion']\"","webpack://@reflar/polls/external \"flarum.core.compat['models/User']\"","webpack://@reflar/polls/external \"flarum.core.compat['utils/ItemList']\"","webpack://@reflar/polls/external \"flarum.core.compat['utils/PostControls']\"","webpack://@reflar/polls/external \"flarum.core.compat['utils/mixin']\"","webpack://@reflar/polls/external \"jQuery\""],"names":["Answer","apiEndpoint","exists","data","id","mixin","Model","answer","attribute","votes","percent","Question","question","isEnded","endDate","isPublic","answers","hasMany","Vote","poll_id","user_id","option_id","extend","PostControls","items","post","discussion","poll","Poll","user","app","session","undefined","canEditPolls","canSelfEditPolls","number","add","m","Button","icon","className","onclick","modal","show","EditPollModal","translator","trans","confirm","request","url","forum","method","store","users","Object","keys","then","location","reload","CommentPost","prototype","content","props","isHidden","subtree","invalidate","push","PollVote","component","addPollBadge","Discussion","badges","Badge","type","label","init","prop","pollCreator","newAnswer","getDateTime","Date","title","date","isNaN","checkTargets","getMonth","getDate","getHours","getMinutes","forEach","target","i","getFullYear","config","isInitalized","oDTP1","$","DateTimePicker","dateTimeFormat","minDateTime","settingValueOfElement","value","withAttr","updateQuestion","bind","map","updateAnswer","removeOption","length","addAnswer","children","close","onhide","redraw","strategy","createRecord","save","alert","option","some","splice","answerToUpdate","attributes","Modal","PollModal","publicPoll","values","el","addOption","Switch","state","onchange","objectSize","obj","size","key","onsubmit","e","preventDefault","pollArray","DiscussionComposer","voted","canVote","find","showVoters","ShowVotersModal","onError","error","srcElement","checked","alerts","changeVote","oldVoteId","oldAnswerId","errorHandler","response","vote","relationships","parseInt","view","item","Math","round","element","tooltip","placement","time","moment","fromNow","addVote","LogInModal","Component","getUsers","ItemList","counter","getById","route","avatar","username","listItems","toArray","initializers","models","questions","hasOne","User","canStartPolls","addPoll","addPollBadege","PollDiscussion","PollControl"],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAA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b,CAAkB,IAAlB,EAAwB,KAAKrG,IAAL,EAAxB;AAAhD,SACK,KAAKA,IAAL,GAAYwB,IAAZ,GAEG;AAAM,iBAAS,EAAC;AAAhB,SAA6BG,GAAG,CAACe,UAAJ,CAAeC,KAAf,CAAqB,6CAArB,CAA7B,CAFH,GAIG;AAAM,iBAAS,EAAC;AAAhB,SAA6BhB,GAAG,CAACe,UAAJ,CAAeC,KAAf,CAAqB,iDAArB,CAA7B,CALR,CADJ,EAQW,CARX;AASH;AACJ,GAZK,CAAN;AAcAxB,8DAAM,CAACsH,2EAAkB,CAAChF,SAApB,EAA+B,UAA/B,EAA2C,YAAW;AACxDtC,gEAAM,CAACsH,2EAAkB,CAAChF,SAApB,EAA+B,MAA/B,EAAuC,UAAUzD,IAAV,EAAgB;AACzDA,UAAI,CAACwB,IAAL,GAAYK,SAAZ;AACH,KAFK,CAAN;AAGH,GAJK,CAAN;AAMA4J,+DAAa;AACbC,kEAAc;AACdC,+DAAW;AACd,CAzCD,E;;;;;;;;;;;ACjBA,iD;;;;;;;;;;;ACAA,6C;;;;;;;;;;;ACAA,2C;;;;;;;;;;;ACAA,wD;;;;;;;;;;;ACAA,yD;;;;;;;;;;;ACAA,8D;;;;;;;;;;;ACAA,qE;;;;;;;;;;;ACAA,6D;;;;;;;;;;;ACAA,wD;;;;;;;;;;;ACAA,yD;;;;;;;;;;;ACAA,8C;;;;;;;;;;;ACAA,sD;;;;;;;;;;;ACAA,yD;;;;;;;;;;;ACAA,wD;;;;;;;;;;;ACAA,yD;;;;;;;;;;;ACAA,mD;;;;;;;;;;;ACAA,sD;;;;;;;;;;;ACAA,0D;;;;;;;;;;;ACAA,mD;;;;;;;;;;;ACAA,wB","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./forum.js\");\n","/*\n * This file is part of Flarum.\n *\n * (c) Toby Zerner \n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport * from './src/common';\nexport * from './src/forum';","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","/* ----------------------------------------------------------------------------- \r\n\r\n jQuery DateTimePicker - Responsive flat design jQuery DateTime Picker plugin for Web & Mobile\r\n Version 0.1.38\r\n Copyright (c)2017 Lajpat Shah\r\n Contributors : https://github.com/nehakadam/DateTimePicker/contributors\r\n Repository : https://github.com/nehakadam/DateTimePicker\r\n Documentation : https://nehakadam.github.io/DateTimePicker\r\n\r\n ----------------------------------------------------------------------------- */\r\n\r\nObject.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),$.DateTimePicker=$.DateTimePicker||{name:\"DateTimePicker\",i18n:{},defaults:{mode:\"date\",defaultDate:null,dateSeparator:\"-\",timeSeparator:\":\",timeMeridiemSeparator:\" \",dateTimeSeparator:\" \",monthYearSeparator:\" \",dateTimeFormat:\"dd-MM-yyyy HH:mm\",dateFormat:\"dd-MM-yyyy\",timeFormat:\"HH:mm\",maxDate:null,minDate:null,maxTime:null,minTime:null,maxDateTime:null,minDateTime:null,shortDayNames:[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],fullDayNames:[\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\"],shortMonthNames:[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],fullMonthNames:[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"],labels:null,minuteInterval:1,roundOffMinutes:!0,secondsInterval:1,roundOffSeconds:!0,showHeader:!0,titleContentDate:\"Set Date\",titleContentTime:\"Set Time\",titleContentDateTime:\"Set Date & Time\",buttonsToDisplay:[\"HeaderCloseButton\",\"SetButton\",\"ClearButton\"],setButtonContent:\"Set\",clearButtonContent:\"Clear\",incrementButtonContent:\"+\",decrementButtonContent:\"-\",setValueInTextboxOnEveryClick:!1,readonlyInputs:!1,animationDuration:400,touchHoldInterval:300,captureTouchHold:!1,mouseHoldInterval:50,captureMouseHold:!1,isPopup:!0,parentElement:\"body\",isInline:!1,inputElement:null,language:\"\",init:null,addEventHandlers:null,beforeShow:null,afterShow:null,beforeHide:null,afterHide:null,buttonClicked:null,settingValueOfElement:null,formatHumanDate:null,parseDateTimeString:null,formatDateTimeString:null},dataObject:{dCurrentDate:new Date,iCurrentDay:0,iCurrentMonth:0,iCurrentYear:0,iCurrentHour:0,iCurrentMinutes:0,iCurrentSeconds:0,sCurrentMeridiem:\"\",iMaxNumberOfDays:0,sDateFormat:\"\",sTimeFormat:\"\",sDateTimeFormat:\"\",dMinValue:null,dMaxValue:null,sArrInputDateFormats:[],sArrInputTimeFormats:[],sArrInputDateTimeFormats:[],bArrMatchFormat:[],bDateMode:!1,bTimeMode:!1,bDateTimeMode:!1,oInputElement:null,iTabIndex:0,bElemFocused:!1,bIs12Hour:!1,sTouchButton:null,iTouchStart:null,oTimeInterval:null,bIsTouchDevice:\"ontouchstart\"in document.documentElement}},$.cf={_isValid:function(a){return void 0!==a&&null!==a&&\"\"!==a},_compare:function(a,b){var c=void 0!==a&&null!==a,d=void 0!==b&&null!==b;return!(!c||!d)&&a.toLowerCase()===b.toLowerCase()}},function(a){\"function\"==typeof define&&define.amd?define([\"jquery\"],a):\"object\"==typeof exports?module.exports=a(require(\"jquery\")):a(jQuery)}(function(a){\"use strict\";function b(b,c){this.element=b;var d=\"\";d=a.cf._isValid(c)&&a.cf._isValid(c.language)?c.language:a.DateTimePicker.defaults.language,this.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[d],c),this.options=c,this.oData=a.extend({},a.DateTimePicker.dataObject),this._defaults=a.DateTimePicker.defaults,this._name=a.DateTimePicker.name,this.init()}a.fn.DateTimePicker=function(c){var d,e,f=a(this).data(),g=f?Object.keys(f):[];if(\"string\"!=typeof c)return this.each(function(){a.removeData(this,\"plugin_DateTimePicker\"),a.data(this,\"plugin_DateTimePicker\")||a.data(this,\"plugin_DateTimePicker\",new b(this,c))});if(a.cf._isValid(f))if(\"destroy\"===c){if(g.length>0)for(d in g)if(e=g[d],e.search(\"plugin_DateTimePicker\")!==-1){a(document).unbind(\"click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker\"),a(this).children().remove(),a(this).removeData(),a(this).unbind(),a(this).removeClass(\"dtpicker-overlay dtpicker-mobile dtpicker-inline\"),f=f[e];break}}else if(\"object\"===c&&g.length>0)for(d in g)if(e=g[d],e.search(\"plugin_DateTimePicker\")!==-1)return f[e]},b.prototype={init:function(){var b=this;b._setDateFormatArray(),b._setTimeFormatArray(),b._setDateTimeFormatArray(),void 0!==a(b.element).data(\"parentelement\")&&(b.settings.parentElement=a(b.element).data(\"parentelement\")),b.settings.isPopup&&!b.settings.isInline&&(b._createPicker(),a(b.element).addClass(\"dtpicker-mobile\")),b.settings.isInline&&(b._createPicker(),b._showPicker(b.settings.inputElement)),b.settings.init&&b.settings.init.call(b),b._addEventHandlersForInput()},_setDateFormatArray:function(){var a=this;a.oData.sArrInputDateFormats=[];var b=\"\";b=\"dd\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"MM\"+a.settings.dateSeparator+\"dd\"+a.settings.dateSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"yyyy\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"dd\",a.oData.sArrInputDateFormats.push(b),b=\"dd\"+a.settings.dateSeparator+\"MMM\"+a.settings.dateSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"MM\"+a.settings.monthYearSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"MMM\"+a.settings.monthYearSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"MMMM\"+a.settings.monthYearSeparator+\"yyyy\",a.oData.sArrInputDateFormats.push(b),b=\"yyyy\"+a.settings.monthYearSeparator+\"MM\",a.oData.sArrInputDateFormats.push(b)},_setTimeFormatArray:function(){var a=this;a.oData.sArrInputTimeFormats=[];var b=\"\";b=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\"+a.settings.timeMeridiemSeparator+\"AA\",a.oData.sArrInputTimeFormats.push(b),b=\"HH\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\",a.oData.sArrInputTimeFormats.push(b),b=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeMeridiemSeparator+\"AA\",a.oData.sArrInputTimeFormats.push(b),b=\"HH\"+a.settings.timeSeparator+\"mm\",a.oData.sArrInputTimeFormats.push(b)},_setDateTimeFormatArray:function(){var a=this;a.oData.sArrInputDateTimeFormats=[];var b=\"\",c=\"\",d=\"\";b=\"dd\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"yyyy\",c=\"HH\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"MM\"+a.settings.dateSeparator+\"dd\"+a.settings.dateSeparator+\"yyyy\",c=\"HH\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"MM\"+a.settings.dateSeparator+\"dd\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"yyyy\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"dd\",c=\"HH\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"yyyy\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"dd\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MMM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MMM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeSeparator+\"ss\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"yyyy\",c=\"HH\"+a.settings.timeSeparator+\"mm\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"MM\"+a.settings.dateSeparator+\"dd\"+a.settings.dateSeparator+\"yyyy\",c=\"HH\"+a.settings.timeSeparator+\"mm\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"MM\"+a.settings.dateSeparator+\"dd\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"yyyy\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"dd\",c=\"HH\"+a.settings.timeSeparator+\"mm\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"yyyy\"+a.settings.dateSeparator+\"MM\"+a.settings.dateSeparator+\"dd\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MMM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b=\"dd\"+a.settings.dateSeparator+\"MMM\"+a.settings.dateSeparator+\"yyyy\",c=\"hh\"+a.settings.timeSeparator+\"mm\"+a.settings.timeMeridiemSeparator+\"AA\",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d)},_matchFormat:function(b,c){var d=this;d.oData.bArrMatchFormat=[],d.oData.bDateMode=!1,d.oData.bTimeMode=!1,d.oData.bDateTimeMode=!1;var e,f=[];for(b=a.cf._isValid(b)?b:d.settings.mode,a.cf._compare(b,\"date\")?(c=a.cf._isValid(c)?c:d.oData.sDateFormat,d.oData.bDateMode=!0,f=d.oData.sArrInputDateFormats):a.cf._compare(b,\"time\")?(c=a.cf._isValid(c)?c:d.oData.sTimeFormat,d.oData.bTimeMode=!0,f=d.oData.sArrInputTimeFormats):a.cf._compare(b,\"datetime\")&&(c=a.cf._isValid(c)?c:d.oData.sDateTimeFormat,d.oData.bDateTimeMode=!0,f=d.oData.sArrInputDateTimeFormats),e=0;e0&&d._matchFormat(b,c)},_createPicker:function(){var b=this;b.settings.isInline?a(b.element).addClass(\"dtpicker-inline\"):(a(b.element).addClass(\"dtpicker-overlay\"),a(\".dtpicker-overlay\").click(function(a){b._hidePicker(\"\")}));var c=\"\";c+=\"
\",c+=\"
\",c+=\"
\",c+=\"
\",c+=\"
\",c+=\"
\",c+=\"
\",c+=\"
\",a(b.element).html(c)},_addEventHandlersForInput:function(){var b=this;if(!b.settings.isInline){b.oData.oInputElement=null,a(b.settings.parentElement).find(\"input[type='date'], input[type='time'], input[type='datetime']\").each(function(){a(this).attr(\"data-field\",a(this).attr(\"type\")),a(this).attr(\"type\",\"text\")});var c=\"[data-field='date'], [data-field='time'], [data-field='datetime']\";a(b.settings.parentElement).off(\"focus\",c,b._inputFieldFocus).on(\"focus\",c,{obj:b},b._inputFieldFocus),a(b.settings.parentElement).off(\"click\",c,b._inputFieldClick).on(\"click\",c,{obj:b},b._inputFieldClick)}b.settings.addEventHandlers&&b.settings.addEventHandlers.call(b)},_inputFieldFocus:function(a){var b=a.data.obj;b.showDateTimePicker(this),b.oData.bMouseDown=!1},_inputFieldClick:function(b){var c=b.data.obj;a.cf._compare(a(this).prop(\"tagName\"),\"input\")||c.showDateTimePicker(this),b.stopPropagation()},getDateObjectForInputField:function(b){var c=this;if(a.cf._isValid(b)){var d,e=c._getValueOfElement(b),f=a(b).data(\"field\"),g=\"\";return a.cf._isValid(f)||(f=c.settings.mode),c.settings.formatDateTimeString?d=c.settings.parseDateTimeString.call(c,e,f,g,a(b)):(g=a(b).data(\"format\"),a.cf._isValid(g)||(a.cf._compare(f,\"date\")?g=c.settings.dateFormat:a.cf._compare(f,\"time\")?g=c.settings.timeFormat:a.cf._compare(f,\"datetime\")&&(g=c.settings.dateTimeFormat)),c._matchFormat(f,g),a.cf._compare(f,\"date\")?d=c._parseDate(e):a.cf._compare(f,\"time\")?d=c._parseTime(e):a.cf._compare(f,\"datetime\")&&(d=c._parseDateTime(e))),d}},setDateTimeStringInInputField:function(b,c){var d=this;c=c||d.oData.dCurrentDate;var e;a.cf._isValid(b)?(e=[],\"string\"==typeof b?e.push(b):\"object\"==typeof b&&(e=b)):e=a.cf._isValid(d.settings.parentElement)?a(d.settings.parentElement).find(\"[data-field='date'], [data-field='time'], [data-field='datetime']\"):a(\"[data-field='date'], [data-field='time'], [data-field='datetime']\"),e.each(function(){var b,e,f,g,h=this;b=a(h).data(\"field\"),a.cf._isValid(b)||(b=d.settings.mode),e=\"Custom\",f=!1,d.settings.formatDateTimeString||(e=a(h).data(\"format\"),a.cf._isValid(e)||(a.cf._compare(b,\"date\")?e=d.settings.dateFormat:a.cf._compare(b,\"time\")?e=d.settings.timeFormat:a.cf._compare(b,\"datetime\")&&(e=d.settings.dateTimeFormat)),f=d.getIs12Hour(b,e)),g=d._setOutput(b,e,f,c,h),d._setValueOfElement(g,a(h))})},getDateTimeStringInFormat:function(a,b,c){var d=this;return d._setOutput(a,b,d.getIs12Hour(a,b),c)},showDateTimePicker:function(a){var b=this;null!==b.oData.oInputElement?b.settings.isInline||b._hidePicker(0,a):b._showPicker(a)},_setButtonAction:function(a){var b=this;null!==b.oData.oInputElement&&(b._setValueOfElement(b._setOutput()),a?(b.settings.buttonClicked&&b.settings.buttonClicked.call(b,\"TAB\",b.oData.oInputElement),b.settings.isInline||b._hidePicker(0)):b.settings.isInline||b._hidePicker(\"\"))},_setOutput:function(b,c,d,e,f){var g=this;e=a.cf._isValid(e)?e:g.oData.dCurrentDate,d=d||g.oData.bIs12Hour;var h,i=g._setVariablesForDate(e,!0,!0),j=\"\",k=g._formatDate(i),l=g._formatTime(i),m=a.extend({},k,l),n=\"\",o=\"\",p=Function.length;return g.settings.formatDateTimeString?j=g.settings.formatDateTimeString.call(g,m,b,c,f):(g._setMatchFormat(p,b,c),g.oData.bDateMode?g.oData.bArrMatchFormat[0]?j=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[1]?j=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]?j=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:g.oData.bArrMatchFormat[3]?j=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]?j=m.MM+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[5]?j=m.monthShort+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[6]?j=m.month+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[7]&&(j=m.yyyy+g.settings.monthYearSeparator+m.MM):g.oData.bTimeMode?g.oData.bArrMatchFormat[0]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[1]?j=m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:g.oData.bArrMatchFormat[2]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[3]&&(j=m.HH+g.settings.timeSeparator+m.mm):g.oData.bDateTimeMode&&(g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[8]||g.oData.bArrMatchFormat[9]?n=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[10]||g.oData.bArrMatchFormat[11]?n=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[12]||g.oData.bArrMatchFormat[13]?n=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:(g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7]||g.oData.bArrMatchFormat[14]||g.oData.bArrMatchFormat[15])&&(n=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy),h=g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7],o=d?h?m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:h?m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:m.HH+g.settings.timeSeparator+m.mm,\"\"!==n&&\"\"!==o&&(j=n+g.settings.dateTimeSeparator+o)),g._setMatchFormat(p)),j},_clearButtonAction:function(){var a=this;null!==a.oData.oInputElement&&a._setValueOfElement(\"\"),a.settings.isInline||a._hidePicker(\"\")},_setOutputOnIncrementOrDecrement:function(){var b=this;a.cf._isValid(b.oData.oInputElement)&&b.settings.setValueInTextboxOnEveryClick&&b._setValueOfElement(b._setOutput())},_showPicker:function(b){var c=this;if(null===c.oData.oInputElement){c.oData.oInputElement=b,c.oData.iTabIndex=parseInt(a(b).attr(\"tabIndex\"));var d=a(b).data(\"field\")||\"\",e=a(b).data(\"min\")||\"\",f=a(b).data(\"max\")||\"\",g=a(b).data(\"format\")||\"\",h=a(b).data(\"view\")||\"\",i=a(b).data(\"startend\")||\"\",j=a(b).data(\"startendelem\")||\"\",k=c._getValueOfElement(b)||\"\";if(\"\"!==h&&(a.cf._compare(h,\"Popup\")?c.setIsPopup(!0):c.setIsPopup(!1)),!c.settings.isPopup&&!c.settings.isInline){c._createPicker();var l=a(c.oData.oInputElement).offset().top+a(c.oData.oInputElement).outerHeight(),m=a(c.oData.oInputElement).offset().left,n=a(c.oData.oInputElement).outerWidth();a(c.element).css({position:\"absolute\",top:l,left:m,width:n,height:\"auto\"})}c.settings.beforeShow&&c.settings.beforeShow.call(c,b),d=a.cf._isValid(d)?d:c.settings.mode,c.settings.mode=d,a.cf._isValid(g)||(a.cf._compare(d,\"date\")?g=c.settings.dateFormat:a.cf._compare(d,\"time\")?g=c.settings.timeFormat:a.cf._compare(d,\"datetime\")&&(g=c.settings.dateTimeFormat)),c._matchFormat(d,g),c.oData.dMinValue=null,c.oData.dMaxValue=null,c.oData.bIs12Hour=!1;var o,p,q,r,s,t,u,v;c.oData.bDateMode?(o=e||c.settings.minDate,p=f||c.settings.maxDate,c.oData.sDateFormat=g,a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDate(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDate(p)),\"\"!==i&&(a.cf._compare(i,\"start\")||a.cf._compare(i,\"end\"))&&\"\"!==j&&a(j).length>=1&&(q=c._getValueOfElement(a(j)),\"\"!==q&&(r=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,q,d,g,a(j)):c._parseDate(q),a.cf._compare(i,\"start\")?a.cf._isValid(p)?c._compareDates(r,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(r)):c.oData.dMaxValue=new Date(r):a.cf._compare(i,\"end\")&&(a.cf._isValid(o)?c._compareDates(r,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(r)):c.oData.dMinValue=new Date(r)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDate(k),c.oData.dCurrentDate.setHours(0),c.oData.dCurrentDate.setMinutes(0),c.oData.dCurrentDate.setSeconds(0)):c.oData.bTimeMode?(o=e||c.settings.minTime,p=f||c.settings.maxTime,c.oData.sTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseTime(o),a.cf._isValid(p)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?p=\"11:59:59 PM\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?p=\"23:59:59\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?p=\"11:59 PM\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(p=\"23:59\"),c.oData.dMaxValue=c._parseTime(p))),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseTime(p),a.cf._isValid(o)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?o=\"12:00:00 AM\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?o=\"00:00:00\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?o=\"12:00 AM\":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(o=\"00:00\"),c.oData.dMinValue=c._parseTime(o))),\"\"!==i&&(a.cf._compare(i,\"start\")||a.cf._compare(i,\"end\"))&&\"\"!==j&&a(j).length>=1&&(s=c._getValueOfElement(a(j)),\"\"!==s&&(c.settings.parseDateTimeString?r=c.settings.parseDateTimeString.call(c,s,d,g,a(j)):t=c._parseTime(s),a.cf._compare(i,\"start\")?(t.setMinutes(t.getMinutes()-1),a.cf._isValid(p)?2===c._compareTime(t,c.oData.dMaxValue)&&(c.oData.dMaxValue=new Date(t)):c.oData.dMaxValue=new Date(t)):a.cf._compare(i,\"end\")&&(t.setMinutes(t.getMinutes()+1),a.cf._isValid(o)?3===c._compareTime(t,c.oData.dMinValue)&&(c.oData.dMinValue=new Date(t)):c.oData.dMinValue=new Date(t)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseTime(k)):c.oData.bDateTimeMode&&(o=e||c.settings.minDateTime,p=f||c.settings.maxDateTime,c.oData.sDateTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDateTime(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDateTime(p)),\"\"!==i&&(a.cf._compare(i,\"start\")||a.cf._compare(i,\"end\"))&&\"\"!==j&&a(j).length>=1&&(u=c._getValueOfElement(a(j)),\"\"!==u&&(v=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,u,d,g,a(j)):c._parseDateTime(u),a.cf._compare(i,\"start\")?a.cf._isValid(p)?c._compareDateTime(v,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(v)):c.oData.dMaxValue=new Date(v):a.cf._compare(i,\"end\")&&(a.cf._isValid(o)?c._compareDateTime(v,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(v)):c.oData.dMinValue=new Date(v)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDateTime(k)),c._setVariablesForDate(),c._modifyPicker(),a(c.element).fadeIn(c.settings.animationDuration),c.settings.afterShow&&setTimeout(function(){c.settings.afterShow.call(c,b)},c.settings.animationDuration)}},_hidePicker:function(b,c){var d=this,e=d.oData.oInputElement;d.settings.beforeHide&&d.settings.beforeHide.call(d,e),a.cf._isValid(b)||(b=d.settings.animationDuration),a.cf._isValid(d.oData.oInputElement)&&(a(d.oData.oInputElement).blur(),d.oData.oInputElement=null),a(d.element).fadeOut(b),0===b?a(d.element).find(\".dtpicker-subcontent\").html(\"\"):setTimeout(function(){a(d.element).find(\".dtpicker-subcontent\").html(\"\")},b),a(document).unbind(\"click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker\"),d.settings.afterHide&&(0===b?d.settings.afterHide.call(d,e):setTimeout(function(){d.settings.afterHide.call(d,e)},b)),a.cf._isValid(c)&&d._showPicker(c)},_modifyPicker:function(){var b,c,d=this,e=[];d.oData.bDateMode?(b=d.settings.titleContentDate,c=3,d.oData.bArrMatchFormat[0]?e=[\"day\",\"month\",\"year\"]:d.oData.bArrMatchFormat[1]?e=[\"month\",\"day\",\"year\"]:d.oData.bArrMatchFormat[2]?e=[\"year\",\"month\",\"day\"]:d.oData.bArrMatchFormat[3]?e=[\"day\",\"month\",\"year\"]:d.oData.bArrMatchFormat[4]?(c=2,e=[\"month\",\"year\"]):d.oData.bArrMatchFormat[5]?(c=2,e=[\"month\",\"year\"]):d.oData.bArrMatchFormat[6]?(c=2,e=[\"month\",\"year\"]):d.oData.bArrMatchFormat[7]&&(c=2,e=[\"year\",\"month\"])):d.oData.bTimeMode?(b=d.settings.titleContentTime,d.oData.bArrMatchFormat[0]?(c=4,e=[\"hour\",\"minutes\",\"seconds\",\"meridiem\"]):d.oData.bArrMatchFormat[1]?(c=3,e=[\"hour\",\"minutes\",\"seconds\"]):d.oData.bArrMatchFormat[2]?(c=3,e=[\"hour\",\"minutes\",\"meridiem\"]):d.oData.bArrMatchFormat[3]&&(c=2,e=[\"hour\",\"minutes\"])):d.oData.bDateTimeMode&&(b=d.settings.titleContentDateTime,d.oData.bArrMatchFormat[0]?(c=6,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"seconds\"]):d.oData.bArrMatchFormat[1]?(c=7,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"seconds\",\"meridiem\"]):d.oData.bArrMatchFormat[2]?(c=6,e=[\"month\",\"day\",\"year\",\"hour\",\"minutes\",\"seconds\"]):d.oData.bArrMatchFormat[3]?(c=7,e=[\"month\",\"day\",\"year\",\"hour\",\"minutes\",\"seconds\",\"meridiem\"]):d.oData.bArrMatchFormat[4]?(c=6,e=[\"year\",\"month\",\"day\",\"hour\",\"minutes\",\"seconds\"]):d.oData.bArrMatchFormat[5]?(c=7,e=[\"year\",\"month\",\"day\",\"hour\",\"minutes\",\"seconds\",\"meridiem\"]):d.oData.bArrMatchFormat[6]?(c=6,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"seconds\"]):d.oData.bArrMatchFormat[7]?(c=7,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"seconds\",\"meridiem\"]):d.oData.bArrMatchFormat[8]?(c=5,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\"]):d.oData.bArrMatchFormat[9]?(c=6,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"meridiem\"]):d.oData.bArrMatchFormat[10]?(c=5,e=[\"month\",\"day\",\"year\",\"hour\",\"minutes\"]):d.oData.bArrMatchFormat[11]?(c=6,e=[\"month\",\"day\",\"year\",\"hour\",\"minutes\",\"meridiem\"]):d.oData.bArrMatchFormat[12]?(c=5,e=[\"year\",\"month\",\"day\",\"hour\",\"minutes\"]):d.oData.bArrMatchFormat[13]?(c=6,e=[\"year\",\"month\",\"day\",\"hour\",\"minutes\",\"meridiem\"]):d.oData.bArrMatchFormat[14]?(c=5,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\"]):d.oData.bArrMatchFormat[15]&&(c=6,e=[\"day\",\"month\",\"year\",\"hour\",\"minutes\",\"meridiem\"]));var f,g=\"dtpicker-comp\"+c,h=!1,i=!1,j=!1;for(f=0;f\",k+=\"
\"+b+\"
\",h&&(k+=\"×\"),k+=\"
\",k+=\"\");var l=\"\";for(l+=\"
\",f=0;f\",l+=\"
\",l+=\"\"+d.settings.incrementButtonContent+\"\",l+=d.settings.readonlyInputs?\"\":\"\",l+=\"\"+d.settings.decrementButtonContent+\"\",d.settings.labels&&(l+=\"
\"+d.settings.labels[m]+\"
\"),l+=\"
\",l+=\"
\"}l+=\"\";var n=\"\";n=i&&j?\" dtpicker-twoButtons\":\" dtpicker-singleButton\";var o=\"\";o+=\"\";var p=k+l+o;a(d.element).find(\".dtpicker-subcontent\").html(p),d._setCurrentDate(),d._addEventHandlersForPicker()},_addEventHandlersForPicker:function(){var b,c,d=this;if(d.settings.isInline||a(document).on(\"click.DateTimePicker\",function(a){d._hidePicker(\"\")}),a(document).on(\"keydown.DateTimePicker\",function(e){if(c=parseInt(e.keyCode?e.keyCode:e.which),!a(\".dtpicker-compValue\").is(\":focus\")&&9===c)return d._setButtonAction(!0),a(\"[tabIndex=\"+(d.oData.iTabIndex+1)+\"]\").focus(),!1;if(a(\".dtpicker-compValue\").is(\":focus\")){if(38===c)return b=a(\".dtpicker-compValue:focus\").parent().attr(\"class\"),d._incrementDecrementActionsUsingArrowAndMouse(b,\"inc\"),!1;if(40===c)return b=a(\".dtpicker-compValue:focus\").parent().attr(\"class\"),d._incrementDecrementActionsUsingArrowAndMouse(b,\"dec\"),!1}}),d.settings.isInline||a(document).on(\"keydown.DateTimePicker\",function(b){c=parseInt(b.keyCode?b.keyCode:b.which),a(\".dtpicker-compValue\").is(\":focus\")||9===c||d._hidePicker(\"\")}),a(\".dtpicker-cont *\").click(function(a){a.stopPropagation()}),d.settings.readonlyInputs||(a(\".dtpicker-compValue\").not(\".month .dtpicker-compValue, .meridiem .dtpicker-compValue\").keyup(function(){this.value=this.value.replace(/[^0-9\\.]/g,\"\")}),a(\".dtpicker-compValue\").focus(function(){d.oData.bElemFocused=!0,a(this).select()}),a(\".dtpicker-compValue\").blur(function(){d._getValuesFromInputBoxes(),d._setCurrentDate(),d.oData.bElemFocused=!1;var b=a(this).parent().parent();setTimeout(function(){b.is(\":last-child\")&&!d.oData.bElemFocused&&d._setButtonAction(!1)},50)}),a(\".dtpicker-compValue\").keyup(function(b){var c,d=a(this),e=d.val(),f=e.length;d.parent().hasClass(\"day\")||d.parent().hasClass(\"hour\")||d.parent().hasClass(\"minutes\")||d.parent().hasClass(\"meridiem\")?f>2&&(c=e.slice(0,2),d.val(c)):d.parent().hasClass(\"month\")?f>3&&(c=e.slice(0,3),d.val(c)):d.parent().hasClass(\"year\")&&f>4&&(c=e.slice(0,4),d.val(c)),9===parseInt(b.keyCode?b.keyCode:b.which)&&a(this).select()})),a(d.element).find(\".dtpicker-compValue\").on(\"mousewheel DOMMouseScroll onmousewheel\",function(c){if(a(\".dtpicker-compValue\").is(\":focus\")){var e=Math.max(-1,Math.min(1,c.originalEvent.wheelDelta));return e>0?(b=a(\".dtpicker-compValue:focus\").parent().attr(\"class\"),d._incrementDecrementActionsUsingArrowAndMouse(b,\"inc\")):(b=a(\".dtpicker-compValue:focus\").parent().attr(\"class\"),d._incrementDecrementActionsUsingArrowAndMouse(b,\"dec\")),!1}}),a(d.element).find(\".dtpicker-close\").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,\"CLOSE\",d.oData.oInputElement),d.settings.isInline||d._hidePicker(\"\")}),a(d.element).find(\".dtpicker-buttonSet\").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,\"SET\",d.oData.oInputElement),d._setButtonAction(!1)}),a(d.element).find(\".dtpicker-buttonClear\").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,\"CLEAR\",d.oData.oInputElement),d._clearButtonAction()}),d.settings.captureTouchHold||d.settings.captureMouseHold){var e=\"\";d.settings.captureTouchHold&&d.oData.bIsTouchDevice&&(e+=\"touchstart touchmove touchend \"),d.settings.captureMouseHold&&(e+=\"mousedown mouseup\"),a(\".dtpicker-cont *\").on(e,function(a){d._clearIntervalForTouchEvents()}),d._bindTouchEvents(\"day\"),d._bindTouchEvents(\"month\"),d._bindTouchEvents(\"year\"),d._bindTouchEvents(\"hour\"),d._bindTouchEvents(\"minutes\"),d._bindTouchEvents(\"seconds\")}else a(d.element).find(\".day .increment, .day .increment *\").click(function(a){d.oData.iCurrentDay++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".day .decrement, .day .decrement *\").click(function(a){d.oData.iCurrentDay--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".month .increment, .month .increment *\").click(function(a){d.oData.iCurrentMonth++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".month .decrement, .month .decrement *\").click(function(a){d.oData.iCurrentMonth--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".year .increment, .year .increment *\").click(function(a){d.oData.iCurrentYear++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".year .decrement, .year .decrement *\").click(function(a){d.oData.iCurrentYear--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".hour .increment, .hour .increment *\").click(function(a){d.oData.iCurrentHour++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".hour .decrement, .hour .decrement *\").click(function(a){d.oData.iCurrentHour--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".minutes .increment, .minutes .increment *\").click(function(a){d.oData.iCurrentMinutes+=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".minutes .decrement, .minutes .decrement *\").click(function(a){d.oData.iCurrentMinutes-=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".seconds .increment, .seconds .increment *\").click(function(a){d.oData.iCurrentSeconds+=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(\".seconds .decrement, .seconds .decrement *\").click(function(a){d.oData.iCurrentSeconds-=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()});a(d.element).find(\".meridiem .dtpicker-compButton, .meridiem .dtpicker-compButton *\").click(function(b){a.cf._compare(d.oData.sCurrentMeridiem,\"AM\")?(d.oData.sCurrentMeridiem=\"PM\",d.oData.iCurrentHour+=12):a.cf._compare(d.oData.sCurrentMeridiem,\"PM\")&&(d.oData.sCurrentMeridiem=\"AM\",d.oData.iCurrentHour-=12),d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()})},_adjustMinutes:function(a){var b=this;return b.settings.roundOffMinutes&&1!==b.settings.minuteInterval&&(a=a%b.settings.minuteInterval?a-a%b.settings.minuteInterval+b.settings.minuteInterval:a),a},_adjustSeconds:function(a){var b=this;return b.settings.roundOffSeconds&&1!==b.settings.secondsInterval&&(a=a%b.settings.secondsInterval?a-a%b.settings.secondsInterval+b.settings.secondsInterval:a),a},_getValueOfElement:function(b){var c=\"\";return c=a.cf._compare(a(b).prop(\"tagName\"),\"INPUT\")?a(b).val():a(b).html()},_setValueOfElement:function(b,c){var d=this;a.cf._isValid(c)||(c=a(d.oData.oInputElement)),a.cf._compare(c.prop(\"tagName\"),\"INPUT\")?c.val(b):c.html(b);var e=d.getDateObjectForInputField(c);return d.settings.settingValueOfElement&&d.settings.settingValueOfElement.call(d,b,e,c),c.change(),b},_bindTouchEvents:function(b){var c=this;a(c.element).find(\".\"+b+\" .increment, .\"+b+\" .increment *\").on(\"touchstart mousedown\",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(),\r\nc.oData.sTouchButton=b+\"-inc\",c._setIntervalForTouchEvents())}),a(c.element).find(\".\"+b+\" .increment, .\"+b+\" .increment *\").on(\"touchend mouseup\",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()}),a(c.element).find(\".\"+b+\" .decrement, .\"+b+\" .decrement *\").on(\"touchstart mousedown\",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(),c.oData.sTouchButton=b+\"-dec\",c._setIntervalForTouchEvents())}),a(c.element).find(\".\"+b+\" .decrement, .\"+b+\" .decrement *\").on(\"touchend mouseup\",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()})},_setIntervalForTouchEvents:function(){var b=this,c=b.oData.bIsTouchDevice?b.settings.touchHoldInterval:b.settings.mouseHoldInterval;if(!a.cf._isValid(b.oData.oTimeInterval)){var d;b.oData.oTimeInterval=setInterval(function(){d=(new Date).getTime()-b.oData.iTouchStart,d>c&&a.cf._isValid(b.oData.sTouchButton)&&(\"day-inc\"===b.oData.sTouchButton?b.oData.iCurrentDay++:\"day-dec\"===b.oData.sTouchButton?b.oData.iCurrentDay--:\"month-inc\"===b.oData.sTouchButton?b.oData.iCurrentMonth++:\"month-dec\"===b.oData.sTouchButton?b.oData.iCurrentMonth--:\"year-inc\"===b.oData.sTouchButton?b.oData.iCurrentYear++:\"year-dec\"===b.oData.sTouchButton?b.oData.iCurrentYear--:\"hour-inc\"===b.oData.sTouchButton?b.oData.iCurrentHour++:\"hour-dec\"===b.oData.sTouchButton?b.oData.iCurrentHour--:\"minute-inc\"===b.oData.sTouchButton?b.oData.iCurrentMinutes+=b.settings.minuteInterval:\"minute-dec\"===b.oData.sTouchButton?b.oData.iCurrentMinutes-=b.settings.minuteInterval:\"second-inc\"===b.oData.sTouchButton?b.oData.iCurrentSeconds+=b.settings.secondsInterval:\"second-dec\"===b.oData.sTouchButton&&(b.oData.iCurrentSeconds-=b.settings.secondsInterval),b._setCurrentDate(),b._setOutputOnIncrementOrDecrement(),b.oData.iTouchStart=(new Date).getTime())},c)}},_clearIntervalForTouchEvents:function(){var b=this;clearInterval(b.oData.oTimeInterval),a.cf._isValid(b.oData.sTouchButton)&&(b.oData.sTouchButton=null,b.oData.iTouchStart=0),b.oData.oTimeInterval=null},_incrementDecrementActionsUsingArrowAndMouse:function(a,b){var c=this;a.includes(\"day\")?\"inc\"===b?c.oData.iCurrentDay++:\"dec\"===b&&c.oData.iCurrentDay--:a.includes(\"month\")?\"inc\"===b?c.oData.iCurrentMonth++:\"dec\"===b&&c.oData.iCurrentMonth--:a.includes(\"year\")?\"inc\"===b?c.oData.iCurrentYear++:\"dec\"===b&&c.oData.iCurrentYear--:a.includes(\"hour\")?\"inc\"===b?c.oData.iCurrentHour++:\"dec\"===b&&c.oData.iCurrentHour--:a.includes(\"minutes\")?\"inc\"===b?c.oData.iCurrentMinutes+=c.settings.minuteInterval:\"dec\"===b&&(c.oData.iCurrentMinutes-=c.settings.minuteInterval):a.includes(\"seconds\")&&(\"inc\"===b?c.oData.iCurrentSeconds+=c.settings.secondsInterval:\"dec\"===b&&(c.oData.iCurrentSeconds-=c.settings.secondsInterval)),c._setCurrentDate(),c._setOutputOnIncrementOrDecrement()},_parseDate:function(b){var c=this,d=c.settings.defaultDate?new Date(c.settings.defaultDate):new Date,e=d.getDate(),f=d.getMonth(),g=d.getFullYear();if(a.cf._isValid(b))if(\"string\"==typeof b){var h;h=c.oData.bArrMatchFormat[4]||c.oData.bArrMatchFormat[5]||c.oData.bArrMatchFormat[6]?b.split(c.settings.monthYearSeparator):b.split(c.settings.dateSeparator),c.oData.bArrMatchFormat[0]?(e=parseInt(h[0]),f=parseInt(h[1]-1),g=parseInt(h[2])):c.oData.bArrMatchFormat[1]?(f=parseInt(h[0]-1),e=parseInt(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[2]?(g=parseInt(h[0]),f=parseInt(h[1]-1),e=parseInt(h[2])):c.oData.bArrMatchFormat[3]?(e=parseInt(h[0]),f=c._getShortMonthIndex(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[4]?(e=1,f=parseInt(h[0])-1,g=parseInt(h[1])):c.oData.bArrMatchFormat[5]?(e=1,f=c._getShortMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[6]?(e=1,f=c._getFullMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[7]&&(e=1,f=parseInt(h[1])-1,g=parseInt(h[0]))}else e=b.getDate(),f=b.getMonth(),g=b.getFullYear();return d=new Date(g,f,e,0,0,0,0)},_parseTime:function(b){var c,d,e,f=this,g=f.settings.defaultDate?new Date(f.settings.defaultDate):new Date,h=g.getDate(),i=g.getMonth(),j=g.getFullYear(),k=g.getHours(),l=g.getMinutes(),m=g.getSeconds(),n=f.oData.bArrMatchFormat[0]||f.oData.bArrMatchFormat[1];return m=n?f._adjustSeconds(m):0,a.cf._isValid(b)&&(\"string\"==typeof b?(f.oData.bIs12Hour&&(c=b.split(f.settings.timeMeridiemSeparator),b=c[0],d=c[1],a.cf._compare(d,\"AM\")||a.cf._compare(d,\"PM\")||(d=\"\")),e=b.split(f.settings.timeSeparator),k=parseInt(e[0]),l=parseInt(e[1]),n&&(m=parseInt(e[2]),m=f._adjustSeconds(m)),12===k&&a.cf._compare(d,\"AM\")?k=0:k<12&&a.cf._compare(d,\"PM\")&&(k+=12)):(k=b.getHours(),l=b.getMinutes(),n&&(m=b.getSeconds(),m=f._adjustSeconds(m)))),l=f._adjustMinutes(l),g=new Date(j,i,h,k,l,m,0)},_parseDateTime:function(b){var c,d,e,f,g,h=this,i=h.settings.defaultDate?new Date(h.settings.defaultDate):new Date,j=i.getDate(),k=i.getMonth(),l=i.getFullYear(),m=i.getHours(),n=i.getMinutes(),o=i.getSeconds(),p=\"\",q=h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7];return o=q?h._adjustSeconds(o):0,a.cf._isValid(b)&&(\"string\"==typeof b?(c=b.split(h.settings.dateTimeSeparator),d=c[0].split(h.settings.dateSeparator),h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[8]||h.oData.bArrMatchFormat[9]?(j=parseInt(d[0]),k=parseInt(d[1]-1),l=parseInt(d[2])):h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[10]||h.oData.bArrMatchFormat[11]?(k=parseInt(d[0]-1),j=parseInt(d[1]),l=parseInt(d[2])):h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[12]||h.oData.bArrMatchFormat[13]?(l=parseInt(d[0]),k=parseInt(d[1]-1),j=parseInt(d[2])):(h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7]||h.oData.bArrMatchFormat[14]||h.oData.bArrMatchFormat[15])&&(j=parseInt(d[0]),k=h._getShortMonthIndex(d[1]),l=parseInt(d[2])),e=c[1],a.cf._isValid(e)&&(h.oData.bIs12Hour&&(a.cf._compare(h.settings.dateTimeSeparator,h.settings.timeMeridiemSeparator)&&3===c.length?p=c[2]:(f=e.split(h.settings.timeMeridiemSeparator),e=f[0],p=f[1]),a.cf._compare(p,\"AM\")||a.cf._compare(p,\"PM\")||(p=\"\")),g=e.split(h.settings.timeSeparator),m=parseInt(g[0]),n=parseInt(g[1]),q&&(o=parseInt(g[2])),12===m&&a.cf._compare(p,\"AM\")?m=0:m<12&&a.cf._compare(p,\"PM\")&&(m+=12))):(j=b.getDate(),k=b.getMonth(),l=b.getFullYear(),m=b.getHours(),n=b.getMinutes(),q&&(o=b.getSeconds(),o=h._adjustSeconds(o)))),n=h._adjustMinutes(n),i=new Date(l,k,j,m,n,o,0)},_getShortMonthIndex:function(b){for(var c=this,d=0;d1&&(c=c.charAt(0).toUpperCase()+c.slice(1)),d=b.settings.shortMonthNames.indexOf(c),d!==-1?b.oData.iCurrentMonth=parseInt(d):c.match(\"^[+|-]?[0-9]+$\")&&(b.oData.iCurrentMonth=parseInt(c-1)),b.oData.iCurrentDay=parseInt(a(b.element).find(\".day .dtpicker-compValue\").val())||b.oData.iCurrentDay,b.oData.iCurrentYear=parseInt(a(b.element).find(\".year .dtpicker-compValue\").val())||b.oData.iCurrentYear}if(b.oData.bTimeMode||b.oData.bDateTimeMode){var e,f,g,h;e=parseInt(a(b.element).find(\".hour .dtpicker-compValue\").val()),f=b._adjustMinutes(parseInt(a(b.element).find(\".minutes .dtpicker-compValue\").val())),g=b._adjustMinutes(parseInt(a(b.element).find(\".seconds .dtpicker-compValue\").val())),b.oData.iCurrentHour=isNaN(e)?b.oData.iCurrentHour:e,b.oData.iCurrentMinutes=isNaN(f)?b.oData.iCurrentMinutes:f,b.oData.iCurrentSeconds=isNaN(g)?b.oData.iCurrentSeconds:g,b.oData.iCurrentSeconds>59&&(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60),b.oData.iCurrentMinutes>59&&(b.oData.iCurrentHour+=b.oData.iCurrentMinutes/60,b.oData.iCurrentMinutes=b.oData.iCurrentMinutes%60),b.oData.bIs12Hour?b.oData.iCurrentHour>12&&(b.oData.iCurrentHour=b.oData.iCurrentHour%12):b.oData.iCurrentHour>23&&(b.oData.iCurrentHour=b.oData.iCurrentHour%23),b.oData.bIs12Hour&&(h=a(b.element).find(\".meridiem .dtpicker-compValue\").val(),(a.cf._compare(h,\"AM\")||a.cf._compare(h,\"PM\"))&&(b.oData.sCurrentMeridiem=h),a.cf._compare(b.oData.sCurrentMeridiem,\"PM\")&&12!==b.oData.iCurrentHour&&b.oData.iCurrentHour<13&&(b.oData.iCurrentHour+=12),a.cf._compare(b.oData.sCurrentMeridiem,\"AM\")&&12===b.oData.iCurrentHour&&(b.oData.iCurrentHour=0))}},_setCurrentDate:function(){var b=this;(b.oData.bTimeMode||b.oData.bDateTimeMode)&&(b.oData.iCurrentSeconds>59?(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60):b.oData.iCurrentSeconds<0&&(b.oData.iCurrentMinutes-=b.settings.minuteInterval,b.oData.iCurrentSeconds+=60),b.oData.iCurrentMinutes=b._adjustMinutes(b.oData.iCurrentMinutes),b.oData.iCurrentSeconds=b._adjustSeconds(b.oData.iCurrentSeconds));var c,d,e,f,g,h,i,j=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),k=!1,l=!1;if(null!==b.oData.dMaxValue&&(k=j.getTime()>b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(l=j.getTime()b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(n=b.oData.dCurrentDate.getTime()12&&(e-=12),\"00\"===g&&(e=12),f=e<10?\"0\"+e:e,j.oData.bIs12Hour&&(g=f),h=k.iCurrentMinutes,h=h<10?\"0\"+h:h,i=k.iCurrentSeconds,i=i<10?\"0\"+i:i,{H:c,HH:d,h:e,hh:f,hour:g,m:k.iCurrentMinutes,mm:h,s:k.iCurrentSeconds,ss:i,ME:k.sCurrentMeridiem}},_setButtons:function(){var b=this;a(b.element).find(\".dtpicker-compButton\").removeClass(\"dtpicker-compButtonDisable\").addClass(\"dtpicker-compButtonEnable\");var c;if(null!==b.oData.dMaxValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour+1>b.oData.dMaxValue.getHours()||b.oData.iCurrentHour+1===b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes>b.oData.dMaxValue.getMinutes())&&a(b.element).find(\".hour .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),b.oData.iCurrentHour>=b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes+1>b.oData.dMaxValue.getMinutes()&&a(b.element).find(\".minutes .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\")):(c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay+1,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".day .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth+1,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".month .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),c=new Date(b.oData.iCurrentYear+1,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".year .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour+1,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".hour .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes+1,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".minutes .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds+1,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".seconds .increment\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\"))),null!==b.oData.dMinValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour-1b.oData.dMaxValue.getHours()||d===b.oData.dMaxValue.getHours()&&e>b.oData.dMaxValue.getMinutes())&&a(b.element).find(\".meridiem .dtpicker-compButton\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\")):c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(\".meridiem .dtpicker-compButton\").removeClass(\"dtpicker-compButtonEnable\").addClass(\"dtpicker-compButtonDisable\")),null!==b.oData.dMinValue&&(b.oData.bTimeMode?(e=b.oData.iCurrentMinutes,(db.getHours()?c=3:a.getHours()===b.getHours()&&(a.getMinutes()b.getMinutes()&&(c=3)),c},_compareDateTime:function(a,b){var c=(a.getTime()-b.getTime())/6e4;return 0===c?c:c/Math.abs(c)},_determineMeridiemFromHourAndMinutes:function(a,b){return a>12||12===a&&b>=0?\"PM\":\"AM\"},setLanguage:function(b){var c=this;return c.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[b],c.options),c.settings.language=b,c._setDateFormatArray(),c._setTimeFormatArray(),c._setDateTimeFormatArray(),c}}});","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class Answer extends mixin(Model, {\n answer: Model.attribute('answer'),\n votes: Model.attribute('votes'),\n percent: Model.attribute('percent')\n}) {\n apiEndpoint() {\n return `/reflar/polls/answers${this.exists ? `/${this.data.id}` : ''}`;\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class Question extends mixin(Model, {\n question: Model.attribute('question'),\n isEnded: Model.attribute('isEnded'),\n endDate: Model.attribute('endDate'),\n isPublic: Model.attribute('isPublic'),\n\n answers: Model.hasMany('answers'),\n votes: Model.hasMany('votes'),\n}) {\n apiEndpoint() {\n return `/reflar/polls${this.exists ? `/${this.data.id}` : ''}`;\n }\n}\n","import Model from 'flarum/Model';\nimport mixin from 'flarum/utils/mixin';\n\nexport default class Vote extends mixin(Model, {\n poll_id: Model.attribute('poll_id'),\n user_id: Model.attribute('user_id'),\n option_id: Model.attribute('option_id'),\n}) {\n apiEndpoint() {\n return `/reflar/polls/votes${this.exists ? `/${this.data.id}` : ''}`;\n }\n}\n","import {extend} from 'flarum/extend';\n\nimport PostControls from 'flarum/utils/PostControls';\nimport Button from 'flarum/components/Button';\nimport EditPollModal from './components/EditPollModal';\n\nexport default function () {\n extend(PostControls, 'moderationControls', function (items, post) {\n const discussion = post.discussion();\n const poll = discussion.Poll();\n const user = app.session.user\n\n if (discussion.Poll() && ((user !== undefined && user.canEditPolls()) || (post.user().canSelfEditPolls()) && post.user().id() === user.id()) && post.number() === 1) {\n if (!poll.isEnded()) {\n items.add('editPoll', [\n m(Button, {\n icon: 'fa fa-check-square',\n className: 'reflar-PollButton',\n onclick: () => {\n app.modal.show(new EditPollModal({post: post, poll: poll}));\n }\n }, app.translator.trans('reflar-polls.forum.moderation.edit'))\n ]);\n }\n\n items.add('removePoll', [\n m(Button, {\n icon: 'fa fa-trash',\n className: 'reflar-PollButton',\n onclick: () => {\n\n if (confirm(app.translator.trans('reflar-polls.forum.moderation.delete_confirm'))) {\n app.request({\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/${poll.id()}`,\n method: 'DELETE',\n data: poll.store.data.users[Object.keys(poll.store.data.users)[0]].id()\n }).then(() => {\n location.reload()\n })\n }\n }\n }, app.translator.trans('reflar-polls.forum.moderation.delete'))\n ]);\n }\n });\n}\n","import { extend, override } from 'flarum/extend';\n\nimport CommentPost from 'flarum/components/CommentPost';\nimport PollVote from './components/PollVote';\n\nexport default function() {\n extend(CommentPost.prototype, 'content', function(content) {\n const discussion = this.props.post.discussion();\n\n if (discussion.Poll() && this.props.post.number() === 1 && !this.props.post.isHidden()) {\n this.subtree.invalidate();\n \n content.push(PollVote.component({\n poll: discussion.Poll()\n }));\n }\n });\n}\n","import { extend } from 'flarum/extend';\nimport Discussion from 'flarum/models/Discussion';\nimport Badge from 'flarum/components/Badge';\n\nexport default function addPollBadge() {\n extend(Discussion.prototype, 'badges', function(badges) {\n if (this.Poll()) {\n badges.add('poll', Badge.component({\n type: 'poll',\n label: app.translator.trans('reflar-polls.forum.tooltip.badge'),\n icon: 'fa fa-signal'\n }), 5);\n }\n });\n}","import {extend, override} from 'flarum/extend';\nimport Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\n\nexport default class EditPollModal extends Modal {\n init() {\n super.init();\n this.answers = this.props.poll.answers();\n\n this.question = m.prop(this.props.poll.question());\n\n this.pollCreator = this.props.poll.store.data.users[Object.keys(this.props.poll.store.data.users)[0]]\n\n this.newAnswer = m.prop('')\n\n this.endDate = m.prop(this.props.poll.endDate() === ' UTC' ? '' : this.getDateTime(new Date(this.props.poll.endDate())))\n }\n\n className() {\n return 'PollDiscussionModal Modal--small';\n }\n\n title() {\n return app.translator.trans('reflar-polls.forum.modal.edit_title');\n }\n\n getDateTime(date = new Date()) {\n if (isNaN(date)) {\n date = new Date()\n }\n var checkTargets = [\n date.getMonth() + 1,\n date.getDate(),\n date.getHours(),\n date.getMinutes()\n ];\n\n checkTargets.forEach((target, i) => {\n if (target < 10) {\n checkTargets[i] = \"0\" + target;\n }\n })\n\n return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]\n }\n\n config(isInitalized) {\n if (isInitalized) return;\n\n var oDTP1;\n\n $('#dtBox').DateTimePicker({\n init: function () {\n oDTP1 = this;\n },\n dateTimeFormat: \"yyyy-MM-dd HH:mm\",\n minDateTime: this.getDateTime(),\n settingValueOfElement: (value) => {\n this.endDate(value);\n\n app.request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/${this.props.poll.id()}/endDate`,\n data: {\n date: new Date(value),\n user_id: this.pollCreator.id()\n }\n });\n }\n });\n }\n\n content() {\n return [\n
\n
\n
\n
\n \n
\n
\n\n

{app.translator.trans('reflar-polls.forum.modal.answers')}

\n\n {\n this.answers.map((answer, i) => (\n
\n
\n \n
\n {i + 1 >= 3 ?\n Button.component({\n type: 'button',\n className: 'Button Button--warning Poll-answer-button',\n icon: 'fa fa-minus',\n onclick: i + 1 >= 3 ? this.removeOption.bind(this, answer) : ''\n }) : ''}\n
\n
\n ))\n }\n
\n
\n \n
\n {Button.component({\n type: 'button',\n className: 'Button Button--warning Poll-answer-button',\n icon: 'fa fa-plus',\n onclick: this.addAnswer.bind(this)\n })}\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n {Button.component({\n className: 'Button Button--primary PollModal-SubmitButton',\n children: app.translator.trans('reflar-polls.forum.modal.submit'),\n onclick: () => {\n app.modal.close()\n }\n })}\n
\n ];\n }\n\n\n onhide() {\n this.props.poll.answers = m.prop(this.answers)\n this.props.poll.question = this.question\n if (this.endDate() !== '') {\n this.props.poll.endDate = this.endDate\n }\n m.redraw.strategy('all')\n }\n\n addAnswer(answer) {\n var data = {\n answer: this.newAnswer(),\n poll_id: this.props.poll.id(),\n user_id: this.pollCreator.id()\n }\n if (this.answers.length < 10) {\n app.store.createRecord('answers').save(data).then(\n answer => {\n this.answers.push(answer);\n\n this.newAnswer('');\n m.redraw.strategy('all')\n m.redraw();\n }\n );\n } else {\n alert(app.translator.trans('reflar-polls.forum.modal.max'))\n }\n }\n\n\n removeOption(option) {\n app.request({\n method: 'DELETE',\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/answers/${option.data.id}`,\n data: this.pollCreator.id()\n });\n this.answers.some((answer, i) => {\n if (answer.data.id === option.data.id) {\n this.answers.splice(i, 1);\n return true;\n }\n })\n }\n\n updateAnswer(answerToUpdate, value) {\n app.request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/answers/${answerToUpdate.data.id}`,\n data: {\n answer: value,\n user_id: this.pollCreator.id()\n }\n });\n this.answers.some((answer) => {\n if (answer.data.id === answerToUpdate.data.id) {\n answer.data.attributes.answer = value;\n return true;\n }\n })\n }\n\n updateQuestion(question) {\n if (question === '') {\n alert(app.translator.trans('reflar-polls.forum.modal.include_question'))\n this.question('')\n return\n }\n app.request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/${this.props.poll.id()}`,\n data: {\n question: question,\n user_id: this.pollCreator.id()\n }\n });\n this.question = m.prop(question)\n m.redraw()\n }\n}\n","import {extend} from 'flarum/extend';\nimport Modal from 'flarum/components/Modal';\nimport Button from 'flarum/components/Button';\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\nimport Switch from \"flarum/components/Switch\";\nimport DateTimePicker from \"DateTimePicker\";\n\nexport default class PollModal extends Modal {\n init() {\n super.init();\n this.answer = [];\n\n this.question = m.prop('');\n this.answer[0] = m.prop('');\n this.answer[1] = m.prop('');\n\n this.endDate = m.prop();\n this.publicPoll = m.prop(false);\n\n if (this.props.poll) {\n var poll = this.props.poll\n this.answer = Object.values(poll.answers)\n this.question(poll.question)\n this.endDate(isNaN(poll.endDate) ? '' : this.getDateTime(poll.endDate))\n this.publicPoll(poll.publicPoll)\n }\n }\n\n className() {\n return 'PollDiscussionModal Modal--small';\n }\n\n getDateTime(date = new Date()) {\n if (isNaN(date)) {\n date = new Date()\n }\n var checkTargets = [\n date.getMonth() + 1,\n date.getDate(),\n date.getHours(),\n date.getMinutes()\n ];\n\n checkTargets.forEach((target, i) => {\n if (target < 10) {\n checkTargets[i] = \"0\" + target;\n }\n })\n\n return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]\n }\n\n title() {\n return app.translator.trans('reflar-polls.forum.modal.add_title');\n }\n\n config() {\n var oDTP1;\n\n $('#dtBox').DateTimePicker({\n init: function () {\n oDTP1 = this;\n },\n dateTimeFormat: \"yyyy-MM-dd HH:mm\",\n minDateTime: this.getDateTime(),\n settingValueOfElement: (value) => {\n this.endDate(value)\n }\n });\n }\n\n content() {\n return [\n
\n
\n
\n
\n \n
\n
\n\n

{app.translator.trans('reflar-polls.forum.modal.answers')}

\n\n {\n Object.keys(this.answer).map((el, i) => (\n
\n
\n \n
\n
\n {i + 1 >= 3 ?\n Button.component({\n type: 'button',\n className: 'Button Button--warning Poll-answer-button',\n icon: 'fa fa-minus',\n onclick: i + 1 >= 3 ? this.removeOption.bind(this, i) : ''\n }) : ''}\n
\n
\n ))\n }\n\n {Button.component({\n className: 'Button Button--primary PollModal-Button',\n children: app.translator.trans('reflar-polls.forum.modal.add'),\n onclick: this.addOption.bind(this)\n })}\n\n
\n
\n \n
\n
\n {Switch.component({\n state: this.publicPoll() || false,\n children: app.translator.trans('reflar-polls.forum.modal.switch'),\n onchange: this.publicPoll\n })}\n
\n {\n Button.component({\n type: 'submit',\n className: 'Button Button--primary PollModal-SubmitButton',\n children: app.translator.trans('reflar-polls.forum.modal.submit')\n })\n }\n
\n
\n
\n ];\n }\n\n addOption() {\n if (this.answer.length < 11) {\n this.answer.push(m.prop(''));\n } else {\n alert(app.translator.trans('reflar-polls.forum.modal.max'))\n }\n }\n\n removeOption(option) {\n this.answer.forEach((answer, i) => {\n if (i === option) {\n this.answer.splice(i, 1)\n }\n })\n }\n\n objectSize(obj) {\n var size = 0, key;\n for (key in obj) {\n if (obj[key] !== '') size++;\n }\n return size;\n }\n\n onsubmit(e) {\n e.preventDefault();\n let pollArray = {\n question: this.question(),\n answers: {},\n endDate: new Date(this.endDate()),\n publicPoll: this.publicPoll()\n };\n\n if (this.question() === '') {\n alert(app.translator.trans('reflar-polls.forum.modal.include_question'))\n return\n }\n\n // Add answers to PollArray\n this.answer.map((answer, i) => {\n if (answer() !== '') {\n pollArray['answers'][i] = answer\n }\n });\n\n if (this.objectSize(pollArray.answers) < 2) {\n alert(app.translator.trans('reflar-polls.forum.modal.min'))\n return\n }\n\n // Add data to DiscussionComposer post data\n extend(DiscussionComposer.prototype, 'data', function (data) {\n data.poll = pollArray;\n });\n\n app.modal.close();\n\n m.redraw.strategy('none');\n }\n}","import {extend} from 'flarum/extend';\nimport Button from 'flarum/components/Button';\nimport Component from 'flarum/Component';\nimport LogInModal from 'flarum/components/LogInModal';\n\nimport ShowVotersModal from './ShowVotersModal';\n\nexport default class PollVote extends Component {\n init() {\n this.poll = this.props.poll;\n this.votes = this.poll.votes();\n this.voted = m.prop(false);\n this.user = app.session.user;\n this.answers = []\n\n this.poll.answers().forEach(answer => {\n this.answers[answer.id()] = answer;\n })\n\n if (this.user !== undefined) {\n if (!this.user.canVote()) {\n this.voted(true)\n } else {\n app.store.find('reflar/polls/votes', {\n poll_id: this.poll.id(),\n user_id: this.user.id()\n }).then((data) => {\n if (data[0] !== undefined) {\n this.voted(data[0])\n } else if (this.poll.isEnded()) {\n this.voted(true)\n }\n\n m.redraw();\n });\n }\n }\n\n }\n\n showVoters() {\n app.modal.show(new ShowVotersModal(this.poll))\n }\n\n onError(el, error) {\n el.srcElement.checked = false\n\n app.alerts.show(error.alert)\n }\n\n changeVote(answer, el) {\n var oldVoteId = this.voted().id()\n var oldAnswerId = this.voted().option_id()\n app.request({\n method: 'PATCH',\n url: `${app.forum.attribute('apiUrl')}/reflar/polls/votes/${answer.id()}`,\n errorHandler: this.onError.bind(this, el),\n data: {\n option_id: answer.id(),\n poll_id: this.poll.id()\n }\n }).then(\n response => {\n this.answers[answer.id()].data.attributes.votes++;\n this.answers[oldAnswerId].data.attributes.votes--;\n this.votes.some((vote, i) => {\n if (vote.data.id === oldVoteId) {\n this.votes[i].data.attributes.option_id = response.data.attributes.option_id\n }\n })\n this.poll.data.relationships.votes.data.some(vote => {\n if (typeof vote.id === \"function\") {\n var id = vote.id()\n } else {\n var id = vote.id\n }\n if (oldVoteId === parseInt(id)) {\n vote.option_id = m.prop(response.data.attributes.option_id);\n return true;\n }\n })\n this.poll.votes = m.prop(this.votes)\n m.redraw.strategy('all')\n m.redraw()\n }\n )\n }\n\n view() {\n\n if (this.voted() !== false) {\n return (\n
\n

{this.poll.question()}

\n {this.answers.map((item) => {\n let voted = false;\n if (this.voted() !== true) {\n voted = parseInt(this.voted().option_id()) === item.data.attributes.id;\n m.redraw()\n }\n let percent = Math.round((item.votes() / this.poll.votes().length) * 100)\n return (\n
\n = 1 ? item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.vote') : item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.votes')}\n className='PollBar'\n data-selected={voted}\n config={\n function (element) {\n $(element).tooltip({placement: 'right'});\n }\n }>\n {!this.poll.isEnded() && this.voted !== true ?\n \n : ''}\n
\n \n \n
\n
\n )\n })\n }\n
\n {this.poll.isPublic() ?\n Button.component({\n className: 'Button Button--primary PublicPollButton',\n children: app.translator.trans('reflar-polls.forum.public_poll'),\n onclick: () => {\n app.modal.show(new ShowVotersModal({votes: this.votes, answers: this.answers}))\n }\n }) : ''}\n
\n {!this.user.canVote() ? (\n
{app.translator.trans('reflar-polls.forum.no_permission')}
\n ) : this.poll.isEnded() ? (\n
{app.translator.trans('reflar-polls.forum.poll_ended')}
\n ) : !isNaN(new Date(this.poll.endDate())) ? (\n
\n {app.translator.trans('reflar-polls.forum.days_remaining', {time: moment(this.poll.endDate()).fromNow()})}\n
\n ) : ''}\n
\n
\n );\n\n } else {\n return (\n
\n

{this.poll.question()}

\n {\n this.answers.map((item) => (\n
\n
\n \n
\n
\n ))\n }\n
\n {this.poll.isPublic() && app.session.user !== undefined ?\n Button.component({\n className: 'Button Button--primary PublicPollButton',\n children: app.translator.trans('reflar-polls.forum.public_poll'),\n onclick: () => {\n app.modal.show(new ShowVotersModal(this.poll))\n }\n }) : ''}\n {this.poll.isEnded() ? (\n
{app.translator.trans('reflar-polls.forum.poll_ended')}
\n ) : !isNaN(new Date(this.poll.endDate())) ? (\n
\n {app.translator.trans('reflar-polls.forum.days_remaining', {time: moment(this.poll.endDate()).fromNow()})}\n
\n ) : ''}\n
\n );\n }\n }\n\n addVote(answer, el) {\n if (this.user === undefined) {\n app.modal.show(new LogInModal())\n el.srcElement.checked = false\n } else {\n app.store.createRecord('votes').save({\n poll_id: this.poll.id(),\n option_id: answer.id()\n }).then(\n vote => {\n this.answers[answer.id()].data.attributes.votes++;\n this.voted(vote);\n this.poll.data.relationships.votes.data.push(vote)\n this.votes.push(vote)\n m.redraw()\n })\n }\n }\n}\n","import Modal from 'flarum/components/Modal';\nimport ItemList from 'flarum/utils/ItemList';\nimport avatar from 'flarum/helpers/avatar';\nimport username from 'flarum/helpers/username';\nimport listItems from 'flarum/helpers/listItems';\n\nexport default class ShowVotersModal extends Modal {\n className() {\n return 'Modal--small';\n }\n\n title() {\n return app.translator.trans('reflar-polls.forum.votes_modal.title');\n }\n\n getUsers(answer) {\n let votes = []\n if (typeof this.props.votes === 'function') {\n votes = this.props.votes()\n } else {\n votes = this.props.votes\n }\n const items = new ItemList();\n var counter = 0;\n\n votes.map(vote => {\n var user = app.store.getById('users', vote.data.attributes.user_id)\n\n if (parseInt(answer.id()) === parseInt(vote.data.attributes.option_id)) {\n counter++\n items.add(user.id(), (\n \n {avatar(user)} {' '}\n {username(user)}\n \n ))\n }\n })\n \n if (counter === 0) {\n items.add('none', (\n

{app.translator.trans('reflar-polls.forum.modal.no_voters')}

\n ))\n }\n\n return items;\n }\n\n content() {\n if (typeof this.props.answers === 'function') {\n this.answers = this.props.answers()\n } else {\n this.answers = this.props.answers\n }\n return (\n
\n
    \n {this.answers.map(answer => (\n
    \n

    {answer.answer() + ':'}

    \n {listItems(this.getUsers(answer).toArray())}\n
    \n ))}\n
\n
\n )\n }\n}\n","import app from 'flarum/app';\nimport {extend, override} from 'flarum/extend';\n\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\n\nimport Model from 'flarum/Model';\nimport Question from '../common/models/Question';\nimport Answer from '../common/models/Answer';\nimport Vote from '../common/models/Vote';\nimport Discussion from 'flarum/models/Discussion';\nimport User from 'flarum/models/User';\n\nimport addPollBadege from './addPollBadge'\nimport PollControl from './PollControl';\nimport PollDiscussion from './PollDiscussion';\nimport PollModal from './components/PollModal';\n\napp.initializers.add('reflar-polls', app => {\n // Relationships\n app.store.models.answers = Answer;\n app.store.models.questions = Question;\n app.store.models.votes = Vote;\n\n Discussion.prototype.Poll = Model.hasOne('Poll');\n\n User.prototype.canEditPolls = Model.attribute('canEditPolls');\n User.prototype.canStartPolls = Model.attribute('canStartPolls');\n User.prototype.canSelfEditPolls = Model.attribute('canSelfEditPolls');\n User.prototype.canVote = Model.attribute('canVote');\n\t\n DiscussionComposer.prototype.addPoll = function(data) {\n app.modal.show(new PollModal(data));\n };\n\n // Add button to DiscussionComposer header\n extend(DiscussionComposer.prototype, 'headerItems', function (items) {\n if (app.session.user.canStartPolls()) {\n items.add('polls', (\n \n {this.data().poll\n ?\n {app.translator.trans('reflar-polls.forum.composer_discussion.edit')}\n :\n {app.translator.trans('reflar-polls.forum.composer_discussion.add_poll')}}\n\n ), 1);\n }\n });\n\n extend(DiscussionComposer.prototype, 'onsubmit', function() {\n extend(DiscussionComposer.prototype, 'data', function (data) {\n data.poll = undefined;\n });\n })\n\n addPollBadege();\n PollDiscussion();\n PollControl();\n});\n","module.exports = flarum.core.compat['Component'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['components/Badge'];","module.exports = flarum.core.compat['components/Button'];","module.exports = flarum.core.compat['components/CommentPost'];","module.exports = flarum.core.compat['components/DiscussionComposer'];","module.exports = flarum.core.compat['components/LogInModal'];","module.exports = flarum.core.compat['components/Modal'];","module.exports = flarum.core.compat['components/Switch'];","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['helpers/avatar'];","module.exports = flarum.core.compat['helpers/listItems'];","module.exports = flarum.core.compat['helpers/username'];","module.exports = flarum.core.compat['models/Discussion'];","module.exports = flarum.core.compat['models/User'];","module.exports = flarum.core.compat['utils/ItemList'];","module.exports = flarum.core.compat['utils/PostControls'];","module.exports = flarum.core.compat['utils/mixin'];","module.exports = jQuery;"],"sourceRoot":""} \ No newline at end of file diff --git a/js/forum.js b/js/forum.js new file mode 100644 index 0000000..90811e4 --- /dev/null +++ b/js/forum.js @@ -0,0 +1,11 @@ +/* + * This file is part of Flarum. + * + * (c) Toby Zerner + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +export * from './src/common'; +export * from './src/forum'; \ No newline at end of file diff --git a/js/forum/Gulpfile.js b/js/forum/Gulpfile.js deleted file mode 100644 index d5ab39e..0000000 --- a/js/forum/Gulpfile.js +++ /dev/null @@ -1,13 +0,0 @@ -var gulp = require('flarum-gulp'); - -gulp({ - files: [ - 'node_modules/datetimepicker/dist/DateTimePicker.min.js' - ], - modules: { - 'reflar/polls': [ - '../lib/**/*.js', - 'src/**/*.js' - ] - } -}); diff --git a/js/forum/dist/extension.js b/js/forum/dist/extension.js deleted file mode 100644 index 55e8d09..0000000 --- a/js/forum/dist/extension.js +++ /dev/null @@ -1,1235 +0,0 @@ -/* ----------------------------------------------------------------------------- - - jQuery DateTimePicker - Responsive flat design jQuery DateTime Picker plugin for Web & Mobile - Version 0.1.38 - Copyright (c)2017 Lajpat Shah - Contributors : https://github.com/nehakadam/DateTimePicker/contributors - Repository : https://github.com/nehakadam/DateTimePicker - Documentation : https://nehakadam.github.io/DateTimePicker - - ----------------------------------------------------------------------------- */ - -Object.keys||(Object.keys=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b}),$.DateTimePicker=$.DateTimePicker||{name:"DateTimePicker",i18n:{},defaults:{mode:"date",defaultDate:null,dateSeparator:"-",timeSeparator:":",timeMeridiemSeparator:" ",dateTimeSeparator:" ",monthYearSeparator:" ",dateTimeFormat:"dd-MM-yyyy HH:mm",dateFormat:"dd-MM-yyyy",timeFormat:"HH:mm",maxDate:null,minDate:null,maxTime:null,minTime:null,maxDateTime:null,minDateTime:null,shortDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],fullDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],fullMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],labels:null,minuteInterval:1,roundOffMinutes:!0,secondsInterval:1,roundOffSeconds:!0,showHeader:!0,titleContentDate:"Set Date",titleContentTime:"Set Time",titleContentDateTime:"Set Date & Time",buttonsToDisplay:["HeaderCloseButton","SetButton","ClearButton"],setButtonContent:"Set",clearButtonContent:"Clear",incrementButtonContent:"+",decrementButtonContent:"-",setValueInTextboxOnEveryClick:!1,readonlyInputs:!1,animationDuration:400,touchHoldInterval:300,captureTouchHold:!1,mouseHoldInterval:50,captureMouseHold:!1,isPopup:!0,parentElement:"body",isInline:!1,inputElement:null,language:"",init:null,addEventHandlers:null,beforeShow:null,afterShow:null,beforeHide:null,afterHide:null,buttonClicked:null,settingValueOfElement:null,formatHumanDate:null,parseDateTimeString:null,formatDateTimeString:null},dataObject:{dCurrentDate:new Date,iCurrentDay:0,iCurrentMonth:0,iCurrentYear:0,iCurrentHour:0,iCurrentMinutes:0,iCurrentSeconds:0,sCurrentMeridiem:"",iMaxNumberOfDays:0,sDateFormat:"",sTimeFormat:"",sDateTimeFormat:"",dMinValue:null,dMaxValue:null,sArrInputDateFormats:[],sArrInputTimeFormats:[],sArrInputDateTimeFormats:[],bArrMatchFormat:[],bDateMode:!1,bTimeMode:!1,bDateTimeMode:!1,oInputElement:null,iTabIndex:0,bElemFocused:!1,bIs12Hour:!1,sTouchButton:null,iTouchStart:null,oTimeInterval:null,bIsTouchDevice:"ontouchstart"in document.documentElement}},$.cf={_isValid:function(a){return void 0!==a&&null!==a&&""!==a},_compare:function(a,b){var c=void 0!==a&&null!==a,d=void 0!==b&&null!==b;return!(!c||!d)&&a.toLowerCase()===b.toLowerCase()}},function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){"use strict";function b(b,c){this.element=b;var d="";d=a.cf._isValid(c)&&a.cf._isValid(c.language)?c.language:a.DateTimePicker.defaults.language,this.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[d],c),this.options=c,this.oData=a.extend({},a.DateTimePicker.dataObject),this._defaults=a.DateTimePicker.defaults,this._name=a.DateTimePicker.name,this.init()}a.fn.DateTimePicker=function(c){var d,e,f=a(this).data(),g=f?Object.keys(f):[];if("string"!=typeof c)return this.each(function(){a.removeData(this,"plugin_DateTimePicker"),a.data(this,"plugin_DateTimePicker")||a.data(this,"plugin_DateTimePicker",new b(this,c))});if(a.cf._isValid(f))if("destroy"===c){if(g.length>0)for(d in g)if(e=g[d],e.search("plugin_DateTimePicker")!==-1){a(document).unbind("click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker"),a(this).children().remove(),a(this).removeData(),a(this).unbind(),a(this).removeClass("dtpicker-overlay dtpicker-mobile dtpicker-inline"),f=f[e];break}}else if("object"===c&&g.length>0)for(d in g)if(e=g[d],e.search("plugin_DateTimePicker")!==-1)return f[e]},b.prototype={init:function(){var b=this;b._setDateFormatArray(),b._setTimeFormatArray(),b._setDateTimeFormatArray(),void 0!==a(b.element).data("parentelement")&&(b.settings.parentElement=a(b.element).data("parentelement")),b.settings.isPopup&&!b.settings.isInline&&(b._createPicker(),a(b.element).addClass("dtpicker-mobile")),b.settings.isInline&&(b._createPicker(),b._showPicker(b.settings.inputElement)),b.settings.init&&b.settings.init.call(b),b._addEventHandlersForInput()},_setDateFormatArray:function(){var a=this;a.oData.sArrInputDateFormats=[];var b="";b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",a.oData.sArrInputDateFormats.push(b),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MMM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="MMMM"+a.settings.monthYearSeparator+"yyyy",a.oData.sArrInputDateFormats.push(b),b="yyyy"+a.settings.monthYearSeparator+"MM",a.oData.sArrInputDateFormats.push(b)},_setTimeFormatArray:function(){var a=this;a.oData.sArrInputTimeFormats=[];var b="";b="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",a.oData.sArrInputTimeFormats.push(b),b="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",a.oData.sArrInputTimeFormats.push(b),b="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",a.oData.sArrInputTimeFormats.push(b),b="HH"+a.settings.timeSeparator+"mm",a.oData.sArrInputTimeFormats.push(b)},_setDateTimeFormatArray:function(){var a=this;a.oData.sArrInputDateTimeFormats=[];var b="",c="",d="";b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="HH"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeSeparator+"ss"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="MM"+a.settings.dateSeparator+"dd"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="HH"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="yyyy"+a.settings.dateSeparator+"MM"+a.settings.dateSeparator+"dd",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d),b="dd"+a.settings.dateSeparator+"MMM"+a.settings.dateSeparator+"yyyy",c="hh"+a.settings.timeSeparator+"mm"+a.settings.timeMeridiemSeparator+"AA",d=b+a.settings.dateTimeSeparator+c,a.oData.sArrInputDateTimeFormats.push(d)},_matchFormat:function(b,c){var d=this;d.oData.bArrMatchFormat=[],d.oData.bDateMode=!1,d.oData.bTimeMode=!1,d.oData.bDateTimeMode=!1;var e,f=[];for(b=a.cf._isValid(b)?b:d.settings.mode,a.cf._compare(b,"date")?(c=a.cf._isValid(c)?c:d.oData.sDateFormat,d.oData.bDateMode=!0,f=d.oData.sArrInputDateFormats):a.cf._compare(b,"time")?(c=a.cf._isValid(c)?c:d.oData.sTimeFormat,d.oData.bTimeMode=!0,f=d.oData.sArrInputTimeFormats):a.cf._compare(b,"datetime")&&(c=a.cf._isValid(c)?c:d.oData.sDateTimeFormat,d.oData.bDateTimeMode=!0,f=d.oData.sArrInputDateTimeFormats),e=0;e0&&d._matchFormat(b,c)},_createPicker:function(){var b=this;b.settings.isInline?a(b.element).addClass("dtpicker-inline"):(a(b.element).addClass("dtpicker-overlay"),a(".dtpicker-overlay").click(function(a){b._hidePicker("")}));var c="";c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",c+="
",a(b.element).html(c)},_addEventHandlersForInput:function(){var b=this;if(!b.settings.isInline){b.oData.oInputElement=null,a(b.settings.parentElement).find("input[type='date'], input[type='time'], input[type='datetime']").each(function(){a(this).attr("data-field",a(this).attr("type")),a(this).attr("type","text")});var c="[data-field='date'], [data-field='time'], [data-field='datetime']";a(b.settings.parentElement).off("focus",c,b._inputFieldFocus).on("focus",c,{obj:b},b._inputFieldFocus),a(b.settings.parentElement).off("click",c,b._inputFieldClick).on("click",c,{obj:b},b._inputFieldClick)}b.settings.addEventHandlers&&b.settings.addEventHandlers.call(b)},_inputFieldFocus:function(a){var b=a.data.obj;b.showDateTimePicker(this),b.oData.bMouseDown=!1},_inputFieldClick:function(b){var c=b.data.obj;a.cf._compare(a(this).prop("tagName"),"input")||c.showDateTimePicker(this),b.stopPropagation()},getDateObjectForInputField:function(b){var c=this;if(a.cf._isValid(b)){var d,e=c._getValueOfElement(b),f=a(b).data("field"),g="";return a.cf._isValid(f)||(f=c.settings.mode),c.settings.formatDateTimeString?d=c.settings.parseDateTimeString.call(c,e,f,g,a(b)):(g=a(b).data("format"),a.cf._isValid(g)||(a.cf._compare(f,"date")?g=c.settings.dateFormat:a.cf._compare(f,"time")?g=c.settings.timeFormat:a.cf._compare(f,"datetime")&&(g=c.settings.dateTimeFormat)),c._matchFormat(f,g),a.cf._compare(f,"date")?d=c._parseDate(e):a.cf._compare(f,"time")?d=c._parseTime(e):a.cf._compare(f,"datetime")&&(d=c._parseDateTime(e))),d}},setDateTimeStringInInputField:function(b,c){var d=this;c=c||d.oData.dCurrentDate;var e;a.cf._isValid(b)?(e=[],"string"==typeof b?e.push(b):"object"==typeof b&&(e=b)):e=a.cf._isValid(d.settings.parentElement)?a(d.settings.parentElement).find("[data-field='date'], [data-field='time'], [data-field='datetime']"):a("[data-field='date'], [data-field='time'], [data-field='datetime']"),e.each(function(){var b,e,f,g,h=this;b=a(h).data("field"),a.cf._isValid(b)||(b=d.settings.mode),e="Custom",f=!1,d.settings.formatDateTimeString||(e=a(h).data("format"),a.cf._isValid(e)||(a.cf._compare(b,"date")?e=d.settings.dateFormat:a.cf._compare(b,"time")?e=d.settings.timeFormat:a.cf._compare(b,"datetime")&&(e=d.settings.dateTimeFormat)),f=d.getIs12Hour(b,e)),g=d._setOutput(b,e,f,c,h),d._setValueOfElement(g,a(h))})},getDateTimeStringInFormat:function(a,b,c){var d=this;return d._setOutput(a,b,d.getIs12Hour(a,b),c)},showDateTimePicker:function(a){var b=this;null!==b.oData.oInputElement?b.settings.isInline||b._hidePicker(0,a):b._showPicker(a)},_setButtonAction:function(a){var b=this;null!==b.oData.oInputElement&&(b._setValueOfElement(b._setOutput()),a?(b.settings.buttonClicked&&b.settings.buttonClicked.call(b,"TAB",b.oData.oInputElement),b.settings.isInline||b._hidePicker(0)):b.settings.isInline||b._hidePicker(""))},_setOutput:function(b,c,d,e,f){var g=this;e=a.cf._isValid(e)?e:g.oData.dCurrentDate,d=d||g.oData.bIs12Hour;var h,i=g._setVariablesForDate(e,!0,!0),j="",k=g._formatDate(i),l=g._formatTime(i),m=a.extend({},k,l),n="",o="",p=Function.length;return g.settings.formatDateTimeString?j=g.settings.formatDateTimeString.call(g,m,b,c,f):(g._setMatchFormat(p,b,c),g.oData.bDateMode?g.oData.bArrMatchFormat[0]?j=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[1]?j=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]?j=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:g.oData.bArrMatchFormat[3]?j=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]?j=m.MM+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[5]?j=m.monthShort+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[6]?j=m.month+g.settings.monthYearSeparator+m.yyyy:g.oData.bArrMatchFormat[7]&&(j=m.yyyy+g.settings.monthYearSeparator+m.MM):g.oData.bTimeMode?g.oData.bArrMatchFormat[0]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[1]?j=m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:g.oData.bArrMatchFormat[2]?j=m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:g.oData.bArrMatchFormat[3]&&(j=m.HH+g.settings.timeSeparator+m.mm):g.oData.bDateTimeMode&&(g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[8]||g.oData.bArrMatchFormat[9]?n=m.dd+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[10]||g.oData.bArrMatchFormat[11]?n=m.MM+g.settings.dateSeparator+m.dd+g.settings.dateSeparator+m.yyyy:g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[12]||g.oData.bArrMatchFormat[13]?n=m.yyyy+g.settings.dateSeparator+m.MM+g.settings.dateSeparator+m.dd:(g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7]||g.oData.bArrMatchFormat[14]||g.oData.bArrMatchFormat[15])&&(n=m.dd+g.settings.dateSeparator+m.monthShort+g.settings.dateSeparator+m.yyyy),h=g.oData.bArrMatchFormat[0]||g.oData.bArrMatchFormat[1]||g.oData.bArrMatchFormat[2]||g.oData.bArrMatchFormat[3]||g.oData.bArrMatchFormat[4]||g.oData.bArrMatchFormat[5]||g.oData.bArrMatchFormat[6]||g.oData.bArrMatchFormat[7],o=d?h?m.hh+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss+g.settings.timeMeridiemSeparator+m.ME:m.hh+g.settings.timeSeparator+m.mm+g.settings.timeMeridiemSeparator+m.ME:h?m.HH+g.settings.timeSeparator+m.mm+g.settings.timeSeparator+m.ss:m.HH+g.settings.timeSeparator+m.mm,""!==n&&""!==o&&(j=n+g.settings.dateTimeSeparator+o)),g._setMatchFormat(p)),j},_clearButtonAction:function(){var a=this;null!==a.oData.oInputElement&&a._setValueOfElement(""),a.settings.isInline||a._hidePicker("")},_setOutputOnIncrementOrDecrement:function(){var b=this;a.cf._isValid(b.oData.oInputElement)&&b.settings.setValueInTextboxOnEveryClick&&b._setValueOfElement(b._setOutput())},_showPicker:function(b){var c=this;if(null===c.oData.oInputElement){c.oData.oInputElement=b,c.oData.iTabIndex=parseInt(a(b).attr("tabIndex"));var d=a(b).data("field")||"",e=a(b).data("min")||"",f=a(b).data("max")||"",g=a(b).data("format")||"",h=a(b).data("view")||"",i=a(b).data("startend")||"",j=a(b).data("startendelem")||"",k=c._getValueOfElement(b)||"";if(""!==h&&(a.cf._compare(h,"Popup")?c.setIsPopup(!0):c.setIsPopup(!1)),!c.settings.isPopup&&!c.settings.isInline){c._createPicker();var l=a(c.oData.oInputElement).offset().top+a(c.oData.oInputElement).outerHeight(),m=a(c.oData.oInputElement).offset().left,n=a(c.oData.oInputElement).outerWidth();a(c.element).css({position:"absolute",top:l,left:m,width:n,height:"auto"})}c.settings.beforeShow&&c.settings.beforeShow.call(c,b),d=a.cf._isValid(d)?d:c.settings.mode,c.settings.mode=d,a.cf._isValid(g)||(a.cf._compare(d,"date")?g=c.settings.dateFormat:a.cf._compare(d,"time")?g=c.settings.timeFormat:a.cf._compare(d,"datetime")&&(g=c.settings.dateTimeFormat)),c._matchFormat(d,g),c.oData.dMinValue=null,c.oData.dMaxValue=null,c.oData.bIs12Hour=!1;var o,p,q,r,s,t,u,v;c.oData.bDateMode?(o=e||c.settings.minDate,p=f||c.settings.maxDate,c.oData.sDateFormat=g,a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDate(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDate(p)),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(q=c._getValueOfElement(a(j)),""!==q&&(r=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,q,d,g,a(j)):c._parseDate(q),a.cf._compare(i,"start")?a.cf._isValid(p)?c._compareDates(r,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(r)):c.oData.dMaxValue=new Date(r):a.cf._compare(i,"end")&&(a.cf._isValid(o)?c._compareDates(r,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(r)):c.oData.dMinValue=new Date(r)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDate(k),c.oData.dCurrentDate.setHours(0),c.oData.dCurrentDate.setMinutes(0),c.oData.dCurrentDate.setSeconds(0)):c.oData.bTimeMode?(o=e||c.settings.minTime,p=f||c.settings.maxTime,c.oData.sTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseTime(o),a.cf._isValid(p)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?p="11:59:59 PM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?p="23:59:59":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?p="11:59 PM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(p="23:59"),c.oData.dMaxValue=c._parseTime(p))),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseTime(p),a.cf._isValid(o)||(c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[0]?o="12:00:00 AM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[1]?o="00:00:00":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[2]?o="12:00 AM":c.oData.sTimeFormat===c.oData.sArrInputTimeFormats[3]&&(o="00:00"),c.oData.dMinValue=c._parseTime(o))),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(s=c._getValueOfElement(a(j)),""!==s&&(c.settings.parseDateTimeString?r=c.settings.parseDateTimeString.call(c,s,d,g,a(j)):t=c._parseTime(s),a.cf._compare(i,"start")?(t.setMinutes(t.getMinutes()-1),a.cf._isValid(p)?2===c._compareTime(t,c.oData.dMaxValue)&&(c.oData.dMaxValue=new Date(t)):c.oData.dMaxValue=new Date(t)):a.cf._compare(i,"end")&&(t.setMinutes(t.getMinutes()+1),a.cf._isValid(o)?3===c._compareTime(t,c.oData.dMinValue)&&(c.oData.dMinValue=new Date(t)):c.oData.dMinValue=new Date(t)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseTime(k)):c.oData.bDateTimeMode&&(o=e||c.settings.minDateTime,p=f||c.settings.maxDateTime,c.oData.sDateTimeFormat=g,c.oData.bIs12Hour=c.getIs12Hour(),a.cf._isValid(o)&&(c.oData.dMinValue=c._parseDateTime(o)),a.cf._isValid(p)&&(c.oData.dMaxValue=c._parseDateTime(p)),""!==i&&(a.cf._compare(i,"start")||a.cf._compare(i,"end"))&&""!==j&&a(j).length>=1&&(u=c._getValueOfElement(a(j)),""!==u&&(v=c.settings.parseDateTimeString?c.settings.parseDateTimeString.call(c,u,d,g,a(j)):c._parseDateTime(u),a.cf._compare(i,"start")?a.cf._isValid(p)?c._compareDateTime(v,c.oData.dMaxValue)<0&&(c.oData.dMaxValue=new Date(v)):c.oData.dMaxValue=new Date(v):a.cf._compare(i,"end")&&(a.cf._isValid(o)?c._compareDateTime(v,c.oData.dMinValue)>0&&(c.oData.dMinValue=new Date(v)):c.oData.dMinValue=new Date(v)))),c.settings.parseDateTimeString?c.oData.dCurrentDate=c.settings.parseDateTimeString.call(c,k,d,g,a(b)):c.oData.dCurrentDate=c._parseDateTime(k)),c._setVariablesForDate(),c._modifyPicker(),a(c.element).fadeIn(c.settings.animationDuration),c.settings.afterShow&&setTimeout(function(){c.settings.afterShow.call(c,b)},c.settings.animationDuration)}},_hidePicker:function(b,c){var d=this,e=d.oData.oInputElement;d.settings.beforeHide&&d.settings.beforeHide.call(d,e),a.cf._isValid(b)||(b=d.settings.animationDuration),a.cf._isValid(d.oData.oInputElement)&&(a(d.oData.oInputElement).blur(),d.oData.oInputElement=null),a(d.element).fadeOut(b),0===b?a(d.element).find(".dtpicker-subcontent").html(""):setTimeout(function(){a(d.element).find(".dtpicker-subcontent").html("")},b),a(document).unbind("click.DateTimePicker keydown.DateTimePicker keyup.DateTimePicker"),d.settings.afterHide&&(0===b?d.settings.afterHide.call(d,e):setTimeout(function(){d.settings.afterHide.call(d,e)},b)),a.cf._isValid(c)&&d._showPicker(c)},_modifyPicker:function(){var b,c,d=this,e=[];d.oData.bDateMode?(b=d.settings.titleContentDate,c=3,d.oData.bArrMatchFormat[0]?e=["day","month","year"]:d.oData.bArrMatchFormat[1]?e=["month","day","year"]:d.oData.bArrMatchFormat[2]?e=["year","month","day"]:d.oData.bArrMatchFormat[3]?e=["day","month","year"]:d.oData.bArrMatchFormat[4]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[5]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[6]?(c=2,e=["month","year"]):d.oData.bArrMatchFormat[7]&&(c=2,e=["year","month"])):d.oData.bTimeMode?(b=d.settings.titleContentTime,d.oData.bArrMatchFormat[0]?(c=4,e=["hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[1]?(c=3,e=["hour","minutes","seconds"]):d.oData.bArrMatchFormat[2]?(c=3,e=["hour","minutes","meridiem"]):d.oData.bArrMatchFormat[3]&&(c=2,e=["hour","minutes"])):d.oData.bDateTimeMode&&(b=d.settings.titleContentDateTime,d.oData.bArrMatchFormat[0]?(c=6,e=["day","month","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[1]?(c=7,e=["day","month","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[2]?(c=6,e=["month","day","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[3]?(c=7,e=["month","day","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[4]?(c=6,e=["year","month","day","hour","minutes","seconds"]):d.oData.bArrMatchFormat[5]?(c=7,e=["year","month","day","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[6]?(c=6,e=["day","month","year","hour","minutes","seconds"]):d.oData.bArrMatchFormat[7]?(c=7,e=["day","month","year","hour","minutes","seconds","meridiem"]):d.oData.bArrMatchFormat[8]?(c=5,e=["day","month","year","hour","minutes"]):d.oData.bArrMatchFormat[9]?(c=6,e=["day","month","year","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[10]?(c=5,e=["month","day","year","hour","minutes"]):d.oData.bArrMatchFormat[11]?(c=6,e=["month","day","year","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[12]?(c=5,e=["year","month","day","hour","minutes"]):d.oData.bArrMatchFormat[13]?(c=6,e=["year","month","day","hour","minutes","meridiem"]):d.oData.bArrMatchFormat[14]?(c=5,e=["day","month","year","hour","minutes"]):d.oData.bArrMatchFormat[15]&&(c=6,e=["day","month","year","hour","minutes","meridiem"]));var f,g="dtpicker-comp"+c,h=!1,i=!1,j=!1;for(f=0;f",h&&(k+="×"),k+="
",k+="
");var l="";for(l+="
",f=0;f",l+="
",l+=""+d.settings.incrementButtonContent+"",l+=d.settings.readonlyInputs?"":"",l+=""+d.settings.decrementButtonContent+"",d.settings.labels&&(l+="
"+d.settings.labels[m]+"
"),l+="
",l+="
"}l+="
";var n="";n=i&&j?" dtpicker-twoButtons":" dtpicker-singleButton";var o="";o+="";var p=k+l+o;a(d.element).find(".dtpicker-subcontent").html(p),d._setCurrentDate(),d._addEventHandlersForPicker()},_addEventHandlersForPicker:function(){var b,c,d=this;if(d.settings.isInline||a(document).on("click.DateTimePicker",function(a){d._hidePicker("")}),a(document).on("keydown.DateTimePicker",function(e){if(c=parseInt(e.keyCode?e.keyCode:e.which),!a(".dtpicker-compValue").is(":focus")&&9===c)return d._setButtonAction(!0),a("[tabIndex="+(d.oData.iTabIndex+1)+"]").focus(),!1;if(a(".dtpicker-compValue").is(":focus")){if(38===c)return b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"inc"),!1;if(40===c)return b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"dec"),!1}}),d.settings.isInline||a(document).on("keydown.DateTimePicker",function(b){c=parseInt(b.keyCode?b.keyCode:b.which),a(".dtpicker-compValue").is(":focus")||9===c||d._hidePicker("")}),a(".dtpicker-cont *").click(function(a){a.stopPropagation()}),d.settings.readonlyInputs||(a(".dtpicker-compValue").not(".month .dtpicker-compValue, .meridiem .dtpicker-compValue").keyup(function(){this.value=this.value.replace(/[^0-9\.]/g,"")}),a(".dtpicker-compValue").focus(function(){d.oData.bElemFocused=!0,a(this).select()}),a(".dtpicker-compValue").blur(function(){d._getValuesFromInputBoxes(),d._setCurrentDate(),d.oData.bElemFocused=!1;var b=a(this).parent().parent();setTimeout(function(){b.is(":last-child")&&!d.oData.bElemFocused&&d._setButtonAction(!1)},50)}),a(".dtpicker-compValue").keyup(function(b){var c,d=a(this),e=d.val(),f=e.length;d.parent().hasClass("day")||d.parent().hasClass("hour")||d.parent().hasClass("minutes")||d.parent().hasClass("meridiem")?f>2&&(c=e.slice(0,2),d.val(c)):d.parent().hasClass("month")?f>3&&(c=e.slice(0,3),d.val(c)):d.parent().hasClass("year")&&f>4&&(c=e.slice(0,4),d.val(c)),9===parseInt(b.keyCode?b.keyCode:b.which)&&a(this).select()})),a(d.element).find(".dtpicker-compValue").on("mousewheel DOMMouseScroll onmousewheel",function(c){if(a(".dtpicker-compValue").is(":focus")){var e=Math.max(-1,Math.min(1,c.originalEvent.wheelDelta));return e>0?(b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"inc")):(b=a(".dtpicker-compValue:focus").parent().attr("class"),d._incrementDecrementActionsUsingArrowAndMouse(b,"dec")),!1}}),a(d.element).find(".dtpicker-close").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"CLOSE",d.oData.oInputElement),d.settings.isInline||d._hidePicker("")}),a(d.element).find(".dtpicker-buttonSet").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"SET",d.oData.oInputElement),d._setButtonAction(!1)}),a(d.element).find(".dtpicker-buttonClear").click(function(a){d.settings.buttonClicked&&d.settings.buttonClicked.call(d,"CLEAR",d.oData.oInputElement),d._clearButtonAction()}),d.settings.captureTouchHold||d.settings.captureMouseHold){var e="";d.settings.captureTouchHold&&d.oData.bIsTouchDevice&&(e+="touchstart touchmove touchend "),d.settings.captureMouseHold&&(e+="mousedown mouseup"),a(".dtpicker-cont *").on(e,function(a){d._clearIntervalForTouchEvents()}),d._bindTouchEvents("day"),d._bindTouchEvents("month"),d._bindTouchEvents("year"),d._bindTouchEvents("hour"),d._bindTouchEvents("minutes"),d._bindTouchEvents("seconds")}else a(d.element).find(".day .increment, .day .increment *").click(function(a){d.oData.iCurrentDay++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".day .decrement, .day .decrement *").click(function(a){d.oData.iCurrentDay--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".month .increment, .month .increment *").click(function(a){d.oData.iCurrentMonth++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".month .decrement, .month .decrement *").click(function(a){d.oData.iCurrentMonth--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".year .increment, .year .increment *").click(function(a){d.oData.iCurrentYear++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".year .decrement, .year .decrement *").click(function(a){d.oData.iCurrentYear--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".hour .increment, .hour .increment *").click(function(a){d.oData.iCurrentHour++,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".hour .decrement, .hour .decrement *").click(function(a){d.oData.iCurrentHour--,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".minutes .increment, .minutes .increment *").click(function(a){d.oData.iCurrentMinutes+=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".minutes .decrement, .minutes .decrement *").click(function(a){d.oData.iCurrentMinutes-=d.settings.minuteInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".seconds .increment, .seconds .increment *").click(function(a){d.oData.iCurrentSeconds+=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()}),a(d.element).find(".seconds .decrement, .seconds .decrement *").click(function(a){d.oData.iCurrentSeconds-=d.settings.secondsInterval,d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()});a(d.element).find(".meridiem .dtpicker-compButton, .meridiem .dtpicker-compButton *").click(function(b){a.cf._compare(d.oData.sCurrentMeridiem,"AM")?(d.oData.sCurrentMeridiem="PM",d.oData.iCurrentHour+=12):a.cf._compare(d.oData.sCurrentMeridiem,"PM")&&(d.oData.sCurrentMeridiem="AM",d.oData.iCurrentHour-=12),d._setCurrentDate(),d._setOutputOnIncrementOrDecrement()})},_adjustMinutes:function(a){var b=this;return b.settings.roundOffMinutes&&1!==b.settings.minuteInterval&&(a=a%b.settings.minuteInterval?a-a%b.settings.minuteInterval+b.settings.minuteInterval:a),a},_adjustSeconds:function(a){var b=this;return b.settings.roundOffSeconds&&1!==b.settings.secondsInterval&&(a=a%b.settings.secondsInterval?a-a%b.settings.secondsInterval+b.settings.secondsInterval:a),a},_getValueOfElement:function(b){var c="";return c=a.cf._compare(a(b).prop("tagName"),"INPUT")?a(b).val():a(b).html()},_setValueOfElement:function(b,c){var d=this;a.cf._isValid(c)||(c=a(d.oData.oInputElement)),a.cf._compare(c.prop("tagName"),"INPUT")?c.val(b):c.html(b);var e=d.getDateObjectForInputField(c);return d.settings.settingValueOfElement&&d.settings.settingValueOfElement.call(d,b,e,c),c.change(),b},_bindTouchEvents:function(b){var c=this;a(c.element).find("."+b+" .increment, ."+b+" .increment *").on("touchstart mousedown",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(), -c.oData.sTouchButton=b+"-inc",c._setIntervalForTouchEvents())}),a(c.element).find("."+b+" .increment, ."+b+" .increment *").on("touchend mouseup",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()}),a(c.element).find("."+b+" .decrement, ."+b+" .decrement *").on("touchstart mousedown",function(d){d.stopPropagation(),a.cf._isValid(c.oData.sTouchButton)||(c.oData.iTouchStart=(new Date).getTime(),c.oData.sTouchButton=b+"-dec",c._setIntervalForTouchEvents())}),a(c.element).find("."+b+" .decrement, ."+b+" .decrement *").on("touchend mouseup",function(a){a.stopPropagation(),c._clearIntervalForTouchEvents()})},_setIntervalForTouchEvents:function(){var b=this,c=b.oData.bIsTouchDevice?b.settings.touchHoldInterval:b.settings.mouseHoldInterval;if(!a.cf._isValid(b.oData.oTimeInterval)){var d;b.oData.oTimeInterval=setInterval(function(){d=(new Date).getTime()-b.oData.iTouchStart,d>c&&a.cf._isValid(b.oData.sTouchButton)&&("day-inc"===b.oData.sTouchButton?b.oData.iCurrentDay++:"day-dec"===b.oData.sTouchButton?b.oData.iCurrentDay--:"month-inc"===b.oData.sTouchButton?b.oData.iCurrentMonth++:"month-dec"===b.oData.sTouchButton?b.oData.iCurrentMonth--:"year-inc"===b.oData.sTouchButton?b.oData.iCurrentYear++:"year-dec"===b.oData.sTouchButton?b.oData.iCurrentYear--:"hour-inc"===b.oData.sTouchButton?b.oData.iCurrentHour++:"hour-dec"===b.oData.sTouchButton?b.oData.iCurrentHour--:"minute-inc"===b.oData.sTouchButton?b.oData.iCurrentMinutes+=b.settings.minuteInterval:"minute-dec"===b.oData.sTouchButton?b.oData.iCurrentMinutes-=b.settings.minuteInterval:"second-inc"===b.oData.sTouchButton?b.oData.iCurrentSeconds+=b.settings.secondsInterval:"second-dec"===b.oData.sTouchButton&&(b.oData.iCurrentSeconds-=b.settings.secondsInterval),b._setCurrentDate(),b._setOutputOnIncrementOrDecrement(),b.oData.iTouchStart=(new Date).getTime())},c)}},_clearIntervalForTouchEvents:function(){var b=this;clearInterval(b.oData.oTimeInterval),a.cf._isValid(b.oData.sTouchButton)&&(b.oData.sTouchButton=null,b.oData.iTouchStart=0),b.oData.oTimeInterval=null},_incrementDecrementActionsUsingArrowAndMouse:function(a,b){var c=this;a.includes("day")?"inc"===b?c.oData.iCurrentDay++:"dec"===b&&c.oData.iCurrentDay--:a.includes("month")?"inc"===b?c.oData.iCurrentMonth++:"dec"===b&&c.oData.iCurrentMonth--:a.includes("year")?"inc"===b?c.oData.iCurrentYear++:"dec"===b&&c.oData.iCurrentYear--:a.includes("hour")?"inc"===b?c.oData.iCurrentHour++:"dec"===b&&c.oData.iCurrentHour--:a.includes("minutes")?"inc"===b?c.oData.iCurrentMinutes+=c.settings.minuteInterval:"dec"===b&&(c.oData.iCurrentMinutes-=c.settings.minuteInterval):a.includes("seconds")&&("inc"===b?c.oData.iCurrentSeconds+=c.settings.secondsInterval:"dec"===b&&(c.oData.iCurrentSeconds-=c.settings.secondsInterval)),c._setCurrentDate(),c._setOutputOnIncrementOrDecrement()},_parseDate:function(b){var c=this,d=c.settings.defaultDate?new Date(c.settings.defaultDate):new Date,e=d.getDate(),f=d.getMonth(),g=d.getFullYear();if(a.cf._isValid(b))if("string"==typeof b){var h;h=c.oData.bArrMatchFormat[4]||c.oData.bArrMatchFormat[5]||c.oData.bArrMatchFormat[6]?b.split(c.settings.monthYearSeparator):b.split(c.settings.dateSeparator),c.oData.bArrMatchFormat[0]?(e=parseInt(h[0]),f=parseInt(h[1]-1),g=parseInt(h[2])):c.oData.bArrMatchFormat[1]?(f=parseInt(h[0]-1),e=parseInt(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[2]?(g=parseInt(h[0]),f=parseInt(h[1]-1),e=parseInt(h[2])):c.oData.bArrMatchFormat[3]?(e=parseInt(h[0]),f=c._getShortMonthIndex(h[1]),g=parseInt(h[2])):c.oData.bArrMatchFormat[4]?(e=1,f=parseInt(h[0])-1,g=parseInt(h[1])):c.oData.bArrMatchFormat[5]?(e=1,f=c._getShortMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[6]?(e=1,f=c._getFullMonthIndex(h[0]),g=parseInt(h[1])):c.oData.bArrMatchFormat[7]&&(e=1,f=parseInt(h[1])-1,g=parseInt(h[0]))}else e=b.getDate(),f=b.getMonth(),g=b.getFullYear();return d=new Date(g,f,e,0,0,0,0)},_parseTime:function(b){var c,d,e,f=this,g=f.settings.defaultDate?new Date(f.settings.defaultDate):new Date,h=g.getDate(),i=g.getMonth(),j=g.getFullYear(),k=g.getHours(),l=g.getMinutes(),m=g.getSeconds(),n=f.oData.bArrMatchFormat[0]||f.oData.bArrMatchFormat[1];return m=n?f._adjustSeconds(m):0,a.cf._isValid(b)&&("string"==typeof b?(f.oData.bIs12Hour&&(c=b.split(f.settings.timeMeridiemSeparator),b=c[0],d=c[1],a.cf._compare(d,"AM")||a.cf._compare(d,"PM")||(d="")),e=b.split(f.settings.timeSeparator),k=parseInt(e[0]),l=parseInt(e[1]),n&&(m=parseInt(e[2]),m=f._adjustSeconds(m)),12===k&&a.cf._compare(d,"AM")?k=0:k<12&&a.cf._compare(d,"PM")&&(k+=12)):(k=b.getHours(),l=b.getMinutes(),n&&(m=b.getSeconds(),m=f._adjustSeconds(m)))),l=f._adjustMinutes(l),g=new Date(j,i,h,k,l,m,0)},_parseDateTime:function(b){var c,d,e,f,g,h=this,i=h.settings.defaultDate?new Date(h.settings.defaultDate):new Date,j=i.getDate(),k=i.getMonth(),l=i.getFullYear(),m=i.getHours(),n=i.getMinutes(),o=i.getSeconds(),p="",q=h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7];return o=q?h._adjustSeconds(o):0,a.cf._isValid(b)&&("string"==typeof b?(c=b.split(h.settings.dateTimeSeparator),d=c[0].split(h.settings.dateSeparator),h.oData.bArrMatchFormat[0]||h.oData.bArrMatchFormat[1]||h.oData.bArrMatchFormat[8]||h.oData.bArrMatchFormat[9]?(j=parseInt(d[0]),k=parseInt(d[1]-1),l=parseInt(d[2])):h.oData.bArrMatchFormat[2]||h.oData.bArrMatchFormat[3]||h.oData.bArrMatchFormat[10]||h.oData.bArrMatchFormat[11]?(k=parseInt(d[0]-1),j=parseInt(d[1]),l=parseInt(d[2])):h.oData.bArrMatchFormat[4]||h.oData.bArrMatchFormat[5]||h.oData.bArrMatchFormat[12]||h.oData.bArrMatchFormat[13]?(l=parseInt(d[0]),k=parseInt(d[1]-1),j=parseInt(d[2])):(h.oData.bArrMatchFormat[6]||h.oData.bArrMatchFormat[7]||h.oData.bArrMatchFormat[14]||h.oData.bArrMatchFormat[15])&&(j=parseInt(d[0]),k=h._getShortMonthIndex(d[1]),l=parseInt(d[2])),e=c[1],a.cf._isValid(e)&&(h.oData.bIs12Hour&&(a.cf._compare(h.settings.dateTimeSeparator,h.settings.timeMeridiemSeparator)&&3===c.length?p=c[2]:(f=e.split(h.settings.timeMeridiemSeparator),e=f[0],p=f[1]),a.cf._compare(p,"AM")||a.cf._compare(p,"PM")||(p="")),g=e.split(h.settings.timeSeparator),m=parseInt(g[0]),n=parseInt(g[1]),q&&(o=parseInt(g[2])),12===m&&a.cf._compare(p,"AM")?m=0:m<12&&a.cf._compare(p,"PM")&&(m+=12))):(j=b.getDate(),k=b.getMonth(),l=b.getFullYear(),m=b.getHours(),n=b.getMinutes(),q&&(o=b.getSeconds(),o=h._adjustSeconds(o)))),n=h._adjustMinutes(n),i=new Date(l,k,j,m,n,o,0)},_getShortMonthIndex:function(b){for(var c=this,d=0;d1&&(c=c.charAt(0).toUpperCase()+c.slice(1)),d=b.settings.shortMonthNames.indexOf(c),d!==-1?b.oData.iCurrentMonth=parseInt(d):c.match("^[+|-]?[0-9]+$")&&(b.oData.iCurrentMonth=parseInt(c-1)),b.oData.iCurrentDay=parseInt(a(b.element).find(".day .dtpicker-compValue").val())||b.oData.iCurrentDay,b.oData.iCurrentYear=parseInt(a(b.element).find(".year .dtpicker-compValue").val())||b.oData.iCurrentYear}if(b.oData.bTimeMode||b.oData.bDateTimeMode){var e,f,g,h;e=parseInt(a(b.element).find(".hour .dtpicker-compValue").val()),f=b._adjustMinutes(parseInt(a(b.element).find(".minutes .dtpicker-compValue").val())),g=b._adjustMinutes(parseInt(a(b.element).find(".seconds .dtpicker-compValue").val())),b.oData.iCurrentHour=isNaN(e)?b.oData.iCurrentHour:e,b.oData.iCurrentMinutes=isNaN(f)?b.oData.iCurrentMinutes:f,b.oData.iCurrentSeconds=isNaN(g)?b.oData.iCurrentSeconds:g,b.oData.iCurrentSeconds>59&&(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60),b.oData.iCurrentMinutes>59&&(b.oData.iCurrentHour+=b.oData.iCurrentMinutes/60,b.oData.iCurrentMinutes=b.oData.iCurrentMinutes%60),b.oData.bIs12Hour?b.oData.iCurrentHour>12&&(b.oData.iCurrentHour=b.oData.iCurrentHour%12):b.oData.iCurrentHour>23&&(b.oData.iCurrentHour=b.oData.iCurrentHour%23),b.oData.bIs12Hour&&(h=a(b.element).find(".meridiem .dtpicker-compValue").val(),(a.cf._compare(h,"AM")||a.cf._compare(h,"PM"))&&(b.oData.sCurrentMeridiem=h),a.cf._compare(b.oData.sCurrentMeridiem,"PM")&&12!==b.oData.iCurrentHour&&b.oData.iCurrentHour<13&&(b.oData.iCurrentHour+=12),a.cf._compare(b.oData.sCurrentMeridiem,"AM")&&12===b.oData.iCurrentHour&&(b.oData.iCurrentHour=0))}},_setCurrentDate:function(){var b=this;(b.oData.bTimeMode||b.oData.bDateTimeMode)&&(b.oData.iCurrentSeconds>59?(b.oData.iCurrentMinutes+=b.oData.iCurrentSeconds/60,b.oData.iCurrentSeconds=b.oData.iCurrentSeconds%60):b.oData.iCurrentSeconds<0&&(b.oData.iCurrentMinutes-=b.settings.minuteInterval,b.oData.iCurrentSeconds+=60),b.oData.iCurrentMinutes=b._adjustMinutes(b.oData.iCurrentMinutes),b.oData.iCurrentSeconds=b._adjustSeconds(b.oData.iCurrentSeconds));var c,d,e,f,g,h,i,j=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),k=!1,l=!1;if(null!==b.oData.dMaxValue&&(k=j.getTime()>b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(l=j.getTime()b.oData.dMaxValue.getTime()),null!==b.oData.dMinValue&&(n=b.oData.dCurrentDate.getTime()12&&(e-=12),"00"===g&&(e=12),f=e<10?"0"+e:e,j.oData.bIs12Hour&&(g=f),h=k.iCurrentMinutes,h=h<10?"0"+h:h,i=k.iCurrentSeconds,i=i<10?"0"+i:i,{H:c,HH:d,h:e,hh:f,hour:g,m:k.iCurrentMinutes,mm:h,s:k.iCurrentSeconds,ss:i,ME:k.sCurrentMeridiem}},_setButtons:function(){var b=this;a(b.element).find(".dtpicker-compButton").removeClass("dtpicker-compButtonDisable").addClass("dtpicker-compButtonEnable");var c;if(null!==b.oData.dMaxValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour+1>b.oData.dMaxValue.getHours()||b.oData.iCurrentHour+1===b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes>b.oData.dMaxValue.getMinutes())&&a(b.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),b.oData.iCurrentHour>=b.oData.dMaxValue.getHours()&&b.oData.iCurrentMinutes+1>b.oData.dMaxValue.getMinutes()&&a(b.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")):(c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay+1,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".day .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth+1,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".month .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear+1,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".year .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour+1,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".hour .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes+1,b.oData.iCurrentSeconds,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".minutes .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"),c=new Date(b.oData.iCurrentYear,b.oData.iCurrentMonth,b.oData.iCurrentDay,b.oData.iCurrentHour,b.oData.iCurrentMinutes,b.oData.iCurrentSeconds+1,0),c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".seconds .increment").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable"))),null!==b.oData.dMinValue&&(b.oData.bTimeMode?((b.oData.iCurrentHour-1b.oData.dMaxValue.getHours()||d===b.oData.dMaxValue.getHours()&&e>b.oData.dMaxValue.getMinutes())&&a(b.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")):c.getTime()>b.oData.dMaxValue.getTime()&&a(b.element).find(".meridiem .dtpicker-compButton").removeClass("dtpicker-compButtonEnable").addClass("dtpicker-compButtonDisable")),null!==b.oData.dMinValue&&(b.oData.bTimeMode?(e=b.oData.iCurrentMinutes,(db.getHours()?c=3:a.getHours()===b.getHours()&&(a.getMinutes()b.getMinutes()&&(c=3)),c},_compareDateTime:function(a,b){var c=(a.getTime()-b.getTime())/6e4;return 0===c?c:c/Math.abs(c)},_determineMeridiemFromHourAndMinutes:function(a,b){return a>12||12===a&&b>=0?"PM":"AM"},setLanguage:function(b){var c=this;return c.settings=a.extend({},a.DateTimePicker.defaults,a.DateTimePicker.i18n[b],c.options),c.settings.language=b,c._setDateFormatArray(),c._setTimeFormatArray(),c._setDateTimeFormatArray(),c}}});; -'use strict'; - -System.register('reflar/polls/addPollBadge', ['flarum/extend', 'flarum/models/Discussion', 'flarum/components/Badge'], function (_export, _context) { - "use strict"; - - var extend, Discussion, Badge; - function addPollBadge() { - extend(Discussion.prototype, 'badges', function (badges) { - if (this.Poll()) { - badges.add('poll', Badge.component({ - type: 'poll', - label: app.translator.trans('reflar-polls.forum.tooltip.badge'), - icon: 'signal' - }), 5); - } - }); - } - - _export('default', addPollBadge); - - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - }, function (_flarumModelsDiscussion) { - Discussion = _flarumModelsDiscussion.default; - }, function (_flarumComponentsBadge) { - Badge = _flarumComponentsBadge.default; - }], - execute: function () {} - }; -});; -'use strict'; - -System.register('reflar/polls/components/EditPollModal', ['flarum/extend', 'flarum/components/Modal', 'flarum/components/Button'], function (_export, _context) { - "use strict"; - - var extend, override, Modal, Button, EditPollModal; - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - override = _flarumExtend.override; - }, function (_flarumComponentsModal) { - Modal = _flarumComponentsModal.default; - }, function (_flarumComponentsButton) { - Button = _flarumComponentsButton.default; - }], - execute: function () { - EditPollModal = function (_Modal) { - babelHelpers.inherits(EditPollModal, _Modal); - - function EditPollModal() { - babelHelpers.classCallCheck(this, EditPollModal); - return babelHelpers.possibleConstructorReturn(this, (EditPollModal.__proto__ || Object.getPrototypeOf(EditPollModal)).apply(this, arguments)); - } - - babelHelpers.createClass(EditPollModal, [{ - key: 'init', - value: function init() { - babelHelpers.get(EditPollModal.prototype.__proto__ || Object.getPrototypeOf(EditPollModal.prototype), 'init', this).call(this); - this.answers = this.props.poll.answers(); - - this.question = m.prop(this.props.poll.question()); - - this.pollCreator = this.props.poll.store.data.users[Object.keys(this.props.poll.store.data.users)[0]]; - - this.newAnswer = m.prop(''); - - this.endDate = m.prop(this.props.poll.endDate() === ' UTC' ? '' : this.getDateTime(new Date(this.props.poll.endDate()))); - } - }, { - key: 'className', - value: function className() { - return 'PollDiscussionModal Modal--small'; - } - }, { - key: 'title', - value: function title() { - return app.translator.trans('reflar-polls.forum.modal.edit_title'); - } - }, { - key: 'getDateTime', - value: function getDateTime() { - var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(); - - if (isNaN(date)) { - date = new Date(); - } - var checkTargets = [date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes()]; - - checkTargets.forEach(function (target, i) { - if (target < 10) { - checkTargets[i] = "0" + target; - } - }); - - return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]; - } - }, { - key: 'config', - value: function config(isInitalized) { - var _this2 = this; - - if (isInitalized) return; - - var oDTP1; - - $('#dtBox').DateTimePicker({ - init: function init() { - oDTP1 = this; - }, - dateTimeFormat: "yyyy-MM-dd HH:mm", - minDateTime: this.getDateTime(), - settingValueOfElement: function settingValueOfElement(value) { - _this2.endDate(value); - app.request({ - method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/endDate/' + _this2.props.poll.id(), - data: { - date: new Date(value), - user_id: _this2.pollCreator.id() - } - }); - } - }); - } - }, { - key: 'content', - value: function content() { - var _this3 = this; - - return [m( - 'div', - { className: 'Modal-body' }, - m( - 'div', - { className: 'PollDiscussionModal-form' }, - m( - 'div', - null, - m( - 'fieldset', - null, - m('input', { type: 'text', name: 'question', className: 'FormControl', value: this.question(), oninput: m.withAttr('value', this.updateQuestion.bind(this)), placeholder: app.translator.trans('reflar-polls.forum.modal.question_placeholder') }) - ) - ), - m( - 'h4', - null, - app.translator.trans('reflar-polls.forum.modal.answers') - ), - this.answers.map(function (answer, i) { - return m( - 'div', - { className: 'Form-group' }, - m( - 'fieldset', - { className: 'Poll-answer-input' }, - m('input', { className: 'FormControl', - type: 'text', - oninput: m.withAttr('value', _this3.updateAnswer.bind(_this3, answer)), - value: answer.answer(), - placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (i + 1) }) - ), - i + 1 >= 3 ? Button.component({ - type: 'button', - className: 'Button Button--warning Poll-answer-button', - icon: 'minus', - onclick: i + 1 >= 3 ? _this3.removeOption.bind(_this3, answer) : '' - }) : '', - m('div', { className: 'clear' }) - ); - }), - m( - 'div', - { className: 'Form-group' }, - m( - 'fieldset', - { className: 'Poll-answer-input' }, - m('input', { className: 'FormControl', - type: 'text', - oninput: m.withAttr('value', this.newAnswer), - placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (this.answers.length + 1) }) - ), - Button.component({ - type: 'button', - className: 'Button Button--warning Poll-answer-button', - icon: 'plus', - onclick: this.addAnswer.bind(this) - }) - ), - m('div', { className: 'clear' }), - m( - 'div', - { style: 'margin-top: 20px', className: 'Form-group' }, - m( - 'fieldset', - { style: 'margin-bottom: 15px', className: 'Poll-answer-input' }, - m('input', { style: 'opacity: 1', className: 'FormControl', type: 'text', 'data-field': 'datetime', value: this.endDate() || app.translator.trans('reflar-polls.forum.modal.date_placeholder'), id: 'dtInput', 'data-min': this.getDateTime(), readonly: true }), - m('div', { id: 'dtBox' }) - ) - ), - m('div', { className: 'clear' }) - ), - Button.component({ - className: 'Button Button--primary PollModal-SubmitButton', - children: app.translator.trans('reflar-polls.forum.modal.submit'), - onclick: function onclick() { - app.modal.close(); - } - }) - )]; - } - }, { - key: 'onhide', - value: function onhide() { - this.props.poll.answers = m.prop(this.answers); - this.props.poll.question = this.question; - if (this.endDate() !== '') { - this.props.poll.endDate = this.endDate; - } - m.redraw.strategy('all'); - } - }, { - key: 'addAnswer', - value: function addAnswer(answer) { - var _this4 = this; - - var data = { - answer: this.newAnswer(), - poll_id: this.props.poll.id(), - user_id: this.pollCreator.id() - }; - if (this.answers.length < 10) { - app.store.createRecord('answers').save(data).then(function (answer) { - _this4.answers.push(answer); - - _this4.newAnswer(''); - m.redraw.strategy('all'); - m.redraw(); - }); - } else { - alert(app.translator.trans('reflar-polls.forum.modal.max')); - } - } - }, { - key: 'removeOption', - value: function removeOption(option) { - var _this5 = this; - - app.request({ - method: 'DELETE', - url: app.forum.attribute('apiUrl') + '/answers/' + option.data.id, - data: this.pollCreator.id() - }); - this.answers.some(function (answer, i) { - if (answer.data.id === option.data.id) { - _this5.answers.splice(i, 1); - return true; - } - }); - } - }, { - key: 'updateAnswer', - value: function updateAnswer(answerToUpdate, value) { - app.request({ - method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/answers/' + answerToUpdate.data.id, - data: { - answer: value, - user_id: this.pollCreator.id() - } - }); - this.answers.some(function (answer) { - if (answer.data.id === answerToUpdate.data.id) { - answer.data.attributes.answer = value; - return true; - } - }); - } - }, { - key: 'updateQuestion', - value: function updateQuestion(question) { - if (question === '') { - alert(app.translator.trans('reflar-polls.forum.modal.include_question')); - this.question(''); - return; - } - app.request({ - method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/questions/' + this.props.poll.id(), - data: { - question: question, - user_id: this.pollCreator.id() - } - }); - this.question = m.prop(question); - m.redraw(); - } - }]); - return EditPollModal; - }(Modal); - - _export('default', EditPollModal); - } - }; -});; -'use strict'; - -System.register('reflar/polls/components/PollModal', ['flarum/extend', 'flarum/components/Modal', 'flarum/components/Button', 'flarum/components/DiscussionComposer', 'flarum/components/Switch'], function (_export, _context) { - "use strict"; - - var extend, Modal, Button, DiscussionComposer, Switch, PollModal; - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - }, function (_flarumComponentsModal) { - Modal = _flarumComponentsModal.default; - }, function (_flarumComponentsButton) { - Button = _flarumComponentsButton.default; - }, function (_flarumComponentsDiscussionComposer) { - DiscussionComposer = _flarumComponentsDiscussionComposer.default; - }, function (_flarumComponentsSwitch) { - Switch = _flarumComponentsSwitch.default; - }], - execute: function () { - PollModal = function (_Modal) { - babelHelpers.inherits(PollModal, _Modal); - - function PollModal() { - babelHelpers.classCallCheck(this, PollModal); - return babelHelpers.possibleConstructorReturn(this, (PollModal.__proto__ || Object.getPrototypeOf(PollModal)).apply(this, arguments)); - } - - babelHelpers.createClass(PollModal, [{ - key: 'init', - value: function init() { - babelHelpers.get(PollModal.prototype.__proto__ || Object.getPrototypeOf(PollModal.prototype), 'init', this).call(this); - this.answer = []; - - this.question = m.prop(''); - this.answer[0] = m.prop(''); - this.answer[1] = m.prop(''); - - this.endDate = m.prop(); - this.publicPoll = m.prop(false); - - if (this.props.poll) { - var poll = this.props.poll; - this.answer = Object.values(poll.answers); - this.question(poll.question); - this.endDate(isNaN(poll.endDate) ? '' : this.getDateTime(poll.endDate)); - this.publicPoll(poll.publicPoll); - } - } - }, { - key: 'className', - value: function className() { - return 'PollDiscussionModal Modal--small'; - } - }, { - key: 'getDateTime', - value: function getDateTime() { - var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(); - - if (isNaN(date)) { - date = new Date(); - } - var checkTargets = [date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes()]; - - checkTargets.forEach(function (target, i) { - if (target < 10) { - checkTargets[i] = "0" + target; - } - }); - - return date.getFullYear() + '-' + checkTargets[0] + '-' + checkTargets[1] + ' ' + checkTargets[2] + ':' + checkTargets[3]; - } - }, { - key: 'title', - value: function title() { - return app.translator.trans('reflar-polls.forum.modal.add_title'); - } - }, { - key: 'config', - value: function config() { - var _this2 = this; - - var oDTP1; - - $('#dtBox').DateTimePicker({ - init: function init() { - oDTP1 = this; - }, - dateTimeFormat: "yyyy-MM-dd HH:mm", - minDateTime: this.getDateTime(), - settingValueOfElement: function settingValueOfElement(value) { - _this2.endDate(value); - } - }); - } - }, { - key: 'content', - value: function content() { - var _this3 = this; - - return [m( - 'div', - { className: 'Modal-body' }, - m( - 'div', - { className: 'PollDiscussionModal-form' }, - m( - 'div', - null, - m( - 'fieldset', - null, - m('input', { type: 'text', name: 'question', className: 'FormControl', bidi: this.question, placeholder: app.translator.trans('reflar-polls.forum.modal.question_placeholder') }) - ) - ), - m( - 'h4', - null, - app.translator.trans('reflar-polls.forum.modal.answers') - ), - Object.keys(this.answer).map(function (el, i) { - return m( - 'div', - { className: _this3.answer[i + 1] === '' ? 'Form-group hide' : 'Form-group' }, - m( - 'fieldset', - { className: 'Poll-answer-input' }, - m('input', { className: 'FormControl', - type: 'text', - name: 'answer' + (i + 1), - bidi: _this3.answer[i], - placeholder: app.translator.trans('reflar-polls.forum.modal.answer_placeholder') + ' #' + (i + 1) }), - m('div', { id: 'dtBox' }) - ), - i + 1 >= 3 ? Button.component({ - type: 'button', - className: 'Button Button--warning Poll-answer-button', - icon: 'minus', - onclick: i + 1 >= 3 ? _this3.removeOption.bind(_this3, i) : '' - }) : '', - m('div', { className: 'clear' }) - ); - }), - Button.component({ - className: 'Button Button--primary PollModal-Button', - children: app.translator.trans('reflar-polls.forum.modal.add'), - onclick: this.addOption.bind(this) - }), - m( - 'div', - { className: 'Form-group' }, - m( - 'fieldset', - { style: 'margin-bottom: 15px', className: 'Poll-answer-input' }, - m('input', { style: 'opacity: 1; color: inherit', className: 'FormControl', type: 'text', 'data-field': 'datetime', value: this.endDate() || app.translator.trans('reflar-polls.forum.modal.date_placeholder'), id: 'dtInput', 'data-min': this.getDateTime(), readonly: true }) - ), - m('div', { className: 'clear' }), - Switch.component({ - state: this.publicPoll() || false, - children: app.translator.trans('reflar-polls.forum.modal.switch'), - onchange: this.publicPoll - }), - m('div', { className: 'clear' }), - Button.component({ - type: 'submit', - className: 'Button Button--primary PollModal-SubmitButton', - children: app.translator.trans('reflar-polls.forum.modal.submit') - }) - ) - ) - )]; - } - }, { - key: 'addOption', - value: function addOption() { - if (this.answer.length < 11) { - this.answer.push(m.prop('')); - } else { - alert(app.translator.trans('reflar-polls.forum.modal.max')); - } - } - }, { - key: 'removeOption', - value: function removeOption(option) { - var _this4 = this; - - this.answer.forEach(function (answer, i) { - if (i === option) { - _this4.answer.splice(i, 1); - } - }); - } - }, { - key: 'objectSize', - value: function objectSize(obj) { - var size = 0, - key; - for (key in obj) { - if (obj[key] !== '') size++; - } - return size; - } - }, { - key: 'onsubmit', - value: function onsubmit(e) { - e.preventDefault(); - var pollArray = { - question: this.question(), - answers: {}, - endDate: new Date(this.endDate()), - publicPoll: this.publicPoll() - }; - - if (this.question() === '') { - alert(app.translator.trans('reflar-polls.forum.modal.include_question')); - return; - } - - // Add answers to PollArray - this.answer.map(function (answer, i) { - if (answer() !== '') { - pollArray['answers'][i] = answer; - } - }); - - if (this.objectSize(pollArray.answers) < 2) { - alert(app.translator.trans('reflar-polls.forum.modal.min')); - return; - } - - // Add data to DiscussionComposer post data - extend(DiscussionComposer.prototype, 'data', function (data) { - data.poll = pollArray; - }); - - app.modal.close(); - - m.redraw.strategy('none'); - } - }]); - return PollModal; - }(Modal); - - _export('default', PollModal); - } - }; -});; -'use strict'; - -System.register('reflar/polls/components/PollVote', ['flarum/extend', 'flarum/components/Button', 'flarum/Component', 'flarum/components/LogInModal', './ShowVotersModal'], function (_export, _context) { - "use strict"; - - var extend, Button, Component, LogInModal, ShowVotersModal, PollVote; - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - }, function (_flarumComponentsButton) { - Button = _flarumComponentsButton.default; - }, function (_flarumComponent) { - Component = _flarumComponent.default; - }, function (_flarumComponentsLogInModal) { - LogInModal = _flarumComponentsLogInModal.default; - }, function (_ShowVotersModal) { - ShowVotersModal = _ShowVotersModal.default; - }], - execute: function () { - PollVote = function (_Component) { - babelHelpers.inherits(PollVote, _Component); - - function PollVote() { - babelHelpers.classCallCheck(this, PollVote); - return babelHelpers.possibleConstructorReturn(this, (PollVote.__proto__ || Object.getPrototypeOf(PollVote)).apply(this, arguments)); - } - - babelHelpers.createClass(PollVote, [{ - key: 'init', - value: function init() { - var _this2 = this; - - this.poll = this.props.poll; - this.votes = this.poll.votes(); - this.voted = m.prop(false); - this.user = app.session.user; - this.answers = []; - - this.poll.answers().forEach(function (answer) { - _this2.answers[answer.id()] = answer; - }); - - if (this.user !== undefined) { - if (!this.user.canVote()) { - this.voted(true); - } else { - app.store.find('votes', { - poll_id: this.poll.id(), - user_id: this.user.id() - }).then(function (data) { - if (data[0] !== undefined) { - _this2.voted(data[0]); - } else if (_this2.poll.isEnded()) { - _this2.voted(true); - } - - m.redraw(); - }); - } - } - } - }, { - key: 'showVoters', - value: function showVoters() { - app.modal.show(new ShowVotersModal(this.poll)); - } - }, { - key: 'onError', - value: function onError(el, error) { - el.srcElement.checked = false; - - app.alerts.show(error.alert); - } - }, { - key: 'changeVote', - value: function changeVote(answer, el) { - var _this3 = this; - - var oldVoteId = this.voted().id(); - var oldAnswerId = this.voted().option_id(); - app.request({ - method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/votes/' + answer.id(), - errorHandler: this.onError.bind(this, el), - data: { - option_id: answer.id(), - poll_id: this.poll.id() - } - }).then(function (response) { - _this3.answers[answer.id()].data.attributes.votes++; - _this3.answers[oldAnswerId].data.attributes.votes--; - _this3.votes.some(function (vote, i) { - if (vote.data.id === oldVoteId) { - _this3.votes[i].data.attributes.option_id = response.data.attributes.option_id; - } - }); - _this3.poll.data.relationships.votes.data.some(function (vote) { - if (typeof vote.id === "function") { - var id = vote.id(); - } else { - var id = vote.id; - } - if (oldVoteId === parseInt(id)) { - vote.option_id = m.prop(response.data.attributes.option_id); - return true; - } - }); - _this3.poll.votes = m.prop(_this3.votes); - m.redraw.strategy('all'); - m.redraw(); - }); - } - }, { - key: 'view', - value: function view() { - var _this4 = this; - - if (this.voted() !== false) { - return m( - 'div', - null, - m( - 'h3', - null, - this.poll.question() - ), - this.answers.map(function (item) { - var voted = false; - if (_this4.voted() !== true) { - voted = parseInt(_this4.voted().option_id()) === item.data.attributes.id; - m.redraw(); - } - var percent = Math.round(item.votes() / _this4.poll.votes().length * 100); - return m( - 'div', - { className: 'PollOption PollVoted' }, - m( - 'div', - { - title: item.votes() >= 1 ? item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.vote') : item.votes() + ' ' + app.translator.trans('reflar-polls.forum.tooltip.votes'), - className: 'PollBar', - 'data-selected': voted, - config: function config(element) { - $(element).tooltip({ placement: 'right' }); - } }, - !_this4.poll.isEnded() && _this4.voted !== true ? m( - 'label', - { className: 'checkbox' }, - voted ? m('input', { onchange: _this4.changeVote.bind(_this4, item), type: 'checkbox', checked: true }) : m('input', { onchange: _this4.changeVote.bind(_this4, item), type: 'checkbox' }), - m('span', { className: 'checkmark' }) - ) : '', - m('div', { style: '--width: ' + percent + '%', className: 'PollOption-active' }), - m( - 'label', - { style: !_this4.poll.isEnded() ? "margin-left: 25px" : '', className: 'PollAnswer' }, - m( - 'span', - null, - item.answer() - ) - ), - m( - 'label', - null, - m( - 'span', - { className: percent !== 100 ? 'PollPercent PollPercent--option' : 'PollPercent' }, - percent, - '%' - ) - ) - ) - ); - }), - m('div', { className: 'clear' }), - this.poll.isPublic() ? Button.component({ - className: 'Button Button--primary PublicPollButton', - children: app.translator.trans('reflar-polls.forum.public_poll'), - onclick: function onclick() { - app.modal.show(new ShowVotersModal({ votes: _this4.votes, answers: _this4.answers })); - } - }) : '', - m('div', { className: 'clear' }), - !this.user.canVote() ? m( - 'div', - { className: 'helpText PollInfoText' }, - app.translator.trans('reflar-polls.forum.no_permission') - ) : this.poll.isEnded() ? m( - 'div', - { className: 'helpText PollInfoText' }, - app.translator.trans('reflar-polls.forum.poll_ended') - ) : !isNaN(new Date(this.poll.endDate())) ? m( - 'div', - { className: 'helpText PollInfoText' }, - m('i', { 'class': 'icon fa fa-clock-o' }), - ' ', - app.translator.trans('reflar-polls.forum.days_remaining', { time: moment(this.poll.endDate()).fromNow() }) - ) : '', - m('div', { className: 'clear' }) - ); - } else { - return m( - 'div', - null, - m( - 'h3', - null, - this.poll.question() - ), - this.answers.map(function (item) { - return m( - 'div', - { className: 'PollOption' }, - m( - 'div', - { className: 'PollBar' }, - m( - 'label', - { className: 'checkbox' }, - m('input', { type: 'checkbox', onchange: _this4.addVote.bind(_this4, item) }), - m( - 'span', - null, - item.answer() - ), - m('span', { className: 'checkmark' }) - ) - ) - ); - }), - m('div', { className: 'clear' }), - this.poll.isPublic() && app.session.user !== undefined ? Button.component({ - className: 'Button Button--primary PublicPollButton', - children: app.translator.trans('reflar-polls.forum.public_poll'), - onclick: function onclick() { - app.modal.show(new ShowVotersModal(_this4.poll)); - } - }) : '', - this.poll.isEnded() ? m( - 'div', - { className: 'helpText PollInfoText' }, - app.translator.trans('reflar-polls.forum.poll_ended') - ) : !isNaN(new Date(this.poll.endDate())) ? m( - 'div', - { className: 'helpText PollInfoText' }, - m('i', { 'class': 'icon fa fa-clock-o' }), - ' ', - app.translator.trans('reflar-polls.forum.days_remaining', { time: moment(this.poll.endDate()).fromNow() }) - ) : '' - ); - } - } - }, { - key: 'addVote', - value: function addVote(answer, el) { - var _this5 = this; - - if (this.user === undefined) { - app.modal.show(new LogInModal()); - el.srcElement.checked = false; - } else { - app.store.createRecord('votes').save({ - poll_id: this.poll.id(), - option_id: answer.id() - }).then(function (vote) { - _this5.answers[answer.id()].data.attributes.votes++; - _this5.voted(vote); - _this5.poll.data.relationships.votes.data.push(vote); - _this5.votes.push(vote); - m.redraw(); - }); - } - } - }]); - return PollVote; - }(Component); - - _export('default', PollVote); - } - }; -});; -'use strict'; - -System.register('reflar/polls/components/ShowVotersModal', ['flarum/components/Modal', 'flarum/utils/ItemList', 'flarum/helpers/avatar', 'flarum/helpers/username', 'flarum/helpers/listItems'], function (_export, _context) { - "use strict"; - - var Modal, ItemList, avatar, username, listItems, ShowVotersModal; - return { - setters: [function (_flarumComponentsModal) { - Modal = _flarumComponentsModal.default; - }, function (_flarumUtilsItemList) { - ItemList = _flarumUtilsItemList.default; - }, function (_flarumHelpersAvatar) { - avatar = _flarumHelpersAvatar.default; - }, function (_flarumHelpersUsername) { - username = _flarumHelpersUsername.default; - }, function (_flarumHelpersListItems) { - listItems = _flarumHelpersListItems.default; - }], - execute: function () { - ShowVotersModal = function (_Modal) { - babelHelpers.inherits(ShowVotersModal, _Modal); - - function ShowVotersModal() { - babelHelpers.classCallCheck(this, ShowVotersModal); - return babelHelpers.possibleConstructorReturn(this, (ShowVotersModal.__proto__ || Object.getPrototypeOf(ShowVotersModal)).apply(this, arguments)); - } - - babelHelpers.createClass(ShowVotersModal, [{ - key: 'className', - value: function className() { - return 'Modal--small'; - } - }, { - key: 'title', - value: function title() { - return app.translator.trans('reflar-polls.forum.votes_modal.title'); - } - }, { - key: 'getUsers', - value: function getUsers(answer) { - var votes = []; - if (typeof this.props.votes === 'function') { - votes = this.props.votes(); - } else { - votes = this.props.votes; - } - var items = new ItemList(); - var counter = 0; - - votes.map(function (vote) { - var user = app.store.getById('users', vote.data.attributes.user_id); - - if (parseInt(answer.id()) === parseInt(vote.data.attributes.option_id)) { - counter++; - items.add(user.id(), m( - 'a', - { href: app.route.user(user), config: m.route }, - avatar(user), - ' ', - ' ', - username(user) - )); - } - }); - - if (counter === 0) { - items.add('none', m( - 'h4', - { style: 'color: #000' }, - app.translator.trans('reflar-polls.forum.modal.no_voters') - )); - } - - return items; - } - }, { - key: 'content', - value: function content() { - var _this2 = this; - - if (typeof this.props.answers === 'function') { - this.answers = this.props.answers(); - } else { - this.answers = this.props.answers; - } - return m( - 'div', - { className: 'Modal-body' }, - m( - 'ul', - { className: 'VotesModal-list' }, - this.answers.map(function (answer) { - return m( - 'div', - null, - m( - 'h2', - null, - answer.answer() + ':' - ), - listItems(_this2.getUsers(answer).toArray()) - ); - }) - ) - ); - } - }]); - return ShowVotersModal; - }(Modal); - - _export('default', ShowVotersModal); - } - }; -});; -'use strict'; - -System.register('reflar/polls/main', ['flarum/app', 'flarum/extend', 'flarum/components/DiscussionComposer', 'flarum/Model', 'reflar/polls/models/Question', 'reflar/polls/models/Answer', 'reflar/polls/models/Vote', 'flarum/models/Discussion', 'flarum/models/User', './addPollBadge', './PollControl', './PollDiscussion', './components/PollModal'], function (_export, _context) { - "use strict"; - - var app, extend, override, DiscussionComposer, Model, Question, Answer, Vote, Discussion, User, addPollBadege, PollControl, PollDiscussion, PollModal; - return { - setters: [function (_flarumApp) { - app = _flarumApp.default; - }, function (_flarumExtend) { - extend = _flarumExtend.extend; - override = _flarumExtend.override; - }, function (_flarumComponentsDiscussionComposer) { - DiscussionComposer = _flarumComponentsDiscussionComposer.default; - }, function (_flarumModel) { - Model = _flarumModel.default; - }, function (_reflarPollsModelsQuestion) { - Question = _reflarPollsModelsQuestion.default; - }, function (_reflarPollsModelsAnswer) { - Answer = _reflarPollsModelsAnswer.default; - }, function (_reflarPollsModelsVote) { - Vote = _reflarPollsModelsVote.default; - }, function (_flarumModelsDiscussion) { - Discussion = _flarumModelsDiscussion.default; - }, function (_flarumModelsUser) { - User = _flarumModelsUser.default; - }, function (_addPollBadge) { - addPollBadege = _addPollBadge.default; - }, function (_PollControl) { - PollControl = _PollControl.default; - }, function (_PollDiscussion) { - PollDiscussion = _PollDiscussion.default; - }, function (_componentsPollModal) { - PollModal = _componentsPollModal.default; - }], - execute: function () { - - app.initializers.add('reflar-polls', function (app) { - // Relationships - app.store.models.answers = Answer; - app.store.models.questions = Question; - app.store.models.votes = Vote; - - Discussion.prototype.Poll = Model.hasOne('Poll'); - - User.prototype.canEditPolls = Model.attribute('canEditPolls'); - User.prototype.canStartPolls = Model.attribute('canStartPolls'); - User.prototype.canSelfEditPolls = Model.attribute('canSelfEditPolls'); - User.prototype.canVote = Model.attribute('canVote'); - - DiscussionComposer.prototype.addPoll = function (data) { - app.modal.show(new PollModal(data)); - }; - - // Add button to DiscussionComposer header - extend(DiscussionComposer.prototype, 'headerItems', function (items) { - if (app.session.user.canStartPolls()) { - items.add('polls', m( - 'a', - { className: 'DiscussionComposer-poll', onclick: this.addPoll.bind(this, this.data()) }, - this.data().poll ? m( - 'span', - { className: 'PollLabel' }, - app.translator.trans('reflar-polls.forum.composer_discussion.edit') - ) : m( - 'span', - { className: 'PollLabel' }, - app.translator.trans('reflar-polls.forum.composer_discussion.add_poll') - ) - ), 1); - } - }); - - extend(DiscussionComposer.prototype, 'onsubmit', function () { - extend(DiscussionComposer.prototype, 'data', function (data) { - data.poll = undefined; - }); - }); - - addPollBadege(); - PollDiscussion(); - PollControl(); - }); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Answer', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Answer; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Answer = function (_mixin) { - babelHelpers.inherits(Answer, _mixin); - - function Answer() { - babelHelpers.classCallCheck(this, Answer); - return babelHelpers.possibleConstructorReturn(this, (Answer.__proto__ || Object.getPrototypeOf(Answer)).apply(this, arguments)); - } - - return Answer; - }(mixin(Model, { - answer: Model.attribute('answer'), - votes: Model.attribute('votes'), - percent: Model.attribute('percent') - })); - - _export('default', Answer); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Question', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Question; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Question = function (_mixin) { - babelHelpers.inherits(Question, _mixin); - - function Question() { - babelHelpers.classCallCheck(this, Question); - return babelHelpers.possibleConstructorReturn(this, (Question.__proto__ || Object.getPrototypeOf(Question)).apply(this, arguments)); - } - - return Question; - }(mixin(Model, { - question: Model.attribute('question'), - answers: Model.hasMany('answers'), - votes: Model.hasMany('votes'), - isEnded: Model.attribute('isEnded'), - endDate: Model.attribute('endDate'), - isPublic: Model.attribute('isPublic') - })); - - _export('default', Question); - } - }; -});; -'use strict'; - -System.register('reflar/polls/models/Vote', ['flarum/Model', 'flarum/utils/mixin'], function (_export, _context) { - "use strict"; - - var Model, mixin, Vote; - return { - setters: [function (_flarumModel) { - Model = _flarumModel.default; - }, function (_flarumUtilsMixin) { - mixin = _flarumUtilsMixin.default; - }], - execute: function () { - Vote = function (_mixin) { - babelHelpers.inherits(Vote, _mixin); - - function Vote() { - babelHelpers.classCallCheck(this, Vote); - return babelHelpers.possibleConstructorReturn(this, (Vote.__proto__ || Object.getPrototypeOf(Vote)).apply(this, arguments)); - } - - return Vote; - }(mixin(Model, { - poll_id: Model.attribute('poll_id'), - user_id: Model.attribute('user_id'), - option_id: Model.attribute('option_id') - })); - - _export('default', Vote); - } - }; -});; -'use strict'; - -System.register('reflar/polls/PollControl', ['flarum/extend', 'flarum/utils/PostControls', 'flarum/components/Button', 'reflar/polls/components/EditPollModal'], function (_export, _context) { - "use strict"; - - var extend, PostControls, Button, EditPollModal; - - _export('default', function () { - extend(PostControls, 'moderationControls', function (items, post) { - var discussion = post.discussion(); - var poll = discussion.Poll(); - var user = app.session.user; - - if (discussion.Poll() && (user !== undefined && user.canEditPolls() || post.user().canSelfEditPolls() && post.user().id() === user.id()) && post.number() === 1) { - if (!poll.isEnded()) { - items.add('editPoll', [m(Button, { - icon: 'check-square', - className: 'reflar-PollButton', - onclick: function onclick() { - app.modal.show(new EditPollModal({ post: post, poll: poll })); - } - }, app.translator.trans('reflar-polls.forum.moderation.edit'))]); - } - - items.add('removePoll', [m(Button, { - icon: 'trash', - className: 'reflar-PollButton', - onclick: function onclick() { - - if (confirm(app.translator.trans('reflar-polls.forum.moderation.delete_confirm'))) { - app.request({ - url: app.forum.attribute('apiUrl') + '/questions/' + poll.id(), - method: 'DELETE', - data: poll.store.data.users[Object.keys(poll.store.data.users)[0]].id() - }).then(function () { - location.reload(); - }); - } - } - }, app.translator.trans('reflar-polls.forum.moderation.delete'))]); - } - }); - }); - - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - }, function (_flarumUtilsPostControls) { - PostControls = _flarumUtilsPostControls.default; - }, function (_flarumComponentsButton) { - Button = _flarumComponentsButton.default; - }, function (_reflarPollsComponentsEditPollModal) { - EditPollModal = _reflarPollsComponentsEditPollModal.default; - }], - execute: function () {} - }; -});; -'use strict'; - -System.register('reflar/polls/PollDiscussion', ['flarum/extend', 'flarum/components/CommentPost', 'reflar/polls/components/PollVote'], function (_export, _context) { - "use strict"; - - var extend, override, CommentPost, PollVote; - - _export('default', function () { - extend(CommentPost.prototype, 'content', function (content) { - var discussion = this.props.post.discussion(); - - if (discussion.Poll() && this.props.post.number() === 1 && !this.props.post.isHidden()) { - this.subtree.invalidate(); - - content.push(PollVote.component({ - poll: discussion.Poll() - })); - } - }); - }); - - return { - setters: [function (_flarumExtend) { - extend = _flarumExtend.extend; - override = _flarumExtend.override; - }, function (_flarumComponentsCommentPost) { - CommentPost = _flarumComponentsCommentPost.default; - }, function (_reflarPollsComponentsPollVote) { - PollVote = _reflarPollsComponentsPollVote.default; - }], - execute: function () {} - }; -}); \ No newline at end of file diff --git a/js/forum/package.json b/js/forum/package.json deleted file mode 100644 index e02bcdb..0000000 --- a/js/forum/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "private": true, - "devDependencies": { - "flarum-gulp": "^0.2.0", - "gulp": "^3.8.11" - }, - "dependencies": { - "datetimepicker": "0.1.38" - } -} diff --git a/js/package.json b/js/package.json new file mode 100644 index 0000000..9298c44 --- /dev/null +++ b/js/package.json @@ -0,0 +1,14 @@ +{ + "name": "@reflar/polls", + "version": "0.0.0", + "dependencies": { + "flarum-webpack-config": "^0.1.0-beta.8", + "webpack": "^4.0.0", + "datetimepicker": "0.1.38", + "webpack-cli": "^3.0.7" + }, + "scripts": { + "build": "webpack --mode production", + "watch": "webpack --mode development --watch" + } +} diff --git a/js/admin/src/main.js b/js/src/admin/index.js similarity index 88% rename from js/admin/src/main.js rename to js/src/admin/index.js index dfbeb19..f22d163 100644 --- a/js/admin/src/main.js +++ b/js/src/admin/index.js @@ -6,26 +6,26 @@ import PermissionGrid from 'flarum/components/PermissionGrid'; app.initializers.add('reflar-polls', app => { extend(PermissionGrid.prototype, 'moderateItems', items => { items.add('reflar-polls', { - icon: 'pencil', + icon: 'fa fa-pencil-alt', label: app.translator.trans('reflar-polls.admin.permissions.moderate'), permission: 'discussion.polls' }, 95); }); extend(PermissionGrid.prototype, 'startItems', items => { items.add('reflar-polls-start', { - icon: 'signal', + icon: 'fa fa-signal', label: app.translator.trans('reflar-polls.admin.permissions.start'), permission: 'startPolls' }, 95); }); extend(PermissionGrid.prototype, 'replyItems', items => { items.add('reflar-polls-edit', { - icon: 'pencil', + icon: 'fa fa-pencil-alt', label: app.translator.trans('reflar-polls.admin.permissions.self_edit'), permission: 'selfEditPolls' }, 70); items.add('reflar-polls-vote', { - icon: 'signal', + icon: 'fa fa-signal', label: app.translator.trans('reflar-polls.admin.permissions.vote'), permission: 'votePolls' }, 80); diff --git a/js/src/common/index.js b/js/src/common/index.js new file mode 100644 index 0000000..e69de29 diff --git a/js/lib/models/Answer.js b/js/src/common/models/Answer.js similarity index 70% rename from js/lib/models/Answer.js rename to js/src/common/models/Answer.js index 3836efe..0e11aef 100644 --- a/js/lib/models/Answer.js +++ b/js/src/common/models/Answer.js @@ -6,4 +6,7 @@ export default class Answer extends mixin(Model, { votes: Model.attribute('votes'), percent: Model.attribute('percent') }) { + apiEndpoint() { + return `/reflar/polls/answers${this.exists ? `/${this.data.id}` : ''}`; + } } diff --git a/js/lib/models/Question.js b/js/src/common/models/Question.js similarity index 70% rename from js/lib/models/Question.js rename to js/src/common/models/Question.js index f482f6d..6a6f332 100644 --- a/js/lib/models/Question.js +++ b/js/src/common/models/Question.js @@ -3,10 +3,14 @@ import mixin from 'flarum/utils/mixin'; export default class Question extends mixin(Model, { question: Model.attribute('question'), - answers: Model.hasMany('answers'), - votes: Model.hasMany('votes'), isEnded: Model.attribute('isEnded'), endDate: Model.attribute('endDate'), - isPublic: Model.attribute('isPublic') + isPublic: Model.attribute('isPublic'), + + answers: Model.hasMany('answers'), + votes: Model.hasMany('votes'), }) { + apiEndpoint() { + return `/reflar/polls${this.exists ? `/${this.data.id}` : ''}`; + } } diff --git a/js/lib/models/Vote.js b/js/src/common/models/Vote.js similarity index 71% rename from js/lib/models/Vote.js rename to js/src/common/models/Vote.js index 3a91360..ec72702 100644 --- a/js/lib/models/Vote.js +++ b/js/src/common/models/Vote.js @@ -6,4 +6,7 @@ export default class Vote extends mixin(Model, { user_id: Model.attribute('user_id'), option_id: Model.attribute('option_id'), }) { + apiEndpoint() { + return `/reflar/polls/votes${this.exists ? `/${this.data.id}` : ''}`; + } } diff --git a/js/forum/src/PollControl.js b/js/src/forum/PollControl.js similarity index 87% rename from js/forum/src/PollControl.js rename to js/src/forum/PollControl.js index 4f42d7c..bdf93e8 100644 --- a/js/forum/src/PollControl.js +++ b/js/src/forum/PollControl.js @@ -2,7 +2,7 @@ import {extend} from 'flarum/extend'; import PostControls from 'flarum/utils/PostControls'; import Button from 'flarum/components/Button'; -import EditPollModal from 'reflar/polls/components/EditPollModal'; +import EditPollModal from './components/EditPollModal'; export default function () { extend(PostControls, 'moderationControls', function (items, post) { @@ -14,7 +14,7 @@ export default function () { if (!poll.isEnded()) { items.add('editPoll', [ m(Button, { - icon: 'check-square', + icon: 'fa fa-check-square', className: 'reflar-PollButton', onclick: () => { app.modal.show(new EditPollModal({post: post, poll: poll})); @@ -25,13 +25,13 @@ export default function () { items.add('removePoll', [ m(Button, { - icon: 'trash', + icon: 'fa fa-trash', className: 'reflar-PollButton', onclick: () => { if (confirm(app.translator.trans('reflar-polls.forum.moderation.delete_confirm'))) { app.request({ - url: app.forum.attribute('apiUrl') + '/questions/' + poll.id(), + url: `${app.forum.attribute('apiUrl')}/reflar/polls/${poll.id()}`, method: 'DELETE', data: poll.store.data.users[Object.keys(poll.store.data.users)[0]].id() }).then(() => { diff --git a/js/forum/src/PollDiscussion.js b/js/src/forum/PollDiscussion.js similarity index 89% rename from js/forum/src/PollDiscussion.js rename to js/src/forum/PollDiscussion.js index 0dffaf6..d9244fc 100644 --- a/js/forum/src/PollDiscussion.js +++ b/js/src/forum/PollDiscussion.js @@ -1,7 +1,7 @@ import { extend, override } from 'flarum/extend'; import CommentPost from 'flarum/components/CommentPost'; -import PollVote from 'reflar/polls/components/PollVote'; +import PollVote from './components/PollVote'; export default function() { extend(CommentPost.prototype, 'content', function(content) { diff --git a/js/forum/src/addPollBadge.js b/js/src/forum/addPollBadge.js similarity index 92% rename from js/forum/src/addPollBadge.js rename to js/src/forum/addPollBadge.js index c2fb7c6..c48a8ba 100644 --- a/js/forum/src/addPollBadge.js +++ b/js/src/forum/addPollBadge.js @@ -8,7 +8,7 @@ export default function addPollBadge() { badges.add('poll', Badge.component({ type: 'poll', label: app.translator.trans('reflar-polls.forum.tooltip.badge'), - icon: 'signal' + icon: 'fa fa-signal' }), 5); } }); diff --git a/js/forum/src/components/EditPollModal.js b/js/src/forum/components/EditPollModal.js similarity index 93% rename from js/forum/src/components/EditPollModal.js rename to js/src/forum/components/EditPollModal.js index a7f7658..63e5ecc 100644 --- a/js/forum/src/components/EditPollModal.js +++ b/js/src/forum/components/EditPollModal.js @@ -56,10 +56,11 @@ export default class EditPollModal extends Modal { dateTimeFormat: "yyyy-MM-dd HH:mm", minDateTime: this.getDateTime(), settingValueOfElement: (value) => { - this.endDate(value) + this.endDate(value); + app.request({ method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/endDate/' + this.props.poll.id(), + url: `${app.forum.attribute('apiUrl')}/reflar/polls/${this.props.poll.id()}/endDate`, data: { date: new Date(value), user_id: this.pollCreator.id() @@ -95,7 +96,7 @@ export default class EditPollModal extends Modal { Button.component({ type: 'button', className: 'Button Button--warning Poll-answer-button', - icon: 'minus', + icon: 'fa fa-minus', onclick: i + 1 >= 3 ? this.removeOption.bind(this, answer) : '' }) : ''}
@@ -112,7 +113,7 @@ export default class EditPollModal extends Modal { {Button.component({ type: 'button', className: 'Button Button--warning Poll-answer-button', - icon: 'plus', + icon: 'fa fa-plus', onclick: this.addAnswer.bind(this) })}
@@ -171,7 +172,7 @@ export default class EditPollModal extends Modal { removeOption(option) { app.request({ method: 'DELETE', - url: app.forum.attribute('apiUrl') + '/answers/' + option.data.id, + url: `${app.forum.attribute('apiUrl')}/reflar/polls/answers/${option.data.id}`, data: this.pollCreator.id() }); this.answers.some((answer, i) => { @@ -185,7 +186,7 @@ export default class EditPollModal extends Modal { updateAnswer(answerToUpdate, value) { app.request({ method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/answers/' + answerToUpdate.data.id, + url: `${app.forum.attribute('apiUrl')}/reflar/polls/answers/${answerToUpdate.data.id}`, data: { answer: value, user_id: this.pollCreator.id() @@ -207,7 +208,7 @@ export default class EditPollModal extends Modal { } app.request({ method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/questions/' + this.props.poll.id(), + url: `${app.forum.attribute('apiUrl')}/reflar/polls/${this.props.poll.id()}`, data: { question: question, user_id: this.pollCreator.id() @@ -216,4 +217,4 @@ export default class EditPollModal extends Modal { this.question = m.prop(question) m.redraw() } -} \ No newline at end of file +} diff --git a/js/forum/src/components/PollModal.js b/js/src/forum/components/PollModal.js similarity index 98% rename from js/forum/src/components/PollModal.js rename to js/src/forum/components/PollModal.js index 792ede7..24f7eb2 100644 --- a/js/forum/src/components/PollModal.js +++ b/js/src/forum/components/PollModal.js @@ -3,6 +3,7 @@ import Modal from 'flarum/components/Modal'; import Button from 'flarum/components/Button'; import DiscussionComposer from 'flarum/components/DiscussionComposer'; import Switch from "flarum/components/Switch"; +import DateTimePicker from "DateTimePicker"; export default class PollModal extends Modal { init() { @@ -95,7 +96,7 @@ export default class PollModal extends Modal { Button.component({ type: 'button', className: 'Button Button--warning Poll-answer-button', - icon: 'minus', + icon: 'fa fa-minus', onclick: i + 1 >= 3 ? this.removeOption.bind(this, i) : '' }) : ''}
diff --git a/js/forum/src/components/PollVote.js b/js/src/forum/components/PollVote.js similarity index 98% rename from js/forum/src/components/PollVote.js rename to js/src/forum/components/PollVote.js index 0cbcf17..8037b28 100644 --- a/js/forum/src/components/PollVote.js +++ b/js/src/forum/components/PollVote.js @@ -21,7 +21,7 @@ export default class PollVote extends Component { if (!this.user.canVote()) { this.voted(true) } else { - app.store.find('votes', { + app.store.find('reflar/polls/votes', { poll_id: this.poll.id(), user_id: this.user.id() }).then((data) => { @@ -53,7 +53,7 @@ export default class PollVote extends Component { var oldAnswerId = this.voted().option_id() app.request({ method: 'PATCH', - url: app.forum.attribute('apiUrl') + '/votes/' + answer.id(), + url: `${app.forum.attribute('apiUrl')}/reflar/polls/votes/${answer.id()}`, errorHandler: this.onError.bind(this, el), data: { option_id: answer.id(), diff --git a/js/forum/src/components/ShowVotersModal.js b/js/src/forum/components/ShowVotersModal.js similarity index 100% rename from js/forum/src/components/ShowVotersModal.js rename to js/src/forum/components/ShowVotersModal.js diff --git a/js/forum/src/main.js b/js/src/forum/index.js similarity index 93% rename from js/forum/src/main.js rename to js/src/forum/index.js index 9959b07..d9ccb59 100644 --- a/js/forum/src/main.js +++ b/js/src/forum/index.js @@ -4,9 +4,9 @@ import {extend, override} from 'flarum/extend'; import DiscussionComposer from 'flarum/components/DiscussionComposer'; import Model from 'flarum/Model'; -import Question from 'reflar/polls/models/Question'; -import Answer from 'reflar/polls/models/Answer'; -import Vote from 'reflar/polls/models/Vote'; +import Question from '../common/models/Question'; +import Answer from '../common/models/Answer'; +import Vote from '../common/models/Vote'; import Discussion from 'flarum/models/Discussion'; import User from 'flarum/models/User'; @@ -27,7 +27,7 @@ app.initializers.add('reflar-polls', app => { User.prototype.canStartPolls = Model.attribute('canStartPolls'); User.prototype.canSelfEditPolls = Model.attribute('canSelfEditPolls'); User.prototype.canVote = Model.attribute('canVote'); - + DiscussionComposer.prototype.addPoll = function(data) { app.modal.show(new PollModal(data)); }; diff --git a/js/webpack.config.js b/js/webpack.config.js new file mode 100644 index 0000000..fcfa77c --- /dev/null +++ b/js/webpack.config.js @@ -0,0 +1,3 @@ +const config = require('flarum-webpack-config'); + +module.exports = config(); diff --git a/migrations/2018_04_27_203645_add_default_poll_permissions.php b/migrations/2018_04_27_203645_add_default_poll_permissions.php index 4714b18..ec58b21 100644 --- a/migrations/2018_04_27_203645_add_default_poll_permissions.php +++ b/migrations/2018_04_27_203645_add_default_poll_permissions.php @@ -1,36 +1,10 @@ 3, - 'permission' => 'startPolls', - ], - [ - 'group_id' => 3, - 'permission' => 'votePolls', - ], - [ - 'group_id' => 3, - 'permission' => 'selfEditPolls', - ], -]; - -return [ - 'up' => function (ConnectionInterface $db) use ($permissionAttributes) { - foreach ($permissionAttributes as $permissionAttribute) { - $instance = $db->table('permissions')->where($permissionAttribute)->first(); - - if (is_null($instance)) { - $db->table('permissions')->insert($permissionAttribute); - } - } - }, - - 'down' => function (ConnectionInterface $db) use ($permissionAttributes) { - foreach ($permissionAttributes as $permissionAttribute) { - $db->table('permissions')->where($permissionAttribute)->delete(); - } - }, -]; +use Flarum\Database\Migration; +use Flarum\Group\Group; + +return Migration::addPermissions([ + 'startPolls' => Group::MEMBER_ID, + 'votePolls' => Group::MEMBER_ID, + 'selfEditPolls' => Group::MEMBER_ID, +]); diff --git a/css/forum/Gulpfile.js b/resources/css/Gulpfile.js similarity index 100% rename from css/forum/Gulpfile.js rename to resources/css/Gulpfile.js diff --git a/css/forum/dist/DateTimePicker.min.css b/resources/css/dist/DateTimePicker.min.css similarity index 100% rename from css/forum/dist/DateTimePicker.min.css rename to resources/css/dist/DateTimePicker.min.css diff --git a/css/forum/package.json b/resources/css/package.json similarity index 100% rename from css/forum/package.json rename to resources/css/package.json diff --git a/src/Answer.php b/src/Answer.php index 12ac565..b1f521f 100644 --- a/src/Answer.php +++ b/src/Answer.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Api/Controllers/CreateAnswerController.php b/src/Api/Controllers/CreateAnswerController.php index 5543ddf..027e47b 100644 --- a/src/Api/Controllers/CreateAnswerController.php +++ b/src/Api/Controllers/CreateAnswerController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,7 +13,7 @@ namespace Reflar\Polls\Api\Controllers; use Flarum\Api\Controller\AbstractCreateController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Answer; use Reflar\Polls\Api\Serializers\AnswerSerializer; diff --git a/src/Api/Controllers/CreateVoteController.php b/src/Api/Controllers/CreateVoteController.php index 3b32dfb..8bb3f62 100644 --- a/src/Api/Controllers/CreateVoteController.php +++ b/src/Api/Controllers/CreateVoteController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -14,11 +14,12 @@ use DateTime; use Flarum\Api\Controller\AbstractCreateController; -use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\FloodingException; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\Post\Exception\FloodingException; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\VoteSerializer; +use Reflar\Polls\Events\PollWasVoted; use Reflar\Polls\Question; use Reflar\Polls\Vote; use Tobscure\JsonApi\Document; @@ -49,7 +50,9 @@ protected function data(ServerRequestInterface $request, Document $document) $this->assertNotFlooding($actor); - if (Question::find($attributes['poll_id'])->isEnded()) { + $question = Question::find($attributes['poll_id']); + + if ($question->isEnded()) { throw new PermissionDeniedException(); } @@ -62,6 +65,8 @@ protected function data(ServerRequestInterface $request, Document $document) $vote->save(); + app()->make('events')->fire(new PollWasVoted($vote, $question, $actor)); + return $vote; } diff --git a/src/Api/Controllers/DeleteAnswerController.php b/src/Api/Controllers/DeleteAnswerController.php index eaf3328..85f4f00 100644 --- a/src/Api/Controllers/DeleteAnswerController.php +++ b/src/Api/Controllers/DeleteAnswerController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,7 +13,7 @@ namespace Reflar\Polls\Api\Controllers; use Flarum\Api\Controller\AbstractDeleteController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Answer; use Reflar\Polls\Api\Serializers\AnswerSerializer; diff --git a/src/Api/Controllers/DeletePollController.php b/src/Api/Controllers/DeletePollController.php index 09ecaf2..847e140 100644 --- a/src/Api/Controllers/DeletePollController.php +++ b/src/Api/Controllers/DeletePollController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,7 +13,7 @@ namespace Reflar\Polls\Api\Controllers; use Flarum\Api\Controller\AbstractDeleteController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\QuestionSerializer; use Reflar\Polls\Question; diff --git a/src/Api/Controllers/ListPollController.php b/src/Api/Controllers/ListPollController.php index 13f108c..028d53e 100644 --- a/src/Api/Controllers/ListPollController.php +++ b/src/Api/Controllers/ListPollController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,14 +12,14 @@ namespace Reflar\Polls\Api\Controllers; -use Flarum\Api\Controller\AbstractCollectionController; -use Flarum\Core\Access\AssertPermissionTrait; +use Flarum\Api\Controller\AbstractListController; +use Flarum\User\AssertPermissionTrait; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\QuestionSerializer; use Reflar\Polls\Repositories\QuestionRepository; use Tobscure\JsonApi\Document; -class ListPollController extends AbstractCollectionController +class ListPollController extends AbstractListController { use AssertPermissionTrait; diff --git a/src/Api/Controllers/ListVotesController.php b/src/Api/Controllers/ListVotesController.php index 86215ae..3e3492b 100644 --- a/src/Api/Controllers/ListVotesController.php +++ b/src/Api/Controllers/ListVotesController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,13 +12,13 @@ namespace Reflar\Polls\Api\Controllers; -use Flarum\Api\Controller\AbstractCollectionController; +use Flarum\Api\Controller\AbstractListController; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\VoteSerializer; use Reflar\Polls\Repositories\VoteRepository; use Tobscure\JsonApi\Document; -class ListVotesController extends AbstractCollectionController +class ListVotesController extends AbstractListController { public $serializer = VoteSerializer::class; diff --git a/src/Api/Controllers/UpdateAnswerController.php b/src/Api/Controllers/UpdateAnswerController.php index e32e4ba..4d76135 100644 --- a/src/Api/Controllers/UpdateAnswerController.php +++ b/src/Api/Controllers/UpdateAnswerController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,7 +13,7 @@ namespace Reflar\Polls\Api\Controllers; use Flarum\Api\Controller\AbstractResourceController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Answer; use Reflar\Polls\Api\Serializers\AnswerSerializer; diff --git a/src/Api/Controllers/UpdateEndDateController.php b/src/Api/Controllers/UpdateEndDateController.php index bdb4f62..6e3c50f 100644 --- a/src/Api/Controllers/UpdateEndDateController.php +++ b/src/Api/Controllers/UpdateEndDateController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,15 +12,15 @@ namespace Reflar\Polls\Api\Controllers; -use Flarum\Api\Controller\AbstractResourceController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\Api\Controller\AbstractShowController; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\QuestionSerializer; use Reflar\Polls\Question; use Reflar\Polls\Repositories\QuestionRepository; use Tobscure\JsonApi\Document; -class UpdateEndDateController extends AbstractResourceController +class UpdateEndDateController extends AbstractShowController { public $serializer = QuestionSerializer::class; diff --git a/src/Api/Controllers/UpdatePollController.php b/src/Api/Controllers/UpdatePollController.php index 6e786ac..fc76e1a 100644 --- a/src/Api/Controllers/UpdatePollController.php +++ b/src/Api/Controllers/UpdatePollController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,15 +12,15 @@ namespace Reflar\Polls\Api\Controllers; -use Flarum\Api\Controller\AbstractResourceController; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\Api\Controller\AbstractShowController; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\QuestionSerializer; use Reflar\Polls\Question; use Reflar\Polls\Repositories\QuestionRepository; use Tobscure\JsonApi\Document; -class UpdatePollController extends AbstractResourceController +class UpdatePollController extends AbstractShowController { public $serializer = QuestionSerializer::class; diff --git a/src/Api/Controllers/UpdateVoteController.php b/src/Api/Controllers/UpdateVoteController.php index 1024d91..6502437 100644 --- a/src/Api/Controllers/UpdateVoteController.php +++ b/src/Api/Controllers/UpdateVoteController.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,17 +13,18 @@ namespace Reflar\Polls\Api\Controllers; use DateTime; -use Flarum\Api\Controller\AbstractResourceController; -use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Core\Exception\FloodingException; -use Flarum\Core\Exception\PermissionDeniedException; +use Flarum\Api\Controller\AbstractShowController; +use Flarum\Post\Exception\FloodingException; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Exception\PermissionDeniedException; use Psr\Http\Message\ServerRequestInterface; use Reflar\Polls\Api\Serializers\VoteSerializer; +use Reflar\Polls\Events\PollWasVoted; use Reflar\Polls\Question; use Reflar\Polls\Vote; use Tobscure\JsonApi\Document; -class UpdateVoteController extends AbstractResourceController +class UpdateVoteController extends AbstractShowController { use AssertPermissionTrait; @@ -39,7 +40,7 @@ class UpdateVoteController extends AbstractResourceController * @throws FloodingException * @throws PermissionDeniedException * - * @return mixed|static + * @return mixed */ protected function data(ServerRequestInterface $request, Document $document) { @@ -49,9 +50,11 @@ protected function data(ServerRequestInterface $request, Document $document) $this->assertCan($actor, 'votePolls'); - // $this->assertNotFlooding($actor); + $question = Question::find($attributes['poll_id']); - if (Question::find($attributes['poll_id'])->isEnded()) { + $this->assertNotFlooding($actor); + + if ($question->isEnded()) { throw new PermissionDeniedException(); } @@ -66,6 +69,8 @@ protected function data(ServerRequestInterface $request, Document $document) $vote->save(); + app()->make('events')->fire(new PollWasVoted($vote, $question, $actor, true)); + return $vote; } diff --git a/src/Api/Serializers/AnswerSerializer.php b/src/Api/Serializers/AnswerSerializer.php index 7eb370b..39e6b7c 100644 --- a/src/Api/Serializers/AnswerSerializer.php +++ b/src/Api/Serializers/AnswerSerializer.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Api/Serializers/QuestionSerializer.php b/src/Api/Serializers/QuestionSerializer.php index 60e598d..1b6cd81 100644 --- a/src/Api/Serializers/QuestionSerializer.php +++ b/src/Api/Serializers/QuestionSerializer.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Api/Serializers/VoteSerializer.php b/src/Api/Serializers/VoteSerializer.php index 6b38eed..e7c22d4 100644 --- a/src/Api/Serializers/VoteSerializer.php +++ b/src/Api/Serializers/VoteSerializer.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Events/PollWasCreated.php b/src/Events/PollWasCreated.php new file mode 100644 index 0000000..4f3113a --- /dev/null +++ b/src/Events/PollWasCreated.php @@ -0,0 +1,39 @@ +discussion = $discussion; + $this->poll = $poll; + $this->actor = $actor; + } +} diff --git a/src/Events/PollWasVoted.php b/src/Events/PollWasVoted.php new file mode 100644 index 0000000..f80fdb5 --- /dev/null +++ b/src/Events/PollWasVoted.php @@ -0,0 +1,56 @@ +vote = $vote; + $this->poll = $poll; + $this->actor = $actor; + $this->changed = $changed; + } +} diff --git a/src/Listeners/AddApiRoutes.php b/src/Listeners/AddApiRoutes.php deleted file mode 100644 index ef09c06..0000000 --- a/src/Listeners/AddApiRoutes.php +++ /dev/null @@ -1,104 +0,0 @@ -listen(ConfigureApiRoutes::class, [$this, 'routes']); - } - - /** - * @param ConfigureApiRoutes $routes - */ - public function routes(ConfigureApiRoutes $routes) - { - // API Route to get all votes - $routes->get( - '/votes', - 'votes.index', - Controllers\ListVotesController::class - ); - - // API Route to store votes - $routes->post( - '/votes', - 'votes.create', - Controllers\CreateVoteController::class - ); - - // API Route to store answer - $routes->post( - '/answers', - 'answers.create', - Controllers\CreateAnswerController::class - ); - - // API Route to get all polls - $routes->get( - '/questions', - 'questions.index', - Controllers\ListPollController::class - ); - - // API Route to update a poll - $routes->patch( - '/questions/{id}', - 'poll.update', - Controllers\UpdatePollController::class - ); - - // API Route to update a vote - $routes->patch( - '/votes/{id}', - 'votes.update', - Controllers\UpdateVoteController::class - ); - - // API Route to update a poll end date - $routes->patch( - '/endDate/{id}', - 'endDate.update', - Controllers\UpdateEndDateController::class - ); - - // API Route to update an answer - $routes->patch( - '/answers/{id}', - 'answers.update', - Controllers\UpdateAnswerController::class - ); - - // API Route to delete a poll - $routes->delete( - '/questions/{id}', - 'poll.delete', - Controllers\DeletePollController::class - ); - - // API Route to delete an answer - $routes->delete( - '/answers/{id}', - 'answer.delete', - Controllers\DeleteAnswerController::class - ); - } -} diff --git a/src/Listeners/AddClientAssets.php b/src/Listeners/AddClientAssets.php deleted file mode 100644 index acd42ee..0000000 --- a/src/Listeners/AddClientAssets.php +++ /dev/null @@ -1,68 +0,0 @@ -listen(ConfigureWebApp::class, [$this, 'addAssets']); - $events->listen(ConfigureLocales::class, [$this, 'addLocales']); - } - - /** - * @param ConfigureWebApp $app - */ - public function addAssets(ConfigureWebApp $app) - { - if ($app->isForum()) { - $app->addAssets([ - __DIR__.'/../../js/forum/dist/extension.js', - __DIR__.'/../../resources/less/forum.less', - __DIR__.'/../../css/forum/dist/DateTimePicker.min.css', - ]); - - $app->addBootstrapper('reflar/polls/main'); - } - - if ($app->isAdmin()) { - $app->addAssets([ - __DIR__.'/../../js/admin/dist/extension.js', - ]); - - $app->addBootstrapper('reflar/polls/main'); - } - } - - /** - * Provides i18n files. - * - * @param ConfigureLocales $event - */ - public function addLocales(ConfigureLocales $event) - { - foreach (new DirectoryIterator(__DIR__.'/../../resources/locale') as $file) { - if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) { - $event->locales->addTranslations($file->getBasename('.'.$file->getExtension()), $file->getPathname()); - } - } - } -} diff --git a/src/Listeners/AddDiscussionPollRelationship.php b/src/Listeners/AddDiscussionPollRelationship.php index ba46b67..288f8a5 100644 --- a/src/Listeners/AddDiscussionPollRelationship.php +++ b/src/Listeners/AddDiscussionPollRelationship.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,13 +13,13 @@ namespace Reflar\Polls\Listeners; use Flarum\Api\Controller; +use Flarum\Api\Event\Serializing; +use Flarum\Api\Event\WillGetData; use Flarum\Api\Serializer\DiscussionSerializer; use Flarum\Api\Serializer\UserSerializer; -use Flarum\Core\Discussion; -use Flarum\Event\ConfigureApiController; +use Flarum\Discussion\Discussion; use Flarum\Event\GetApiRelationship; use Flarum\Event\GetModelRelationship; -use Flarum\Event\PrepareApiAttributes; use Illuminate\Contracts\Events\Dispatcher; use Reflar\Polls\Api\Serializers\QuestionSerializer; use Reflar\Polls\Question; @@ -33,8 +33,8 @@ public function subscribe(Dispatcher $events) { $events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']); $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']); - $events->listen(ConfigureApiController::class, [$this, 'includeRelationship']); - $events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']); + $events->listen(WillGetData::class, [$this, 'includeRelationship']); + $events->listen(Serializing::class, [$this, 'prepareApiAttributes']); } /** @@ -62,9 +62,9 @@ public function getApiRelationship(GetApiRelationship $event) } /** - * @param PrepareApiAttributes $event + * @param Serializing $event */ - public function prepareApiAttributes(PrepareApiAttributes $event) + public function prepareApiAttributes(Serializing $event) { if ($event->isSerializer(UserSerializer::class)) { $event->attributes['canEditPolls'] = $event->actor->can('discussion.polls'); @@ -75,9 +75,9 @@ public function prepareApiAttributes(PrepareApiAttributes $event) } /** - * @param ConfigureApiController $event + * @param WillGetData $event */ - public function includeRelationship(ConfigureApiController $event) + public function includeRelationship(WillGetData $event) { if ($event->isController(Controller\ListDiscussionsController::class) || $event->isController(Controller\ShowDiscussionController::class) diff --git a/src/Listeners/AddForumFieldRelationship.php b/src/Listeners/AddForumFieldRelationship.php index ef6028a..d2fe83c 100644 --- a/src/Listeners/AddForumFieldRelationship.php +++ b/src/Listeners/AddForumFieldRelationship.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,8 +12,8 @@ namespace Reflar\Polls\Listeners; +use Flarum\Api\Event\WillGetData; use Flarum\Api\Serializer\ForumSerializer; -use Flarum\Event\ConfigureApiController; use Flarum\Event\GetApiRelationship; use Illuminate\Contracts\Events\Dispatcher; use Reflar\Polls\Api\Serializers\QuestionSerializer; @@ -29,7 +29,7 @@ class AddForumFieldRelationship public function subscribe(Dispatcher $events) { $events->listen(GetApiRelationship::class, [$this, 'addSerializerRelationship']); - $events->listen(ConfigureApiController::class, [$this, 'addSerializerInclude']); + $events->listen(WillGetData::class, [$this, 'addSerializerInclude']); } /** @@ -49,9 +49,9 @@ public function addSerializerRelationship(GetApiRelationship $event) } /** - * @param ConfigureApiController $event + * @param WillGetData $event */ - public function addSerializerInclude(ConfigureApiController $event) + public function addSerializerInclude(WillGetData $event) { if ($event->controller->serializer === ForumSerializer::class) { $event->addInclude('PollsQuestion'); diff --git a/src/Listeners/SavePollToDatabase.php b/src/Listeners/SavePollToDatabase.php index c906f2d..b040a27 100644 --- a/src/Listeners/SavePollToDatabase.php +++ b/src/Listeners/SavePollToDatabase.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,10 +12,11 @@ namespace Reflar\Polls\Listeners; -use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Event\DiscussionWillBeSaved; +use Flarum\Discussion\Event\Saving; +use Flarum\User\AssertPermissionTrait; use Illuminate\Contracts\Events\Dispatcher; use Reflar\Polls\Answer; +use Reflar\Polls\Events\PollWasCreated; use Reflar\Polls\Question; use Reflar\Polls\Validators\AnswerValidator; @@ -28,14 +29,21 @@ class SavePollToDatabase */ protected $validator; + /** + * @var Dispatcher + */ + protected $Dispatcher; + /** * SavePollToDatabase constructor. * * @param AnswerValidator $validator + * @param Dispatcher $events */ - public function __construct(AnswerValidator $validator) + public function __construct(AnswerValidator $validator, Dispatcher $events) { $this->validator = $validator; + $this->events = $events; } /** @@ -43,15 +51,15 @@ public function __construct(AnswerValidator $validator) */ public function subscribe(Dispatcher $events) { - $events->listen(DiscussionWillBeSaved::class, [$this, 'whenDiscussionWillBeSaved']); + $events->listen(Saving::class, [$this, 'whenSaving']); } /** - * @param DiscussionWillBeSaved $event + * @param Saving $event * - * @throws \Flarum\Core\Exception\PermissionDeniedException + * @throws \Flarum\User\Exception\PermissionDeniedException */ - public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event) + public function whenSaving(Saving $event) { $discussion = $event->discussion; @@ -74,6 +82,10 @@ public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event) $poll = Question::build($attributes['question'], $discussion->id, $event->actor->id, $endDate, $attributes['publicPoll']); $poll->save(); + $this->events->fire( + new PollWasCreated($discussion, $poll, $event->actor) + ); + // Add answers to database foreach (array_filter($attributes['answers']) as $answer) { $answer = Answer::build($answer); diff --git a/src/Question.php b/src/Question.php index 2e815dc..f93ae3b 100644 --- a/src/Question.php +++ b/src/Question.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -13,8 +13,8 @@ namespace Reflar\Polls; use DateTime; -use Flarum\Core\Discussion; use Flarum\Database\AbstractModel; +use Flarum\Discussion\Discussion; class Question extends AbstractModel { diff --git a/src/Repositories/AnswerRepository.php b/src/Repositories/AnswerRepository.php index a00b5e9..9413d41 100644 --- a/src/Repositories/AnswerRepository.php +++ b/src/Repositories/AnswerRepository.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Repositories/QuestionRepository.php b/src/Repositories/QuestionRepository.php index 6a54d5f..a068f15 100644 --- a/src/Repositories/QuestionRepository.php +++ b/src/Repositories/QuestionRepository.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Repositories/VoteRepository.php b/src/Repositories/VoteRepository.php index 71059c8..53e13a2 100644 --- a/src/Repositories/VoteRepository.php +++ b/src/Repositories/VoteRepository.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. diff --git a/src/Validators/AnswerValidator.php b/src/Validators/AnswerValidator.php index 2434244..e770857 100644 --- a/src/Validators/AnswerValidator.php +++ b/src/Validators/AnswerValidator.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code. @@ -12,7 +12,7 @@ namespace Reflar\Polls\Validators; -use Flarum\Core\Validator\AbstractValidator; +use Flarum\Foundation\AbstractValidator; class AnswerValidator extends AbstractValidator { diff --git a/src/Vote.php b/src/Vote.php index 48e9972..8d22d1b 100644 --- a/src/Vote.php +++ b/src/Vote.php @@ -4,7 +4,7 @@ * * Copyright (c) ReFlar. * - * http://reflar.io + * https://reflar.redevs.org * * For the full copyright and license information, please view the license.md * file that was distributed with this source code.