Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
- Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
- Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
- Opera: Нажмите Ctrl+F5.
/******/ (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 = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(1); /***/ }), /* 1 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _lib_mediawiki_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); /* harmony import */ var _lib_wikitext_section_editor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3); /* harmony import */ var _lib_ui_components_pagination__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6); /* harmony import */ var _lib_ui_components_listing_item__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7); /* harmony import */ var _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(16); /* harmony import */ var _lib_async_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(19); /* harmony import */ var _lib_wikivoyage_api__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(20); /* harmony import */ var _lib_cultural_editor_serializer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(21); /* harmony import */ var _lib_mediawiki_page_wikitext__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(23); /* harmony import */ var _lib_download_content__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(25); /* harmony import */ var _lib_ui_components_export_panel__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(26); /* harmony import */ var _lib_array_utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(18); /* harmony import */ var _lib_commons_api__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(27); /* harmony import */ var _lib_string_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(5); /* harmony import */ var _lib_commons_images_loader__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(28); /* harmony import */ var _lib_cultural_gallery_images__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(29); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * TODO * * 1. Integration with missing images gadget. * 2. Show loading/saving progress. * 3. Complete listing template implementation. * 4. Object passport document. * 5. Advanced gallery. * 6. Better compact view. * 7. Captcha handling. * 8. XSS. * 9. Edit then go to another page. * 10. Save all. * 11. Leave warning. * 12. Complete GPX, JSON, CSV export. * 13. Map. */ $(document).ready(function () { var reportFatalError = function reportFatalError(errorText) { var gadgetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; window.console.error(errorText); if (gadgetElement) { var errorElement = $('<div style="color: red;">').text(errorText); gadgetElement.append(errorElement); } }; var initGadget = function initGadget(gadgetElement) { var settingsElement = gadgetElement.children('.gadget-heritage-list-settings'); if (settingsElement.length === 0) { reportFatalError("Heritage gadget error: settings are not specified.", gadgetElement); return; } if (settingsElement.length > 1) { reportFatalError("Heritage gadget error: multiple settings elements are specified.", gadgetElement); return; } var gadgetSettings = {}; try { gadgetSettings = JSON.parse(settingsElement.text()); } catch (e) { reportFatalError("Heritage gadget error: settings element contains invalid JSON.", gadgetElement); return; } var gadgetContentElement = $('<div class="gadget-heritage-list-content">'); gadgetElement.append(gadgetContentElement); showGadget(gadgetContentElement, gadgetSettings); var fallbackElements = gadgetElement.find('.gadget-heritage-list-disabled'); fallbackElements.hide(); }; var HeritageListGadgetState = function HeritageListGadgetState() { _classCallCheck(this, HeritageListGadgetState); this.allListingItems = []; this.currentListingItems = []; this.filterListingItems = []; this.page = 0; this.itemsPerPage = 10; this.view = _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].VIEW_FULL; this.sortBy = _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].DEFAULT; this.filter = new _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchFilter"]('', '', _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].PHOTO_ANY, _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_ANY, '', '', ''); }; var ListingItem = function ListingItem(data, page, index) { _classCallCheck(this, ListingItem); this.data = data; this.page = page; this.index = index; }; var HeritageListGadget = /*#__PURE__*/ function () { function HeritageListGadget(rootElement) { var _this = this; _classCallCheck(this, HeritageListGadget); this.rootElement = rootElement; this.state = new HeritageListGadgetState(); this.searchBar = new _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchBar"](function (filter) { return _this.updateFilterListingItems(filter); }, function (itemsOnPage) { return _this.updateItemsOnPage(itemsOnPage); }, function (view) { return _this.updateView(view); }, function (sortBy) { return _this.updateSort(sortBy); }); this.dataElement = $('<div>'); } _createClass(HeritageListGadget, [{ key: "loadData", value: function loadData(pages) { var _this2 = this; var api = new _lib_mediawiki_api__WEBPACK_IMPORTED_MODULE_0__["MediawikiApi"](); var loadPageListings = function loadPageListings(page, onSuccess) { api.getPageText(page, function (text) { var listings = []; var sectionEditor = new _lib_wikitext_section_editor__WEBPACK_IMPORTED_MODULE_1__["WikitextSectionEditor"](text, 'monument'); var listingIndex = 0; while (true) { var listingData = sectionEditor.getListingData(listingIndex); if (!listingData) { break; } var listingItem = new ListingItem(listingData, page, listingIndex); listings.push(listingItem); listingIndex++; } onSuccess(listings); }, function (reason) { window.console.error(reason); onSuccess([]); }); }; _lib_async_utils__WEBPACK_IMPORTED_MODULE_5__["AsyncUtils"].runSequence(pages.map(function (page) { return function (onSuccess) { return loadPageListings(page, onSuccess); }; }), function (pagesListingItems) { var allListingItems = pagesListingItems.reduce(function (pageListingItems, acc) { return pageListingItems.concat(acc); }, []); _this2.state.allListingItems = allListingItems; _this2.state.filterListingItems = allListingItems; _this2.updateCurrentListingItems(); }); } }, { key: "updateCurrentListingItems", value: function updateCurrentListingItems() { if (this.state.itemsPerPage !== 0) { this.state.currentListingItems = this.state.filterListingItems.slice(this.state.page * this.state.itemsPerPage, (this.state.page + 1) * this.state.itemsPerPage); } else { this.state.currentListingItems = this.state.filterListingItems; } this.renderData(); } }, { key: "updateView", value: function updateView(view) { this.state.view = view; this.updateCurrentListingItems(); } }, { key: "updateItemsOnPage", value: function updateItemsOnPage(itemsOnPage) { this.state.itemsPerPage = itemsOnPage; this.state.page = 0; this.updateCurrentListingItems(); } }, { key: "updateSort", value: function updateSort(sortBy) { this.state.sortBy = sortBy; this.updateFilteredSortedListingItems(); this.updateCurrentListingItems(); } }, { key: "updateFilterListingItems", value: function updateFilterListingItems(filter) { this.state.filter = filter; this.state.page = 0; this.updateFilteredSortedListingItems(); this.updateCurrentListingItems(); } }, { key: "updateFilteredSortedListingItems", value: function updateFilteredSortedListingItems() { this.state.filterListingItems = this.applySort(this.applyFilter(this.state.allListingItems, this.state.filter), this.state.sortBy); } }, { key: "applySort", value: function applySort(items, sortBy) { var sortedItems = items.concat(); if (_lib_array_utils__WEBPACK_IMPORTED_MODULE_11__["ArrayUtils"].inArray(sortBy, [_lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].NAME, _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].ADDRESS, _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].TYPE])) { sortedItems.sort(function (item1, item2) { if (sortBy === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].NAME) { return item1.data.name.localeCompare(item2.data.name); } else if (sortBy === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].ADDRESS) { return item1.data.address.localeCompare(item2.data.address); } else if (sortBy === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SortConstants"].TYPE) { return item1.data.type.localeCompare(item2.data.type); } }); } return sortedItems; } }, { key: "applyFilter", value: function applyFilter(items, filter) { var searchDescription = filter.getSearchDescription().toLowerCase(); var searchAddress = filter.getSearchAddress().toLowerCase(); var photo = filter.getPhoto(); var coordinates = filter.getCoordinates(); var type = filter.getType(); var style = filter.getStyle(); var protection = filter.getProtection(); return items.filter(function (item) { return (searchDescription === '' || item.data.name.toLowerCase().indexOf(searchDescription) !== -1) && (searchAddress === '' || item.data.address.toLowerCase().indexOf(searchAddress) !== -1) && (photo === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].PHOTO_ANY || photo === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].PHOTO_YES && item.data.image || photo === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].PHOTO_NO && !item.data.image) && (coordinates === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_ANY || coordinates === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_PRECISE && item.data.lat && item.data.long && item.data.precise === 'yes' || coordinates === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_NOT_PRECISE && item.data.lat && item.data.long && item.data.precise !== 'yes' || coordinates === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_EXISTS && item.data.lat && item.data.long || coordinates === _lib_ui_components_search_bar__WEBPACK_IMPORTED_MODULE_4__["SearchConstants"].COORDINATES_NO && (!item.data.lat || !item.data.long)) && (!type || item.data.type === type) && (!style || item.data.style === style) && (!protection || item.data.protection === protection); }); } }, { key: "render", value: function render() { this.rootElement.empty(); this.rootElement.append(this.searchBar.render()); this.rootElement.append(this.dataElement); this.renderData(); } }, { key: "exportJson", value: function exportJson() { var items = this.state.filterListingItems.map(function (item) { return item.data; }); Object(_lib_download_content__WEBPACK_IMPORTED_MODULE_9__["downloadContent"])('listings.json', JSON.stringify(items, null, 2)); } }, { key: "exportGpx", value: function exportGpx() { var items = this.state.filterListingItems.map(function (item) { return item.data; }); var header = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>\n' + '<gpx version="1.1" creator="Wikivoyage"\n' + ' xmlns="http://www.topografix.com/GPX/1/1"\n' + ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' + ' xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' + 'http://www.topografix.com/GPX/1/1/gpx.xsd">\n'; var footer = '\n</gpx>'; // TODO proper escaping var data = items.filter(function (item) { return item.lat && item.long; }).map(function (item) { return ' <wpt lat="' + item.lat + '" lon="' + item.long + '">\n' + ' <name>' + item.name + '</name>\n' + ' <desc>' + item.address + '</desc>\n' + ' </wpt>'; }).join("\n"); Object(_lib_download_content__WEBPACK_IMPORTED_MODULE_9__["downloadContent"])('listings.gpx', header + data + footer); } }, { key: "onSaveListing", value: function onSaveListing(page, listingComponent, listingIndex, data, changesDescription, onSuccess) { var newListingText = _lib_cultural_editor_serializer__WEBPACK_IMPORTED_MODULE_7__["CulturalEditorListingSerializer"].serializeListingData(data); var editor = this; var api = new _lib_mediawiki_api__WEBPACK_IMPORTED_MODULE_0__["MediawikiApi"](); api.getPageText(page, function (text) { var sectionEditor = new _lib_wikitext_section_editor__WEBPACK_IMPORTED_MODULE_1__["WikitextSectionEditor"](text, 'monument'); var newPageText = sectionEditor.getSectionTextWithReplacedListing(listingIndex, newListingText); var changesDescriptionText = 'Обновлен объект "' + data.name + '"'; if (changesDescription.getDescription()) { changesDescriptionText += ' - ' + changesDescription.getDescription(); } _lib_mediawiki_page_wikitext__WEBPACK_IMPORTED_MODULE_8__["MediaWikiPageWikitext"].saveSectionWikitext(null, newPageText, changesDescriptionText, changesDescription.getIsMinor(), null, null, function () { editor.loadImageThumb(listingComponent, function () { return onSuccess(); }, true, data.image); }, function () { alert('Failed to save listing'); }, function () { alert('Captcha request'); }, page); }); } }, { key: "onLoadGallery", value: function onLoadGallery(listingItem, onSuccess) { _lib_commons_images_loader__WEBPACK_IMPORTED_MODULE_14__["CommonsImagesLoader"].loadImagesFromWLMCategory(listingItem.data.knid, function (wlmImages) { _lib_commons_images_loader__WEBPACK_IMPORTED_MODULE_14__["CommonsImagesLoader"].loadImagesFromCommonsCategory(listingItem.data.commonscat, function (commonsImages) { listingItem.galleryImages = new _lib_cultural_gallery_images__WEBPACK_IMPORTED_MODULE_15__["CulturalGalleryImages"](wlmImages, commonsImages); onSuccess(); }); }); } }, { key: "loadImageThumb", value: function loadImageThumb(listingComponent, onSuccess, force, newImage) { var image = newImage ? newImage : listingComponent.listingItem.data.image; if (image && (!listingComponent.listingItem.imageThumb || force)) { _lib_wikivoyage_api__WEBPACK_IMPORTED_MODULE_6__["WikivoyageApi"].getImageInfo('File:' + image, function (result) { listingComponent.listingItem.imageThumb = result.thumb; listingComponent.onImageThumbUpdated(); onSuccess(); }, function () { listingComponent.onImageThumbUpdated(); onSuccess(); }); } else { listingComponent.onImageThumbUpdated(); onSuccess(); } } }, { key: "renderData", value: function renderData() { var _this3 = this, _this$dataElement, _this$dataElement2; this.dataElement.empty(); var exportPanel = new _lib_ui_components_export_panel__WEBPACK_IMPORTED_MODULE_10__["ExportPanel"](function () { return _this3.exportJson(); }, function () { return _this3.exportGpx(); }); this.dataElement.append(exportPanel.render()); var topPagination = this.createPagination(false); var bottomPagination = this.createPagination(true); (_this$dataElement = this.dataElement).append.apply(_this$dataElement, _toConsumableArray(topPagination.render())); var listingComponents = []; this.state.currentListingItems.forEach(function (listingItem) { var _this3$dataElement; var listingComponent = new _lib_ui_components_listing_item__WEBPACK_IMPORTED_MODULE_3__["ListingItemComponent"](listingItem, _this3.state.view, function () { return _this3.onSaveListing.apply(_this3, arguments); }, _this3.onLoadGallery); (_this3$dataElement = _this3.dataElement).append.apply(_this3$dataElement, _toConsumableArray(listingComponent.render())); listingComponents.push(listingComponent); }); _lib_async_utils__WEBPACK_IMPORTED_MODULE_5__["AsyncUtils"].runSequence(listingComponents.map(function (listingComponent) { return function (onSuccess) { return _this3.loadImageThumb(listingComponent, onSuccess); }; })); var categories = []; categories = categories.concat(this.state.currentListingItems.map(function (item) { return 'Category:WLM/' + item.data.knid; })); categories = categories.concat(this.state.currentListingItems.map(function (item) { return item.data.commonscat; }).filter(function (commonscatValue) { return _lib_string_utils__WEBPACK_IMPORTED_MODULE_13__["StringUtils"].emptyToString(commonscatValue) !== ''; }).map(function (commonscatValue) { return 'Category:' + commonscatValue; })); _lib_commons_api__WEBPACK_IMPORTED_MODULE_12__["CommonsApi"].countCategoriesFiles(categories, function (categoriesWithImages) { var filesCountByCategory = {}; categoriesWithImages.forEach(function (item) { filesCountByCategory[item.category] = item.files; }); var getCategoryFilesCount = function getCategoryFilesCount(category) { if (_lib_string_utils__WEBPACK_IMPORTED_MODULE_13__["StringUtils"].emptyToString(category) === '') { return 0; } var filesCount = filesCountByCategory[category]; return filesCount !== undefined ? filesCount : 0; }; listingComponents.forEach(function (listingComponent) { listingComponent.listingItem.imagesCount = getCategoryFilesCount('Category:WLM/' + listingComponent.listingItem.data.knid) + getCategoryFilesCount('Category:' + _lib_string_utils__WEBPACK_IMPORTED_MODULE_13__["StringUtils"].emptyToString(listingComponent.listingItem.data.commonscat).replace(/_'/g, ' ')); listingComponent.onUpdateImageCount(); }); }); (_this$dataElement2 = this.dataElement).append.apply(_this$dataElement2, _toConsumableArray(bottomPagination.render())); } }, { key: "createPagination", value: function createPagination(scrollToTop) { var _this4 = this; return new _lib_ui_components_pagination__WEBPACK_IMPORTED_MODULE_2__["PaginationComponent"](this.state.filterListingItems.length, this.state.itemsPerPage, this.state.page, function (pageNumber) { _this4.state.page = pageNumber; _this4.updateCurrentListingItems(); _this4.renderData(); if (scrollToTop) { $("html, body").animate({ scrollTop: 0 }, "slow"); } }); } }]); return HeritageListGadget; }(); var showGadget = function showGadget(gadgetContentElement, gadgetSettings) { var gadget = new HeritageListGadget(gadgetContentElement); gadget.render(); gadget.loadData(gadgetSettings.pages); }; $('.gadget-heritage-list').each(function (index, gadgetElement) { return initGadget($(gadgetElement)); }); }); /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MediawikiApi", function() { return MediawikiApi; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var MediawikiApi = /*#__PURE__*/ function () { function MediawikiApi() { _classCallCheck(this, MediawikiApi); } _createClass(MediawikiApi, [{ key: "getPageText", value: function getPageText(pageUrl, onSuccess, onError) { $.ajax({ // TODO ability to specify URL url: mw.util.wikiScript(''), data: { title: pageUrl, action: 'raw' }, cache: false }).done(function (data) { onSuccess(data); }).fail(function (jqXHR, textStatus, errorThrown) { onError(new Error('Ошибка при получении исходного вики-текста статьи: ' + textStatus + ' ' + errorThrown)); }); } }]); return MediawikiApi; }(); /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WikitextSectionEditor", function() { return WikitextSectionEditor; }); /* harmony import */ var _wikitext_parser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var WikitextSectionEditor = /*#__PURE__*/ function () { function WikitextSectionEditor(sectionText, listingName) { _classCallCheck(this, WikitextSectionEditor); this._sectionText = sectionText; this._listingName = listingName; this._commentReplacements = {}; this._stripComments(); } _createClass(WikitextSectionEditor, [{ key: "getListingData", value: function getListingData(listingIndex) { var listingText = _wikitext_parser__WEBPACK_IMPORTED_MODULE_0__["WikitextParser"].getListingWikitextBraces(this._sectionText, this._listingName, listingIndex); if (!listingText) { return null; } var listingData = _wikitext_parser__WEBPACK_IMPORTED_MODULE_0__["WikitextParser"].wikiTextToListing(listingText); for (var key in listingData) { if (!listingData.hasOwnProperty(key)) { continue; } listingData[key] = this._restoreComments(listingData[key]); } return listingData; } }, { key: "getSectionTextWithReplacedListing", value: function getSectionTextWithReplacedListing(listingIndex, newListingText) { var oldListingText = _wikitext_parser__WEBPACK_IMPORTED_MODULE_0__["WikitextParser"].getListingWikitextBraces(this._sectionText, this._listingName, listingIndex); var result = this._sectionText; result = result.replace(oldListingText, newListingText); result = this._restoreComments(result); return result; } }, { key: "getSectionTextWithAddedListing", value: function getSectionTextWithAddedListing(newListingText) { var result = this._sectionText; var index = result.indexOf('{{footer'); if (index > 0) { result = result.substr(0, index) + '\n' + newListingText + '\n' + result.substr(index); } else { result += '\n' + newListingText; } result = this._restoreComments(result); return result; } /** * Commented-out listings can result in the wrong listing being edited, so * strip out any comments and replace them with placeholders that can be * restored prior to saving changes. */ }, { key: "_stripComments", value: function _stripComments() { var comments = this._sectionText.match(/<!--[\s\S]*?-->/mig); if (comments !== null) { for (var i = 0; i < comments.length; i++) { var comment = comments[i]; var rep = '<<<COMMENT' + i + '>>>'; this._sectionText = this._sectionText.replace(comment, rep); this._commentReplacements[rep] = comment; } } } /** * Search the text provided, and if it contains any text that was * previously stripped out for replacement purposes, restore it. */ }, { key: "_restoreComments", value: function _restoreComments(sectionText) { for (var key in this._commentReplacements) { var val = this._commentReplacements[key]; sectionText = sectionText.replace(key, val); } return sectionText; } }]); return WikitextSectionEditor; }(); /***/ }), /* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WikitextParser", function() { return WikitextParser; }); /* harmony import */ var _string_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5); var WikitextParser = { /** * Given a listing index, return the full wikitext for that listing * ("{{listing|key=value|...}}"). An index of 0 returns the first listing * template invocation, 1 returns the second, etc. */ getListingWikitextBraces: function getListingWikitextBraces(wikitext, listingName, listingIndex) { // find the listing wikitext that matches the same index as the listing index var listingRegex = new RegExp('{{\\s*(' + listingName + ')(\\s|\\|)', 'ig'); // look through all matches for "{{listing|see|do...}}" within the section // wikitext, returning the nth match, where 'n' is equal to the index of the // edit link that was clicked var listingSyntax, regexResult, listingMatchIndex; for (var i = 0; i <= listingIndex; i++) { regexResult = listingRegex.exec(wikitext); if (!regexResult) { return null; } listingMatchIndex = regexResult.index; listingSyntax = regexResult[0]; } // listings may contain nested templates, so step through all section // text after the matched text to find MATCHING closing braces // the first two braces are matched by the listing regex and already // captured in the listingSyntax variable var curlyBraceCount = 2; var endPos = wikitext.length; var startPos = listingMatchIndex + listingSyntax.length; var matchFound = false; for (var j = startPos; j < endPos; j++) { if (wikitext[j] === '{') { ++curlyBraceCount; } else if (wikitext[j] === '}') { --curlyBraceCount; } if (curlyBraceCount === 0 && j + 1 < endPos) { listingSyntax = wikitext.substring(listingMatchIndex, j + 1); matchFound = true; break; } } if (!matchFound) { listingSyntax = wikitext.substring(listingMatchIndex); } return _string_utils__WEBPACK_IMPORTED_MODULE_0__["StringUtils"].trim(listingSyntax); }, /** * Convert raw wiki listing syntax into a mapping of key-value pairs * corresponding to the listing template parameters. */ wikiTextToListing: function wikiTextToListing(wikitext) { // remove the trailing braces if there are some for (var i = 0; i < 2; i++) { if (wikitext[wikitext.length - 1] === '}') { wikitext = wikitext.slice(0, -1); } } var listingData = {}; var lastKey; var listParams = WikitextParser.listingTemplateToParamsArray(wikitext); for (var _i = 1; _i < listParams.length; _i++) { var param = listParams[_i]; var index = param.indexOf('='); if (index > 0) { // param is of the form key=value var key = _string_utils__WEBPACK_IMPORTED_MODULE_0__["StringUtils"].trim(param.substr(0, index)); listingData[key] = _string_utils__WEBPACK_IMPORTED_MODULE_0__["StringUtils"].trim(param.substr(index + 1)); lastKey = key; } else if (listingData[lastKey].length) { // there was a pipe character within a param value, such as // "key=value1|value2", so just append to the previous param listingData[lastKey] += '|' + param; } } return listingData; }, /** * Split the raw template wikitext into an array of params. The pipe * symbol delimits template params, but this method will also inspect the * description to deal with nested templates or wikilinks that might contain * pipe characters that should not be used as delimiters. */ listingTemplateToParamsArray: function listingTemplateToParamsArray(wikitext) { var results = []; var paramValue = ''; var pos = 0; while (pos < wikitext.length) { var remainingString = wikitext.substr(pos); // check for a nested template or wikilink var patternMatch = WikitextParser.findPatternMatch(remainingString, "{{", "}}"); if (patternMatch.length === 0) { patternMatch = WikitextParser.findPatternMatch(remainingString, "[[", "]]"); } if (patternMatch.length > 0) { paramValue += patternMatch; pos += patternMatch.length; } else if (wikitext.charAt(pos) === '|') { // delimiter - push the previous param and move on to the next results.push(paramValue); paramValue = ''; pos++; } else { // append the character to the param value being built paramValue += wikitext.charAt(pos); pos++; } } if (paramValue.length > 0) { // append the last param value results.push(paramValue); } return results; }, /** * Utility method for finding a matching end pattern for a specified start * pattern, including nesting. The specified value must start with the * start value, otherwise an empty string will be returned. */ findPatternMatch: function findPatternMatch(value, startPattern, endPattern) { var matchString = ''; var startRegex = new RegExp('^' + WikitextParser.replaceSpecial(startPattern), 'i'); if (startRegex.test(value)) { var endRegex = new RegExp('^' + WikitextParser.replaceSpecial(endPattern), 'i'); var matchCount = 1; for (var i = startPattern.length; i < value.length; i++) { var remainingValue = value.substr(i); if (startRegex.test(remainingValue)) { matchCount++; } else if (endRegex.test(remainingValue)) { matchCount--; } if (matchCount === 0) { matchString = value.substr(0, i); break; } } } return matchString; }, replaceSpecial: function replaceSpecial(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); } }; /***/ }), /* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringUtils", function() { return StringUtils; }); var StringUtils = { contains: function contains(string, substring) { return string.indexOf(substring) >= 0; }, trim: function trim(string) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim return string.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }, emptyToString: function emptyToString(value) { if (value === undefined || value === null) { return ''; } else { return value; } } }; /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PaginationComponent", function() { return PaginationComponent; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var PaginationComponent = /*#__PURE__*/ function () { function PaginationComponent(itemsCount, itemsPerPage, currentPage, setPageFunction) { _classCallCheck(this, PaginationComponent); this.itemsPerPage = itemsPerPage; if (this.itemsPerPage !== 0) { this.pagesCount = Math.ceil(itemsCount / itemsPerPage); } this.setPageFunction = setPageFunction; this.currentPage = currentPage; } _createClass(PaginationComponent, [{ key: "render", value: function render() { if (this.itemsPerPage === 0 || this.pagesCount < 2) { return []; } var firstPage = 0; var previousPage = this.currentPage > 0 ? this.currentPage - 1 : null; var lastPage = this.pagesCount - 1; var nextPage = this.currentPage < this.pagesCount - 1 ? this.currentPage + 1 : null; var pagesDistance = 3; var paginationElement = $('<div style="display: flex; flex-direction: row;">'); paginationElement.append(this.createPaginationItemElement('<<', firstPage)); paginationElement.append(this.createPaginationItemElement('<', previousPage)); var startPage = Math.max(0, this.currentPage - pagesDistance); var endPage = Math.min(this.pagesCount - 1, this.currentPage + pagesDistance + 1); if (startPage !== firstPage) { paginationElement.append(this.createMoreItemsElement()); } for (var pageNumber = startPage; pageNumber < this.currentPage; pageNumber++) { paginationElement.append(this.createPaginationItemElement(pageNumber, pageNumber)); } paginationElement.append(this.createPaginationItemElement(this.currentPage, this.currentPage)); for (var _pageNumber = this.currentPage + 1; _pageNumber < endPage + 1; _pageNumber++) { paginationElement.append(this.createPaginationItemElement(_pageNumber, _pageNumber)); } if (endPage !== lastPage) { paginationElement.append(this.createMoreItemsElement()); } paginationElement.append(this.createPaginationItemElement('>', nextPage)); paginationElement.append(this.createPaginationItemElement('>>', lastPage)); return [paginationElement]; } }, { key: "createMoreItemsElement", value: function createMoreItemsElement() { return $('<div>').attr('style', 'padding-right: 3px;').text('...'); } }, { key: "createPaginationItemElement", value: function createPaginationItemElement(title, pageNumber) { var _this = this; var isActive = pageNumber !== null && pageNumber !== this.currentPage; var paginationItemElement = $('<div>').text('[' + title + ']').attr('style', isActive ? 'padding-right: 3px; color: blue; cursor: pointer;' : 'padding-right: 3px;'); if (isActive) { paginationItemElement.click(function () { _this.setPageFunction(pageNumber); }); } return paginationItemElement; } }]); return PaginationComponent; }(); /***/ }), /* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingItemComponent", function() { return ListingItemComponent; }); /* harmony import */ var _cultural_monument_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8); /* harmony import */ var _cultural_monument_styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9); /* harmony import */ var _cultural_monument_protections__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10); /* harmony import */ var _regions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(11); /* harmony import */ var _validation_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12); /* harmony import */ var _listing_item_icons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(13); /* harmony import */ var _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(14); /* harmony import */ var _search_bar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16); /* harmony import */ var _changes_description__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(17); /* harmony import */ var _string_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5); /* harmony import */ var _array_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(18); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ListingItemComponent = /*#__PURE__*/ function () { function ListingItemComponent(listingItem, view, onSaveListing, onLoadGallery) { _classCallCheck(this, ListingItemComponent); this.view = view; this.listingItem = listingItem; this.listingItemContainer = $('<div>'); this.onSaveListing = onSaveListing; this.onLoadGallery = onLoadGallery; this._mode = MODES.VIEW; this._listingTable = null; this._listingDataRow = null; this._listingGalleryRow = null; } _createClass(ListingItemComponent, [{ key: "render", value: function render() { this.listingItemContainer.append(this.renderView()); return [this.listingItemContainer, $('<hr/>')]; } }, { key: "renderView", value: function renderView() { if (this.view === _search_bar__WEBPACK_IMPORTED_MODULE_7__["SearchConstants"].VIEW_COMPACT) { return this.renderViewCompact(); } else { return this.renderViewFull(); } } }, { key: "renderViewFull", value: function renderViewFull() { var _this = this; var listingData = this.listingItem.data; this.imageCellComponent = new ImageCellComponent(listingData, this.listingItem.imageThumb, this.listingItem.imagesCount, function () { return _this.onToggleGallery(); }); var imageCell = this.imageCellComponent.render(); this.dataCell = $('<td style="padding-left:10px;" valign="middle">'); this.renderDataCellView(); var uploadCellComponent = new UploadCellComponent(listingData); var uploadCell = uploadCellComponent.render(); this._listingDataRow = $('<tr valign="top">'); this._listingDataRow.append(imageCell); this._listingDataRow.append(this.dataCell); this._listingDataRow.append(uploadCell); this.galleryRowComponent = new GalleryRowComponent(function (image) { return _this.onSelectImage(image); }); this._listingGalleryRow = this.galleryRowComponent.render(); this.galleryRowComponent.onModeUpdate(this._mode); this._listingTable = $('<table class="monument" border="0" style="font-size:97%; width:100%;">'); this._listingTable.append(this._listingDataRow); this._listingTable.append(this._listingGalleryRow); this._updateListingDataStatus(); return this._listingTable; } }, { key: "_updateListingDataStatus", value: function _updateListingDataStatus() { var listingData = this.listingItem.data; if (!this._listingDataRow) { return; } if (this._mode === MODES.VIEW && listingData.status === 'destroyed') { this._listingDataRow.css('color', '#808080'); } else { this._listingDataRow.css('color', '#000000'); } } }, { key: "renderDataCellView", value: function renderDataCellView() { var _this2 = this; this._mode = MODES.VIEW; this.updateMode(); var listingData = this.listingItem.data; this.dataCell.empty(); var viewComponent = new ViewComponent(this.dataCell, listingData, function () { _this2.renderDataCellEdit(); _this2._updateListingDataStatus(); }); viewComponent.render(); } }, { key: "renderDataCellEdit", value: function renderDataCellEdit() { var _this3 = this; this._mode = MODES.EDIT; this.updateMode(); var listingData = this.listingItem.data; this.dataCell.empty(); this._editComponent = new EditorComponent(this.dataCell, listingData, function () { return _this3.onEditDiscard(); }, function (values, changes) { return _this3.onEditSave(values, changes); }); this._editComponent.render(); } }, { key: "updateMode", value: function updateMode() { if (this.galleryRowComponent) { this.galleryRowComponent.onModeUpdate(this._mode); } } }, { key: "onImageThumbUpdated", value: function onImageThumbUpdated() { this.imageCellComponent.onImageThumbUpdated(this.listingItem.imageThumb); } }, { key: "onUpdateImageCount", value: function onUpdateImageCount() { this.imageCellComponent.onUpdateImageCount(this.listingItem.imagesCount); } }, { key: "onEditDiscard", value: function onEditDiscard() { this.renderDataCellView(); this._updateListingDataStatus(); } }, { key: "onEditSave", value: function onEditSave(values, changesDescription) { var _this4 = this; var onSaveSuccessful = function onSaveSuccessful() { _this4.listingItem.data = values; _this4.renderDataCellView(); _this4._updateListingDataStatus(); }; if (this.onSaveListing) { this.onSaveListing(this.listingItem.page, this, this.listingItem.index, values, changesDescription, onSaveSuccessful); } else { onSaveSuccessful(); } } }, { key: "onToggleGallery", value: function onToggleGallery() { var _this5 = this; if (!this.listingItem.galleryImages) { this.onLoadGallery(this.listingItem, function () { _this5.onGalleryUpdated(); }); } this.galleryRowComponent.toggle(); } }, { key: "onGalleryUpdated", value: function onGalleryUpdated() { this.galleryRowComponent.setGalleryImages(this.listingItem.galleryImages); } }, { key: "onSelectImage", value: function onSelectImage(image) { if (this._editComponent) { this._editComponent.setImage(image); } } }, { key: "renderViewCompact", value: function renderViewCompact() { var listingData = this.listingItem.data; return $('<div>').append($('<b>').text(listingData.name)).append($('<br/>')).append(listingData.address); } }]); return ListingItemComponent; }(); var ImageCellComponent = /*#__PURE__*/ function () { function ImageCellComponent(listingData, imageThumb, galleryImagesCount, onToggleGallery) { _classCallCheck(this, ImageCellComponent); this._listingData = listingData; this._imageThumb = imageThumb; this._galleryImagesCount = galleryImagesCount; this._onToggleGallery = onToggleGallery; } _createClass(ImageCellComponent, [{ key: "render", value: function render() { var _this6 = this; var imageCell = $('<td width="160px;">'); this.image = this.renderImage(); imageCell.append(this.image); this.galleryLink = $('<a style="display: none;">'); this.galleryLink.click(function () { return _this6._onToggleGallery(); }); imageCell.append($('<div style="text-align: center;">').append(this.galleryLink)); return imageCell; } }, { key: "onImageThumbUpdated", value: function onImageThumbUpdated(imageThumb) { this._imageThumb = imageThumb; this.renderImageThumb(); } }, { key: "onUpdateImageCount", value: function onUpdateImageCount(galleryImagesCount) { this._galleryImagesCount = galleryImagesCount; if (!this.galleryLink) { return; } if (this._galleryImagesCount > 0) { this.galleryLink.show(); this.galleryLink.text('смотреть фото (' + this._galleryImagesCount + ')'); } else { this.galleryLink.hide(); } } }, { key: "renderImageThumb", value: function renderImageThumb() { if (this.image && this._listingData.image && this._imageThumb) { this.image.attr('src', this._imageThumb); } } }, { key: "renderImage", value: function renderImage() { var image = $('<img>'); image.attr('src', 'https://upload.wikimedia.org/' + 'wikipedia/commons/thumb/c/ca/Village_without_photo.svg/150px-Village_without_photo.svg.png'); if (this._listingData.image) { image.attr('alt', this._listingData.name); } else { image.attr('alt', 'Нет фото'); image.attr('class', 'thumbborder'); } this.renderImageThumb(); return image; } }]); return ImageCellComponent; }(); var UploadCellComponent = /*#__PURE__*/ function () { function UploadCellComponent(listingData) { _classCallCheck(this, UploadCellComponent); this._listingData = listingData; } _createClass(UploadCellComponent, [{ key: "render", value: function render() { return $('<td>').attr('style', 'width:10%; ' + 'text-align: center; ' + 'vertical-align: middle; ' + 'font-size: 120%; ' + 'background-color: #FFFACD').append($('<a>').attr('href', this.composeUploadUrl()).attr('class', 'external text').text('Загрузить фото')); } }, { key: "composeUploadUrl", value: function composeUploadUrl() { var params = { title: 'Special:UploadWizard', campaign: this._listingData.campaign, id: this._listingData.knid, id2: this._listingData.uid, // TODO full description description: this._listingData.description, categories: this._listingData.commonscat, userlang: 'ru' }; // TODO check how URL encoding works with spaces return 'http://commons.wikimedia.org/w/index.php?' + $.param(params); } }]); return UploadCellComponent; }(); var ViewComponent = /*#__PURE__*/ function () { function ViewComponent(container, listingData, onEdit) { _classCallCheck(this, ViewComponent); this._container = container; this._listingData = listingData; this._onEdit = onEdit; } _createClass(ViewComponent, [{ key: "render", value: function render() { var _this7 = this; var isMainComplexElement = this._listingData.complex && this._listingData.complex === this._listingData.knid; var cardBackgroundColor = this._getCardBackgroundColor(); if (cardBackgroundColor) { this._container.css({ 'background-color': cardBackgroundColor }); } if (this._listingData.type === 'architecture') { this._container.append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].MonumentType.createArchitectureIcon()); } else if (this._listingData.type === 'history') { this._container.append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].MonumentType.createHistoryIcon()); } else if (this._listingData.type === 'archeology') { this._container.append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].MonumentType.createArcheologyIcon()); } else if (this._listingData.type === 'monument') { this._container.append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].MonumentType.createMonumentIcon()); } this._container.append(' '); if (isMainComplexElement) { this._container.append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createComplexMainElementIcon()); this._container.append(' '); } var itemNameElement = $('<span class="monument-name" style="font-size:115%; font-weight:bold">'); itemNameElement.text(this._listingData.name); this._container.append(itemNameElement); var editButton = this.renderEditButton(); // TODO handle only click on image editButton.click(function () { _this7._onEdit(); }); this._container.append(editButton); this._container.append($('<br/>')); this._container.append($('<i>').text('Адрес: ')); if (this._listingData.municipality) { this._container.append($('<i>').text(this._listingData.municipality)); } if (this._listingData.munid) { this._container.append(' '); // TODO urlencode this._container.append($('<a>').attr('href', 'http://wikidata.org/wiki/' + this._listingData.munid).append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createMunidIcon())); } if (this._listingData.block) { this._container.append(', квартал ' + this._listingData.block); } if (this._listingData.address) { if (this._listingData.municipality) { this._container.append(', '); } this._container.append(this._listingData.address); } this._container.append($('<br/>')); this._container.append($('<i>').text('Номер объекта: ')); var knidSpan = $('<span>').attr('id', this._listingData.knid).text(this._listingData.knid); if (this._listingData['knid-new']) { knidSpan.append(' / ').append($('<abbr>').attr('title', '15-значный номер в Едином государственном реестре').append($('<a>').attr('href', 'https://tools.wmflabs.org/ru_monuments/get_info.php?id=' + this._listingData['knid-new']).text(this._listingData['knid-new']))); } // TODO: listing data UID this._container.append($('<span style="font-size:93%">').append(knidSpan)); this._container.append(' '); this._container.append($('<i>').text('Ссылки:')); this._container.append(' '); if (this._listingData.lat && this._listingData.long) { this._container.append($('<a>') // TODO correct link & escaping .attr('href', 'https://tools.wmflabs.org/wikivoyage/w/monmap1.php?lat=' + this._listingData.lat + '&lon=' + this._listingData.long + '&zoom=13&layer=OX&lang=ru').append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createMapIcon())); if (this._listingData.precise !== 'yes') { this._container.append($('<span style="color:#FF0000">!</span>')); } this._container.append(' '); } if (this._listingData.wiki) { this._container.append($('<a>').attr('alt', 'Статья в Википедии') // TODO urlencode .attr('href', 'http://ru.wikipedia.org/wiki/' + this._listingData.wiki).append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createWikipediaIcon())); } if (this._listingData.commonscat) { this._container.append($('<a>').attr('alt', 'Категория на Викискладе') // TODO urlencode .attr('href', 'http://commons.wikimedia.org/wiki/Category:' + this._listingData.commonscat).append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createCommonsIcon())); this._container.append('  '); } if (this._listingData.wdid) { this._container.append($('<a>').attr('alt', 'Элемент в Викиданных') // TODO urlencode .attr('href', 'http://www.wikidata.org/wiki/' + this._listingData.wdid).append(_listing_item_icons__WEBPACK_IMPORTED_MODULE_5__["ListingItemIcons"].createWikidataIcon())); } // TODO external links this._container.append($('<a>').attr('href', 'https://commons.wikimedia.org/wiki/Category:WLM/' + this._listingData.knid).text('галерея')); this._container.append('<br>'); this._container.append($('<i>').text('Описание:')); var descriptionComponents = []; if (this._listingData.year) { descriptionComponents.push(this._listingData.year); } if (this._listingData.author) { descriptionComponents.push(this._listingData.author); } if (descriptionComponents.length > 0) { this._container.append(descriptionComponents.join(', ') + '.'); } var typeText = ''; if (this._listingData.type === 'architecture') { typeText = 'Памятник архитектуры'; } else if (this._listingData.type === 'history') { typeText = 'Памятник истории'; } else if (this._listingData.type === 'archeology') { typeText = 'Памятник археологии'; } else if (this._listingData.type === 'monument') { typeText = 'Памятник монументального искусства'; } this._container.append(' ' + typeText); var protectionText = ''; if (this._listingData.protection === 'Ф') { protectionText = ' федерального значения'; } else if (this._listingData.protection === 'Р') { protectionText = ' регионального значения'; } else if (this._listingData.protection === 'М') { protectionText = ' местного значения'; } else if (this._listingData.protection === 'В') { protectionText = ', выявленный'; } if (protectionText) { this._container.append(protectionText); } // TODO documents } }, { key: "renderEditButton", value: function renderEditButton() { var editListingButton = $('<span>').attr({ 'class': 'vcard-edit-button noprint', 'style': 'padding-left: 5px;' }); var editListingLink = $('<a>').attr({ 'class': 'icon-pencil', 'title': 'Редактировать' }).text('Редактировать'); editListingButton.append(editListingLink); return editListingButton; } }, { key: "_getCardBackgroundColor", value: function _getCardBackgroundColor() { var knid = this._listingData.knid; var complex = this._listingData.complex; if (!knid) { return ''; } var isOfficial = !(knid % 100000000 >= 40000000 && knid % 100000000 <= 49999999); var isMainComplexElement = knid === complex; if (isOfficial) { if (complex) { if (isMainComplexElement) { return '#baffc1'; } else { return '#e1ffe4'; } } else { return '#f8f8f8'; } } else { if (complex) { if (isMainComplexElement) { return '#cdeefe'; } else { return '#ebf5f9'; } } else { return '#f8f8ed'; } } } }]); return ViewComponent; }(); var EditorComponent = /*#__PURE__*/ function () { function EditorComponent(container, listingData, onDiscard, onSave) { _classCallCheck(this, EditorComponent); this._container = container; this._listingData = listingData; this._onDiscard = onDiscard; this._onSave = onSave; } _createClass(EditorComponent, [{ key: "setImage", value: function setImage(image) { this._inputImage.val(image); this._onValueChange(); } }, { key: "render", value: function render() { var _this8 = this; this._container.css({ 'background-color': '#FFFFFF' }); var inputName = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputLarge(); var inputRegion = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createSelector(_regions__WEBPACK_IMPORTED_MODULE_3__["regions"].map(function (region) { return { title: region.getTitle(), value: region.getId() }; })); var inputDistrict = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputMunicipality = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputBlock = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputAddress = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputLat = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputSmall(); var inputLong = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputSmall(); var inputPrecise = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createCheckboxInput(); var inputStyle = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createSelector(_cultural_monument_styles__WEBPACK_IMPORTED_MODULE_1__["culturalMonumentStyles"].map(function (culturalMonumentStyle) { return { title: culturalMonumentStyle.getTitle(), value: culturalMonumentStyle.getValue() }; })); var inputType = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createSelector(_cultural_monument_types__WEBPACK_IMPORTED_MODULE_0__["culturalMonumentTypes"].map(function (culturalMonumentType) { return { title: culturalMonumentType.getTitle(), value: culturalMonumentType.getValue() }; })); var inputProtection = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createSelector(_cultural_monument_protections__WEBPACK_IMPORTED_MODULE_2__["culturalMonumentProtections"].map(function (culturalMonumentProtection) { return { title: culturalMonumentProtection.getTitle(), value: culturalMonumentProtection.getValue() }; })); var inputYear = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputSmall(); var inputAuthor = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputDestroyed = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createCheckboxInput(); this._inputImage = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputWikipedia = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputWikidata = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputSmall(); var inputCommons = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputMunid = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputSmall(); var inputDocument = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputLink = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputLinkExtra = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(); var inputKnid = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(10); var inputComplex = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(10); var inputKnidNew = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInput(15); var inputDescription = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextarea(); var allInputs = [inputName, inputType, inputRegion, inputDistrict, inputMunicipality, inputBlock, inputAddress, inputLat, inputLong, inputYear, inputAuthor, inputKnid, inputComplex, inputKnidNew, this._inputImage, inputWikipedia, inputWikidata, inputCommons, inputMunid, inputDocument, inputLink, inputLinkExtra, inputDescription, inputProtection, inputStyle, inputDestroyed, inputPrecise]; var directMappingInputs = { name: inputName, type: inputType, region: inputRegion, district: inputDistrict, municipality: inputMunicipality, block: inputBlock, address: inputAddress, lat: inputLat, long: inputLong, year: inputYear, author: inputAuthor, knid: inputKnid, complex: inputComplex, 'knid-new': inputKnidNew, image: this._inputImage, wiki: inputWikipedia, wdid: inputWikidata, commonscat: inputCommons, munid: inputMunid, document: inputDocument, link: inputLink, linkextra: inputLinkExtra, description: inputDescription, protection: inputProtection }; var setValues = function setValues(listing) { Object.keys(directMappingInputs).forEach(function (key) { if (listing[key]) { directMappingInputs[key].val(listing[key]); } }); if (listing['style']) { inputStyle.val(listing['style'].toLowerCase()); } inputDestroyed.attr('checked', listing['status'] === 'destroyed'); inputPrecise.attr('checked', listing['precise'] === 'yes'); }; var getValues = function getValues() { var listingData = {}; Object.keys(directMappingInputs).forEach(function (key) { listingData[key] = directMappingInputs[key].val(); }); if (inputDestroyed.is(':checked')) { listingData['status'] = 'destroyed'; } else { listingData['status'] = ''; } if (inputPrecise.is(':checked')) { listingData['precise'] = 'yes'; } else { listingData['precise'] = 'no'; } listingData['link'] = _validation_utils__WEBPACK_IMPORTED_MODULE_4__["ValidationUtils"].normalizeUrl(listingData['link']); listingData['linkextra'] = _validation_utils__WEBPACK_IMPORTED_MODULE_4__["ValidationUtils"].normalizeUrl(listingData['linkextra']); listingData['style'] = inputStyle.val(); return listingData; }; setValues(this._listingData); var nameRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Название:').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement(null, inputName)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createInsertSymbols(inputName)); this._container.append(nameRow); var addressRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Адрес:').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Регион', inputRegion)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Район', inputDistrict)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Населенный пункт', inputMunicipality)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Квартал', inputBlock)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Улица, дом', inputAddress)); this._container.append(addressRow); var coordRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Координаты: ').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Широта', inputLat)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Долгота', inputLong)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Заданы точно?', inputPrecise)); this._container.append(coordRow); var propsRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Свойства: ').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Тип', inputType)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Стиль', inputStyle)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Категория охраны', inputProtection)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Год', inputYear)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Автор', inputAuthor)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Утрачен', inputDestroyed)); this._container.append(propsRow); var linksRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Ссылки: ').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Изображение', this._inputImage)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Википедия', inputWikipedia)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Викиданные', inputWikidata)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Викисклад', inputCommons)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Викиданные нас. пункта', inputMunid)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Код документа', inputDocument)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Ссылка №1', inputLink)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('Ссылка №2', inputLinkExtra)); this._container.append(linksRow); var numbersRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Номера: ').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('10-значный № объекта', inputKnid)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('10-значный № комплекса', inputComplex)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('15-значный № объекта', inputKnidNew)); this._container.append(numbersRow); var descriptionRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Описание:').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement(null, inputDescription)); this._container.append(descriptionRow); var inputChanges = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createTextInputLarge(); var inputIsMinor = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createCheckboxInput(); var changesDescriptionRow = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormRow('Описание изменений: ').append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement(null, inputChanges)).append(_listing_item_form_composer__WEBPACK_IMPORTED_MODULE_6__["ListingItemFormComposer"].createFormElement('незначительные?', inputIsMinor)); changesDescriptionRow.css('border-top', '1px dotted gray'); changesDescriptionRow.css('border-bottom', '1px dotted gray'); changesDescriptionRow.css('margin-top', '3px'); var changesChanged = false; inputChanges.change(function () { changesChanged = true; }); this._onValueChange = function () { if (!changesChanged) { var values = getValues(); var originalData = _this8._listingData; var changedItems = []; Object.keys(values).forEach(function (key) { if (_string_utils__WEBPACK_IMPORTED_MODULE_9__["StringUtils"].emptyToString(originalData[key]) !== _string_utils__WEBPACK_IMPORTED_MODULE_9__["StringUtils"].emptyToString(values[key])) { changedItems.push(key); } }); if (_array_utils__WEBPACK_IMPORTED_MODULE_10__["ArrayUtils"].consistsOnlyOf(changedItems, ['name'])) { inputChanges.val('название'); } else if (_array_utils__WEBPACK_IMPORTED_MODULE_10__["ArrayUtils"].consistsOnlyOf(changedItems, ['image'])) { inputChanges.val('изображение'); } else if (_array_utils__WEBPACK_IMPORTED_MODULE_10__["ArrayUtils"].consistsOnlyOf(changedItems, ['address'])) { inputChanges.val('адрес'); } else if (_array_utils__WEBPACK_IMPORTED_MODULE_10__["ArrayUtils"].consistsOnlyOf(changedItems, ['lat', 'long', 'precise'])) { inputChanges.val('координаты'); } else { inputChanges.val(''); } } }; allInputs.forEach(function (input) { return input.change(_this8._onValueChange); }); this._container.append(changesDescriptionRow); var buttonsBlock = $('<div>').attr('class', 'ui-dialog-buttonset'); var buttonDiscard = this.renderButton('Отменить'); var buttonSave = this.renderButton('Сохранить'); buttonsBlock.append(buttonDiscard); buttonsBlock.append(buttonSave); buttonDiscard.click(function () { _this8._onDiscard(); }); buttonSave.click(function () { var values = getValues(); var changesDescription = new _changes_description__WEBPACK_IMPORTED_MODULE_8__["ChangesDescription"](inputChanges.val(), inputIsMinor.is(':checked')); _this8._onSave(values, changesDescription); }); this._container.append(buttonsBlock); } }, { key: "renderButton", value: function renderButton(buttonText) { return $('<button>').attr('class', 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only').append($('<span>').attr('class', 'ui-button-text').text(buttonText)); } }]); return EditorComponent; }(); var GalleryRowComponent = /*#__PURE__*/ function () { function GalleryRowComponent(onSelectImage) { _classCallCheck(this, GalleryRowComponent); this._onSelectImage = onSelectImage; } _createClass(GalleryRowComponent, [{ key: "render", value: function render() { this._galleryContents = $('<td colspan="2">'); this._galleryComponent = new GalleryComponent(this._galleryContents, this._onSelectImage); this._galleryComponent.render(); this._galleryRow = $('<tr style="display: none;">').append(this._galleryContents); return this._galleryRow; } }, { key: "onModeUpdate", value: function onModeUpdate(mode) { this._mode = mode; this.updateMode(); } }, { key: "updateMode", value: function updateMode() { this._galleryComponent.onModeUpdate(this._mode); } }, { key: "toggle", value: function toggle() { this._galleryRow.toggle(); } }, { key: "setGalleryImages", value: function setGalleryImages(galleryImages) { this._galleryComponent.setGalleryImages(galleryImages); } }]); return GalleryRowComponent; }(); var GalleryComponent = /*#__PURE__*/ function () { function GalleryComponent(container, onSelectImage) { _classCallCheck(this, GalleryComponent); this._galleryImages = null; this._container = container; this._imageComponents = []; this._onSelectImage = onSelectImage; } _createClass(GalleryComponent, [{ key: "onModeUpdate", value: function onModeUpdate(mode) { this._mode = mode; this.updateMode(); } }, { key: "updateMode", value: function updateMode() { var _this9 = this; this._imageComponents.forEach(function (imageComponent) { imageComponent.onModeUpdate(_this9._mode); }); } }, { key: "setGalleryImages", value: function setGalleryImages(galleryImages) { this._galleryImages = galleryImages; this.render(); } }, { key: "render", value: function render() { if (!this._container) { return; } this._container.empty(); this._renderGallery(); } }, { key: "_renderGallery", value: function _renderGallery() { if (!this._galleryImages) { this._container.text('загрузка...'); } else { if (this._galleryImages.hasWlmImages()) { this._container.append(this._renderGallerySection('Фотографии Wiki Loves Monuments', this._galleryImages.getWlmImages())); } if (this._galleryImages.hasCommonsImages()) { this._container.append(this._renderGallerySection('Фотографии из категории Commons', this._galleryImages.getCommonsImages())); } } } }, { key: "_renderGallerySection", value: function _renderGallerySection(title, images) { var _this10 = this; var headerDiv = $('<div style="width: 100%; text-align: center; font-weight: bold;">').text(title); var imagesDiv = $('<div style="display: flex; flex-direction: row; flex-wrap: wrap; align-items: center">'); images.forEach(function (image) { var imageComponent = new GalleryImageComponent(imagesDiv, image, _this10._onSelectImage, _this10._mode); imageComponent.render(); _this10._imageComponents.push(imageComponent); }); return $('<div>').append(headerDiv).append(imagesDiv); } }]); return GalleryComponent; }(); var GalleryImageComponent = /*#__PURE__*/ function () { function GalleryImageComponent(container, image, onSelect, mode) { _classCallCheck(this, GalleryImageComponent); this._container = container; this._image = image; this._onSelect = onSelect; this.mode = mode; } _createClass(GalleryImageComponent, [{ key: "onModeUpdate", value: function onModeUpdate(mode) { this.mode = mode; this.updateMode(); } }, { key: "updateMode", value: function updateMode() { if (this.mode === MODES.EDIT) { this._selectLink.show(); } else { this._selectLink.hide(); } } }, { key: "render", value: function render() { var _this11 = this; var imageElement = $('<img>').attr('src', this._image.thumb); var commonsUrl = 'https://commons.wikimedia.org/wiki/' + this._image.image; var fullSizeUrl = this._image.url; var imageLink = $('<a>').attr('href', fullSizeUrl).attr('target', '_blank').append(imageElement); var viewCommonsLink = $('<a>').text('[Смотрeть на Commons]').attr('href', commonsUrl).attr('target', '_blank'); var viewFullLink = $('<a>').text('[Смотреть в полном размере]').attr('href', fullSizeUrl).attr('target', '_blank'); this._selectLink = $('<a style="display: none;">').text('[Выбрать]').click(function () { return _this11._onSelect(_this11._image.image.replace(/^File:/, '').replace(' ', '_')); }); this._container.append($('<div style="padding: 10px; display: flex; flex-direction: column; justify-content: center">').append($('<div>').append(imageLink)).append($('<div style="text-align: center">').append(viewCommonsLink)).append($('<div style="text-align: center">').append(viewFullLink)).append($('<div style="text-align: center">').append(this._selectLink))); this.updateMode(); } }]); return GalleryImageComponent; }(); var MODES = { VIEW: 'view', EDIT: 'edit' }; /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CulturalMonumentType", function() { return CulturalMonumentType; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "culturalMonumentTypes", function() { return culturalMonumentTypes; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var CulturalMonumentType = /*#__PURE__*/ function () { function CulturalMonumentType(value, title) { _classCallCheck(this, CulturalMonumentType); this._value = value; this._title = title; } _createClass(CulturalMonumentType, [{ key: "getValue", value: function getValue() { return this._value; } }, { key: "getTitle", value: function getTitle() { return this._title; } }]); return CulturalMonumentType; }(); var culturalMonumentTypes = [new CulturalMonumentType('', ''), new CulturalMonumentType('architecture', 'памятник архитектуры'), new CulturalMonumentType('history', 'памятник истории'), new CulturalMonumentType('monument', 'памятник монументального искусства'), new CulturalMonumentType('archeology', 'памятник археологии')]; /***/ }), /* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CulturalMonumentStyle", function() { return CulturalMonumentStyle; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "culturalMonumentStyles", function() { return culturalMonumentStyles; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var CulturalMonumentStyle = /*#__PURE__*/ function () { function CulturalMonumentStyle(value, title) { _classCallCheck(this, CulturalMonumentStyle); this._value = value; this._title = title; } _createClass(CulturalMonumentStyle, [{ key: "getTitle", value: function getTitle() { return this._title; } }, { key: "getValue", value: function getValue() { return this._value; } }]); return CulturalMonumentStyle; }(); var culturalMonumentStyles = [new CulturalMonumentStyle('', ''), new CulturalMonumentStyle('конструктивизм', 'конструктивизм'), new CulturalMonumentStyle('модерн', 'модерн')]; /***/ }), /* 10 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CulturalMonumentProtection", function() { return CulturalMonumentProtection; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "culturalMonumentProtections", function() { return culturalMonumentProtections; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var CulturalMonumentProtection = /*#__PURE__*/ function () { function CulturalMonumentProtection(value, title) { _classCallCheck(this, CulturalMonumentProtection); this._value = value; this._title = title; } _createClass(CulturalMonumentProtection, [{ key: "getTitle", value: function getTitle() { return this._title; } }, { key: "getValue", value: function getValue() { return this._value; } }]); return CulturalMonumentProtection; }(); var culturalMonumentProtections = [new CulturalMonumentProtection('', ''), new CulturalMonumentProtection('Ф', 'федеральная'), new CulturalMonumentProtection('Р', 'региональная'), new CulturalMonumentProtection('М', 'местная'), new CulturalMonumentProtection('В', 'выявленный объект')]; /***/ }), /* 11 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Region", function() { return Region; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "regions", function() { return regions; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var Region = /*#__PURE__*/ function () { function Region(id, title) { _classCallCheck(this, Region); this._id = id; this._title = title; } _createClass(Region, [{ key: "getId", value: function getId() { return this._id; } }, { key: "getTitle", value: function getTitle() { return this._title; } }]); return Region; }(); var regions = [new Region("", "не задан"), new Region("ru-ad", "Адыгея"), new Region("ru-ba", "Башкортостан"), new Region("ru-bu", "Бурятия"), new Region("ru-al", "Алтай"), new Region("ru-da", "Дагестан"), new Region("ru-in", "Ингушетия"), new Region("ru-kb", "Кабардино-Балкария"), new Region("ru-kl", "Калмыкия"), new Region("ru-kc", "Карачаево-Черкесия"), new Region("ru-krl", "Карелия"), new Region("ru-ko", "республика Коми"), new Region("ru-me", "Марий Эл"), new Region("ru-mo", "Мордовия"), new Region("ru-sa", "Якутия (Саха)"), new Region("ru-se", "Северная Осетия"), new Region("ru-ta", "Татарстан"), new Region("ru-ty", "Тува"), new Region("ru-ud", "Удмуртия"), new Region("ru-kk", "Хакасия"), new Region("ru-ce", "Чеченская республика"), new Region("ru-chv", "Чувашия"), new Region("ru-alt", "Алтайский край"), new Region("ru-kda", "Краснодарский край"), new Region("ru-kya", "Красноярский край"), new Region("ru-pri", "Приморский край"), new Region("ru-sta", "Ставропольский край"), new Region("ru-kha", "Хабаровский край"), new Region("ru-amu", "Амурская область"), new Region("ru-ark", "Архангельская область"), new Region("ru-ast", "Астраханская область"), new Region("ru-bel", "Белгородская область"), new Region("ru-bry", "Брянская область"), new Region("ru-vla", "Владимирская область"), new Region("ru-vgg", "Волгоградская область"), new Region("ru-vol", "Вологодская область"), new Region("ru-vor", "Воронежская область"), new Region("ru-iva", "Ивановская область"), new Region("ru-irk", "Иркутская область"), new Region("ru-kal", "Калининградская область"), new Region("ru-klu", "Калужская область"), new Region("ru-kam", "Камчатский край"), new Region("ru-kem", "Кемеровская область"), new Region("ru-kir", "Кировская область"), new Region("ru-kos", "Костромская область"), new Region("ru-kgn", "Курганская область"), new Region("ru-krs", "Курская область"), new Region("ru-len", "Ленинградская область"), new Region("ru-lip", "Липецкая область"), new Region("ru-mag", "Магаданская область"), new Region("ru-mos", "Московская область"), new Region("ru-mur", "Мурманская область"), new Region("ru-niz", "Нижегородская область"), new Region("ru-ngr", "Новгородская область"), new Region("ru-nvs", "Новосибирская область"), new Region("ru-oms", "Омская область"), new Region("ru-ore", "Оренбургская область"), new Region("ru-orl", "Орловская область"), new Region("ru-pnz", "Пензенская область"), new Region("ru-per", "Пермский край"), new Region("ru-psk", "Псковская область"), new Region("ru-ros", "Ростовская область"), new Region("ru-rya", "Рязанская область"), new Region("ru-sam", "Самарская область"), new Region("ru-sar", "Саратовская область"), new Region("ru-sak", "Сахалинская область"), new Region("ru-sve", "Свердловская область"), new Region("ru-smo", "Смоленская область"), new Region("ru-tam", "Тамбовская область"), new Region("ru-tve", "Тверская область"), new Region("ru-tom", "Томская область"), new Region("ru-tul", "Тульская область"), new Region("ru-tyu", "Тюменская область"), new Region("ru-uly", "Ульяновская область"), new Region("ru-che", "Челябинская область"), new Region("ru-zab", "Забайкальский край"), new Region("ru-yar", "Ярославская область"), new Region("ru-mow", "Москва"), new Region("ru-spb", "Санкт-Петербург"), new Region("ru-jew", "Еврейская автономная область"), new Region("ru-km", "Крым"), new Region("ru-nen", "Ненецкий автономный округ"), new Region("ru-khm", "Ханты-Мансийский автономный округ"), new Region("ru-chu", "Чукотский автономный округ"), new Region("ru-yam", "Ямало-Ненецкий автономный округ"), new Region("ru-sev", "Севастополь")]; /***/ }), /* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValidationUtils", function() { return ValidationUtils; }); var ValidationUtils = { normalizeUrl: function normalizeUrl(url) { var webRegex = new RegExp('^https?://', 'i'); if (!webRegex.test(url) && url !== '') { return 'http://' + url; } else { return url; } } }; /***/ }), /* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingItemIcons", function() { return ListingItemIcons; }); var ListingItemIcons = { THUMBS_URL: 'https://upload.wikimedia.org/wikipedia/commons/thumb/', createComplexMainElementIcon: function createComplexMainElementIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + '8/8c/Location_dot_darkslategray.svg/10px-Location_dot_darkslategray.svg.png', 'alt': 'главный элемент комплекса', 'width': '10px', 'height': '10px' }); }, createMunidIcon: function createMunidIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'f/ff/Wikidata-logo.svg/18px-Wikidata-logo.svg.png', 'alt': 'район на Викиданных', 'width': '18px', 'height': '10px' }); }, createMapIcon: function createMapIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'c/ce/Map_mag.png/17px-Map_mag.png', 'alt': 'Расположение на карте', 'width': '17px', 'height': '17px' }); }, createWikipediaIcon: function createWikipediaIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + '8/80/Wikipedia-logo-v2.svg/19px-Wikipedia-logo-v2.svg.png', 'alt': 'Расположение на карте', 'width': '19px', 'height': '17px' }); }, createCommonsIcon: function createCommonsIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + '4/4a/Commons-logo.svg/17px-Commons-logo.svg.png', 'alt': 'Расположение на карте', 'width': '17px', 'height': '23px' }); }, createWikidataIcon: function createWikidataIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'f/ff/Wikidata-logo.svg/24px-Wikidata-logo.svg.png', 'alt': 'Расположение на карте', 'width': '24px', 'height': '13px' }); }, MonumentType: { createArchitectureIcon: function createArchitectureIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'c/cc/PorticoIcon.svg/20px-PorticoIcon.svg.png', 'alt': 'памятник архитектуры', 'width': '20px', 'height': '20px' }); }, createHistoryIcon: function createHistoryIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'c/c8/HistoryIcon.svg/18px-HistoryIcon.svg.png', 'alt': 'памятник истории', 'width': '18px', 'height': '18px' }); }, createArcheologyIcon: function createArcheologyIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'c/ce/ArcheologyIcon.svg/22px-ArcheologyIcon.svg.png', 'alt': 'памятник археологии', 'width': '22px', 'height': '22px' }); }, createMonumentIcon: function createMonumentIcon() { return $('<img>').attr({ 'src': ListingItemIcons.THUMBS_URL + 'c/c2/MonumentIcon.svg/20px-MonumentIcon.svg.png', 'alt': 'памятник монументального искусства', 'width': '20px', 'height': '20px' }); } } }; /***/ }), /* 14 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingItemFormComposer", function() { return ListingItemFormComposer; }); /* harmony import */ var _input_insert_symbols__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); var ListingItemFormComposer = { createTextInput: function createTextInput(size) { var input = $('<input>').attr({ 'type': 'text', 'style': 'font-size: 97%; border: 1px solid grey;' }); if (size) { input.attr('size', size); } return input; }, createTextInputLarge: function createTextInputLarge() { return $('<input>').attr({ 'type': 'text', 'style': 'font-size: 97%; border: 1px solid grey; width: 600px;' }); }, createTextInputSmall: function createTextInputSmall() { return $('<input>').attr({ 'type': 'text', 'style': 'font-size: 97%; border: 1px solid grey; width: 100px;' }); }, createTextarea: function createTextarea() { return $('<textarea>').attr({ 'type': 'text', 'style': 'font-size: 97%; border: 1px solid grey; width: 600px;', 'rows': '3' }); }, createCheckboxInput: function createCheckboxInput() { return $('<input>').attr({ 'type': 'checkbox', 'style': 'border: 1px solid grey;' }); }, createSelector: function createSelector(options) { var inputElement = $('<select>').attr({ 'style': 'font-size: 97%; border: 1px solid grey; width: 200px;' }); options.forEach(function (option) { var optionElement = $('<option>', { 'value': option.value, 'html': option.title }); inputElement.append(optionElement); }); return inputElement; }, createFormRow: function createFormRow(rowTitle) { return $('<div>').attr('style', 'display: flex; flex-wrap: wrap;').append($('<div>').attr('style', 'font-weight: bold; padding-top: 5px;').text(rowTitle)); }, createFormElement: function createFormElement(title, input) { var formElement = $('<div>').attr('style', 'padding-left: 5px; display: flex; padding-top: 5px;'); if (title) { formElement.append($('<div>').attr('style', 'padding-left: 5px;').text(title)); } formElement.append($('<div>').attr('style', 'padding-left: 5px;').append(input)); return formElement; }, createInsertSymbols: function createInsertSymbols(input) { var buttonInsertQuotes = $('<a>', { 'class': 'name-quotes-template', href: 'javascript:;', html: '«»' }); var buttonInsertDash = $('<a>', { 'class': 'name-dash-template', href: 'javascript:;', html: '—' }); _input_insert_symbols__WEBPACK_IMPORTED_MODULE_0__["InputInsertSymbols"].addDashInsertHandler(buttonInsertDash, input); _input_insert_symbols__WEBPACK_IMPORTED_MODULE_0__["InputInsertSymbols"].addQuotesInsertHandler(buttonInsertQuotes, input); return $('<span>').append(' ').append(buttonInsertQuotes).append(' ').append(buttonInsertDash); } }; /***/ }), /* 15 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputInsertSymbols", function() { return InputInsertSymbols; }); var InputInsertSymbols = { addQuotesInsertHandler: function addQuotesInsertHandler(insertButton, insertToInput) { insertButton.click(function () { var selectionStart = insertToInput[0].selectionStart; var selectionEnd = insertToInput[0].selectionEnd; var oldValue = insertToInput.val(); var newValue = oldValue.substring(0, selectionStart) + "«" + oldValue.substring(selectionStart, selectionEnd) + "»" + oldValue.substring(selectionEnd); insertToInput.val(newValue); InputInsertSymbols._selectRange(insertToInput[0], selectionStart + 1, selectionEnd + 1); }); }, addDashInsertHandler: function addDashInsertHandler(insertButton, insertToInput) { insertButton.click(function () { var caretPos = insertToInput[0].selectionStart; var oldValue = insertToInput.val(); var newValue = oldValue.substring(0, caretPos) + "—" + oldValue.substring(caretPos); insertToInput.val(newValue); InputInsertSymbols._selectRange(insertToInput[0], caretPos + 1); }); }, _selectRange: function _selectRange(element, start, end) { if (end === undefined) { end = start; } element.focus(); if ('selectionStart' in element) { element.selectionStart = start; element.selectionEnd = end; } else if (element.setSelectionRange) { element.setSelectionRange(start, end); } else if (element.createTextRange) { var range = element.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', start); range.select(); } } }; /***/ }), /* 16 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SearchBar", function() { return SearchBar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SearchConstants", function() { return SearchConstants; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SortConstants", function() { return SortConstants; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SearchFilter", function() { return SearchFilter; }); /* harmony import */ var _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14); /* harmony import */ var _cultural_monument_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8); /* harmony import */ var _cultural_monument_styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9); /* harmony import */ var _cultural_monument_protections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var SearchBar = /*#__PURE__*/ function () { function SearchBar(onUpdate, onUpdateItemsOnPage, onUpdateView, onUpdateSort) { _classCallCheck(this, SearchBar); this._onUpdate = onUpdate; this._onUpdateItemsOnPage = onUpdateItemsOnPage; this._onUpdateView = onUpdateView; this._onUpdateSort = onUpdateSort; this._initComponents(); } _createClass(SearchBar, [{ key: "render", value: function render() { return this._searchBar; } }, { key: "_initComponents", value: function _initComponents() { var _this = this; this._searchBar = $('<div style="padding: 10px; background-color: #f8f9fa; border: 1px solid #a2a9b1;">'); this._inputSort = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector([{ title: 'По-умолчанию', value: SortConstants.DEFAULT }, { title: 'По названию', value: SortConstants.NAME }, { title: 'По адресу', value: SortConstants.ADDRESS }, { title: 'По типу', value: SortConstants.TYPE }]); this._inputItemsOnPage = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector([{ title: '10', value: 10 }, { title: '50', value: 50 }, { title: '100', value: 100 }, { title: '250', value: 250 }, { title: '500', value: 500 }, { title: 'все', value: 0 }]).css('width', '50px'); this._inputView = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector([{ title: 'полный', value: SearchConstants.VIEW_FULL }, { title: 'компактный', value: SearchConstants.VIEW_COMPACT }]).css('width', '120px'); this._inputSearchDescription = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createTextInput(); this._inputSearchAddress = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createTextInput(); this._inputImage = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector([{ title: '', value: SearchConstants.PHOTO_ANY }, { title: 'Отсутствует', value: SearchConstants.PHOTO_NO }, { title: 'Присутствует', value: SearchConstants.PHOTO_YES }]); this._inputCoordinates = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector([{ title: '', value: SearchConstants.COORDINATES_ANY }, { title: 'Заданы, точные', value: SearchConstants.COORDINATES_PRECISE }, { title: 'Заданы, неточные', value: SearchConstants.COORDINATES_NOT_PRECISE }, { title: 'Заданы, любые', value: SearchConstants.COORDINATES_EXISTS }, { title: 'Не заданы', value: SearchConstants.COORDINATES_NO }]); var filterStyleVals = _cultural_monument_styles__WEBPACK_IMPORTED_MODULE_2__["culturalMonumentStyles"].map(function (culturalMonumentStyle) { return { title: culturalMonumentStyle.getTitle(), value: culturalMonumentStyle.getValue() }; }); this._inputStyle = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector(filterStyleVals); var filterTypeVals = _cultural_monument_types__WEBPACK_IMPORTED_MODULE_1__["culturalMonumentTypes"].map(function (culturalMonumentType) { return { title: culturalMonumentType.getTitle(), value: culturalMonumentType.getValue() }; }); this._inputType = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector(filterTypeVals); var filterProtectionVals = _cultural_monument_protections__WEBPACK_IMPORTED_MODULE_3__["culturalMonumentProtections"].map(function (culturalMonumentProtection) { return { title: culturalMonumentProtection.getTitle(), value: culturalMonumentProtection.getValue() }; }); this._inputProtection = _listing_item_form_composer__WEBPACK_IMPORTED_MODULE_0__["ListingItemFormComposer"].createSelector(filterProtectionVals); this._hideLink = $('<a href="javascript:;" style="display: none;">').text('[Скрыть]'); this._showLink = $('<a href="javascript:;">').text('[Показать]'); this._searchBar.append($('<div style="display: flex; justify-content: space-between;">').append($('<div>').append($('<b>').text('Фильтры')).append(' ').append(this._hideLink).append(this._showLink)).append($('<div style="display: flex;">').append($('<div>').append($('<b>').text('Упорядочить: ')).append(this._inputSort)).append($('<div style="padding-left: 10px;">').append($('<b>').text('Вид: ')).append(this._inputView)).append($('<div style="padding-left: 10px;">').append($('<b>').text('Элементов на странице: ')).append(this._inputItemsOnPage)))); this._filtersBar = $('<div style="display: none;">'); this._hideLink.click(function () { _this._hideLink.hide(); _this._showLink.show(); _this._filtersBar.hide(); }); this._showLink.click(function () { _this._showLink.hide(); _this._hideLink.show(); _this._filtersBar.show(); }); this._searchBar.append(this._filtersBar); this._filtersBar.append($('<div style="padding: 5px;">').append('Название или описание: ').append(this._inputSearchDescription)); this._filtersBar.append($('<div style="padding: 5px;">').append('Адрес: ').append(this._inputSearchAddress)); this._filtersBar.append($('<div style="padding: 5px;">').append('Фотография: ').append(this._inputImage)); this._filtersBar.append($('<div style="padding: 5px;">').append('Координаты: ').append(this._inputCoordinates)); this._filtersBar.append($('<div style="padding: 5px;">').append('Стиль: ').append(this._inputStyle)); this._filtersBar.append($('<div style="padding: 5px;">').append('Тип: ').append(this._inputType)); this._filtersBar.append($('<div style="padding: 5px;">').append('Категория охраны: ').append(this._inputProtection)); this._inputSearchDescription.keyup(function () { return _this._onUpdateSearch(); }); this._inputSearchAddress.keyup(function () { return _this._onUpdateSearch(); }); this._inputImage.change(function () { return _this._onUpdateSearch(); }); this._inputCoordinates.change(function () { return _this._onUpdateSearch(); }); this._inputType.change(function () { return _this._onUpdateSearch(); }); this._inputStyle.change(function () { return _this._onUpdateSearch(); }); this._inputProtection.change(function () { return _this._onUpdateSearch(); }); this._inputItemsOnPage.change(function () { return _this._onUpdateItemsOnPage(parseInt(_this._inputItemsOnPage.val())); }); this._inputView.change(function () { return _this._onUpdateView(_this._inputView.val()); }); this._inputSort.change(function () { return _this._onUpdateSort(_this._inputSort.val()); }); } }, { key: "_onUpdateSearch", value: function _onUpdateSearch() { this._onUpdate(this._getCurrentSearchFilter()); } }, { key: "_getCurrentSearchFilter", value: function _getCurrentSearchFilter() { return new SearchFilter(this._inputSearchDescription.val(), this._inputSearchAddress.val(), this._inputImage.val(), this._inputCoordinates.val(), this._inputType.val(), this._inputStyle.val(), this._inputProtection.val()); } }]); return SearchBar; }(); var SearchConstants = { PHOTO_ANY: '', PHOTO_YES: 'yes', PHOTO_NO: 'no', COORDINATES_ANY: '', COORDINATES_EXISTS: 'exists', COORDINATES_PRECISE: 'precise', COORDINATES_NOT_PRECISE: 'not-precise', COORDINATES_NO: 'no', VIEW_FULL: 'full', VIEW_COMPACT: 'compact' }; var SortConstants = { DEFAULT: 'default', NAME: 'name', ADDRESS: 'address', TYPE: 'type' }; var SearchFilter = /*#__PURE__*/ function () { function SearchFilter(searchText, searchAddress, photo, coordinates, type, style, protection) { _classCallCheck(this, SearchFilter); this._searchDescription = searchText; this._searchAddress = searchAddress; this._photo = photo; this._coordinates = coordinates; this._type = type; this._style = style; this._protection = protection; } _createClass(SearchFilter, [{ key: "getSearchDescription", value: function getSearchDescription() { return this._searchDescription; } }, { key: "getSearchAddress", value: function getSearchAddress() { return this._searchAddress; } }, { key: "getPhoto", value: function getPhoto() { return this._photo; } }, { key: "getCoordinates", value: function getCoordinates() { return this._coordinates; } }, { key: "getType", value: function getType() { return this._type; } }, { key: "getStyle", value: function getStyle() { return this._style; } }, { key: "getProtection", value: function getProtection() { return this._protection; } }]); return SearchFilter; }(); /***/ }), /* 17 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChangesDescription", function() { return ChangesDescription; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ChangesDescription = /*#__PURE__*/ function () { function ChangesDescription(description, isMinor) { _classCallCheck(this, ChangesDescription); this._description = description; this._isMinor = isMinor; } _createClass(ChangesDescription, [{ key: "getDescription", value: function getDescription() { return this._description; } }, { key: "getIsMinor", value: function getIsMinor() { return this._isMinor; } }]); return ChangesDescription; }(); /***/ }), /* 18 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayUtils", function() { return ArrayUtils; }); var ArrayUtils = { hasElement: function hasElement(array, element) { return array.indexOf(element) >= 0; }, inArray: function inArray(element, array) { return this.hasElement(array, element); }, diff: function diff(array1, array2) { var _this = this; return array1.filter(function (item) { return !_this.inArray(item, array2); }); }, consistsOnlyOf: function consistsOnlyOf(array, items) { var arrayUnique = this.unique(array); var itemsUnique = this.unique(items); arrayUnique.sort(); itemsUnique.sort(); for (var i = 0; i < arrayUnique.length; i++) { if (!this.inArray(arrayUnique[i], itemsUnique[i])) { return false; } } return true; }, unique: function unique(array) { return array.filter(function (value, index) { return array.indexOf(value) === index; }); } }; /***/ }), /* 19 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncUtils", function() { return AsyncUtils; }); var AsyncUtils = { runSequence: function runSequence(functions, onSuccess, results) { if (!results) { results = []; } if (functions.length > 0) { var firstFunction = functions[0]; firstFunction(function (result) { results.push(result); setTimeout( // hack to break recursion chain function () { AsyncUtils.runSequence(functions.slice(1), onSuccess, results); }, 0); }); } else { if (onSuccess) { onSuccess(results); } } }, runChunks: function runChunks(runSingleChunkFunction, maxChunkSize, data, onSuccess) { var chunkRunFunctions = []; var _loop = function _loop(dataNumStart) { var dataChunk = data.slice(dataNumStart, dataNumStart + maxChunkSize); chunkRunFunctions.push(function (onSuccess) { return runSingleChunkFunction(dataChunk, onSuccess); }); }; for (var dataNumStart = 0; dataNumStart < data.length; dataNumStart += maxChunkSize) { _loop(dataNumStart); } this.runSequence(chunkRunFunctions, function (chunkResults) { var result = chunkResults.reduce(function (current, total) { return total.concat(current); }, []); onSuccess(result); }); } }; /***/ }), /* 20 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WikivoyageApi", function() { return WikivoyageApi; }); var WikivoyageApi = { baseUrl: 'https://ru.wikivoyage.org/w/api.php', executeRequest: function executeRequest(parameters, onSuccess, onFailure) { $.ajax({ url: this.baseUrl, data: parameters, crossDomain: true, dataType: 'jsonp' }).done(function (data) { onSuccess(data); }).fail(function () { if (onFailure) { onFailure(); } }); }, getPage: function getPage(page, onSuccess) { this.executeRequest({ 'action': 'query', 'prop': 'revisions', 'rvprop': 'content', 'rvlimit': '1', 'titles': page, 'format': 'json' }, function (data) { if (!data || !data.query || !data.query.pages) { return; } var pages = data.query.pages; var firstPage = pages[Object.keys(pages)[0]]; if (!firstPage || !firstPage.revisions || firstPage.revisions.length <= 0) { return; } onSuccess(firstPage.revisions[0]['*']); }); }, getImageInfo: function getImageInfo(image, onSuccess, onFailure) { var self = this; self.executeRequest({ 'action': 'query', 'titles': image, 'prop': 'imageinfo', 'iiprop': 'url', 'iiurlwidth': '200', 'iiurlheight': '200', 'format': 'json' }, function (data) { if (!data.query || !data.query.pages) { if (onFailure) { onFailure(); } return; } var pages = data.query.pages; var firstPage = pages[Object.keys(pages)[0]]; if (!firstPage || !firstPage.imageinfo || firstPage.imageinfo.length <= 0) { if (onFailure) { onFailure(); } return; } var imageInfo = firstPage.imageinfo[0]; onSuccess({ 'image': image, 'thumb': imageInfo.thumburl, 'url': imageInfo.url }); }, function () { if (onFailure) { onFailure(); } }); } }; /***/ }), /* 21 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CulturalEditorListingSerializer", function() { return CulturalEditorListingSerializer; }); /* harmony import */ var _listing_serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22); var CulturalEditorListingSerializer = { serializeListingData: function serializeListingData(listingData) { var serializer = new _listing_serializer__WEBPACK_IMPORTED_MODULE_0__["ListingSerializer"]('monument', listingData); serializer.writeListingStart(); serializer.writeParametersLine(['type', 'status']); serializer.writeParametersLine(['lat', 'long', 'precise']); serializer.writeParameterLine('name'); serializer.writeParametersLine(['knid', 'complex'], ['complex']); serializer.writeParameterLine('knid-new'); serializer.writeParametersLine(['region', 'district']); serializer.writeParametersLine(['municipality', 'munid']); serializer.writeParameterLine('block', true); serializer.writeParameterLine('address'); serializer.writeParametersLine(['year', 'author']); serializer.writeParameterLine('style', true); serializer.writeParameterLine('description'); serializer.writeParameterLine('image'); serializer.writeParameterLine('wdid'); serializer.writeParameterLine('wiki'); serializer.writeParametersLine(['commonscat', 'protection'], ['protection']); serializer.writeParameterLine('link'); serializer.writeParameterLine('linkextra', true); serializer.writeParameterLine('document', true); serializer.writeParameterLine('doc', true); serializer.writeParameterLine('style', true); serializer.writeParameterLine('protection', true); serializer.writeParameterLine('dismissed', true); serializer.writeOtherNonEmptyParameters(); serializer.writeListingEnd(); return serializer.getSerializedListing(); } }; /***/ }), /* 22 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ListingSerializer", function() { return ListingSerializer; }); /* harmony import */ var _array_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18); /* harmony import */ var _string_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ListingSerializer = /*#__PURE__*/ function () { function ListingSerializer(listingType, listingData) { _classCallCheck(this, ListingSerializer); this._listingType = listingType; this._listingData = listingData; this._serializedListing = ''; this._serializedParameters = []; } _createClass(ListingSerializer, [{ key: "writeListingStart", value: function writeListingStart(addNewline) { this._serializedListing += '{{' + this._listingType; if (addNewline) { this._serializedListing += '\n'; } else { this._serializedListing += ' '; } } }, { key: "writeParameterLine", value: function writeParameterLine(parameterName, isOptional) { var parameterValue = this._getParameterValue(parameterName); if (isOptional && parameterValue === '') { return; } this._serializedListing += ListingSerializer._parameterString(parameterName, parameterValue, true); this._serializedParameters.push(parameterName); } }, { key: "writeParametersLine", value: function writeParametersLine(parameterNames, optionalParameters) { var _this = this; var isFirst = true; parameterNames.forEach(function (parameterName) { var parameterValue = _this._getParameterValue(parameterName); var isOptional = optionalParameters && _array_utils__WEBPACK_IMPORTED_MODULE_0__["ArrayUtils"].inArray(parameterName, optionalParameters); if (isOptional && parameterValue === '') { return; } if (!isFirst) { _this._serializedListing += ' '; } _this._serializedListing += ListingSerializer._parameterString(parameterName, parameterValue, false); _this._serializedParameters.push(parameterName); isFirst = false; }); if (!isFirst) { this._serializedListing += '\n'; } } }, { key: "writeOtherNonEmptyParameters", value: function writeOtherNonEmptyParameters() { var _this2 = this; var allParameterNames = Object.keys(this._listingData); var otherParameterNames = _array_utils__WEBPACK_IMPORTED_MODULE_0__["ArrayUtils"].diff(allParameterNames, this._serializedParameters); otherParameterNames.forEach(function (parameterName) { var parameterValue = _this2._getParameterValue(parameterName); if (parameterValue !== '') { _this2._serializedListing += ListingSerializer._parameterString(parameterName, parameterValue, true); } }); } }, { key: "writeListingEnd", value: function writeListingEnd() { this._serializedListing += '}}'; } }, { key: "getSerializedListing", value: function getSerializedListing() { return this._serializedListing; } }, { key: "_getParameterValue", value: function _getParameterValue(parameterName) { return _string_utils__WEBPACK_IMPORTED_MODULE_1__["StringUtils"].emptyToString(this._listingData[parameterName]); } }], [{ key: "_parameterString", value: function _parameterString(parameterName, parameterValue, addNewline) { var result = '|' + parameterName + '= ' + parameterValue; if (addNewline) { result += '\n'; } return result; } }]); return ListingSerializer; }(); /***/ }), /* 23 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MediaWikiPageWikitext", function() { return MediaWikiPageWikitext; }); /* harmony import */ var _messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24); var api = new mw.Api(); var MediaWikiPageWikitext = { loadSectionWikitext: function loadSectionWikitext(sectionIndex, onSuccess) { $.ajax({ url: mw.util.wikiScript(''), data: { title: mw.config.get('wgPageName'), action: 'raw', section: sectionIndex }, cache: false }).done(function (data) { onSuccess(data); }).fail(function (jqXHR, textStatus, errorThrown) { alert('Ошибка при получении исходного вики-текста статьи: ' + textStatus + ' ' + errorThrown); }); }, saveSectionWikitext: function saveSectionWikitext(sectionIndex, sectionWikitext, changesSummary, changesIsMinor, captchaId, captchaAnswer, onSuccess, onFailure, onCaptcha, pageName) { if (!pageName) { pageName = mw.config.get("wgPageName"); } var editPayload = { action: "edit", title: pageName, text: sectionWikitext, summary: changesSummary, captchaid: captchaId, captchaword: captchaAnswer }; if (sectionIndex !== null) { $.extend(editPayload, { section: sectionIndex }); } if (changesIsMinor) { $.extend(editPayload, { minor: 'true' }); } api.postWithToken("csrf", editPayload).done(function (data) { if (data && data.edit && data.edit.result === 'Success') { onSuccess(); } else if (data && data.error) { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitApiError + ' "' + data.error.code + '": ' + data.error.info); } else if (data && data.edit.spamblacklist) { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitBlacklistError + ': ' + data.edit.spamblacklist); } else if (data && data.edit.captcha) { onCaptcha(data.edit.captcha.url, data.edit.captcha.id); } else { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitUnknownError); } }).fail(function (code, result) { if (code === "http") { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitHttpError + ': ' + result.textStatus); } else if (code === "ok-but-empty") { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitEmptyError); } else { onFailure(_messages__WEBPACK_IMPORTED_MODULE_0__["commonMessages"].submitUnknownError + ': ' + code); } }); }, getSectionName: function getSectionName(sectionWikitext) { var HEADING_REGEX = /^=+\s*([^=]+)\s*=+\s*\n/; var result = HEADING_REGEX.exec(sectionWikitext); return result !== null ? result[1].trim() : ""; } }; /***/ }), /* 24 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commonMessages", function() { return commonMessages; }); var commonMessages = { addTitle: 'Добавить объект', editTitle: 'Редактировать объект', submitApiError: 'Во время сохранения листинга на сервере произошла ошибка, пожайлуста, попробуйте сохранить ещё раз', submitBlacklistError: 'Ошибка: текст содержит ссылку из чёрного списка, пожайлуста, удалите её и попробуйте сохранить снова', submitUnknownError: 'Ошибка: при попытке сохранить листинг произошла неизвестная ошибка, пожайлуста, попробуйте сохранить ещё раз', submitHttpError: 'Ошибка: сервер сообщил о HTTP ошибке, возникшей во время сохранения листинга, пожайлуста, попробуйте сохранить ещё раз', submitEmptyError: 'Ошибка: сервер вернул пустой ответ при попытке сохранить листинг, пожайлуста, попробуйте сохранить ещё раз', enterCaptcha: 'Введите CAPTCHA', changesSummaryAdded: 'Добавлен объект', changesSummaryUpdated: 'Обновлён объект', captchaSubmit: 'Продолжить', captchaCancel: 'Отмена' }; /***/ }), /* 25 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "downloadContent", function() { return downloadContent; }); // https://stackoverflow.com/questions/3665115/create-a-file-in-memory-for-user-to-download-not-through-server var downloadContent = function downloadContent(filename, text) { var element = document.createElement('a'); element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); element.setAttribute('download', filename); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); }; /***/ }), /* 26 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExportPanel", function() { return ExportPanel; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ExportPanel = /*#__PURE__*/ function () { function ExportPanel(onExportJson, onExportGpx) { _classCallCheck(this, ExportPanel); this._onExportJson = onExportJson; this._onExportGpx = onExportGpx; } _createClass(ExportPanel, [{ key: "render", value: function render() { var _this = this; var exportPanel = $('<div style="float: right;">'); var exportJsonLink = $("<a>").text('[JSON]'); exportPanel.append(exportJsonLink); exportJsonLink.click(function () { return _this._onExportJson(); }); exportPanel.append(' '); var exportGpxLink = $("<a>").text('[GPX]'); exportPanel.append(exportGpxLink); exportGpxLink.click(function () { return _this._onExportGpx(); }); return exportPanel; } }]); return ExportPanel; }(); /***/ }), /* 27 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommonsApi", function() { return CommonsApi; }); /* harmony import */ var _async_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19); var CommonsApi = { baseUrl: 'https://commons.wikimedia.org/w/api.php', executeRequest: function executeRequest(parameters, onSuccess) { $.ajax({ url: this.baseUrl, data: parameters, crossDomain: true, dataType: 'jsonp' }).done(function (data) { onSuccess(data); }); }, getCategoryFiles: function getCategoryFiles(category, limit, onSuccess) { var self = this; self.executeRequest({ 'action': 'query', 'list': 'categorymembers', 'cmtype': 'file', 'cmtitle': 'Category:' + category, 'cmlimit': 'max', 'format': 'json' }, function (data) { if (data.query && data.query.categorymembers) { var files = []; data.query.categorymembers.forEach(function (member) { if (member.title) { files.push(member.title); } }); onSuccess(files); } }); }, getCategoryImages: function getCategoryImages(category, limit, onSucess) { this.getCategoryFiles(category, limit, function (files) { var images = []; files.forEach(function (file) { var extension = file.toLowerCase().substr(file.length - 4); if (extension === '.jpg' || extension === '.png' || extension === '.gif') { images.push(file); } }); onSucess(images); }); }, getImageInfo: function getImageInfo(image, onSuccess) { var self = this; self.executeRequest({ 'action': 'query', 'titles': image, 'prop': 'imageinfo|revisions', 'iiprop': 'url', 'iiurlwidth': '200', 'iiurlheight': '200', 'rvprop': 'content', 'rvlimit': '1', 'format': 'json' }, function (data) { if (!data.query || !data.query.pages) { return; } var pages = data.query.pages; var firstPage = pages[Object.keys(pages)[0]]; if (!firstPage || !firstPage.imageinfo || firstPage.imageinfo.length <= 0) { return; } var text = ''; if (firstPage.revisions && firstPage.revisions.length > 0) { var revision = firstPage.revisions[0]; if (revision['*']) { text = revision['*']; } } var imageInfo = firstPage.imageinfo[0]; onSuccess({ 'image': image, 'thumb': imageInfo.thumburl, 'text': text, 'url': imageInfo.url }); }); }, getImagesInfo: function getImagesInfo(images, onSuccess) { var self = this; _async_utils__WEBPACK_IMPORTED_MODULE_0__["AsyncUtils"].runSequence(images.map(function (image) { return function (onSuccess) { self.getImageInfo(image, onSuccess); }; }), function (imageInfos) { onSuccess(imageInfos); }); }, /** * * @param categories list of category titles, e.g. ['Novosibirsk', 'Tomsk', 'Culture_of_Novosibirsk'] * @param onSuccess function which accepts single argument - list which has category * titles for each category which has at least one file, e.g. * ['Novosibirsk': 'Culture_of_Novosibirsk'] */ hasCategoriesFiles: function hasCategoriesFiles(categories, onSuccess) { var _this = this; var maxChunkSize = 30; _async_utils__WEBPACK_IMPORTED_MODULE_0__["AsyncUtils"].runChunks(function (categoriesChunk, onSuccess) { _this.executeRequest({ action: 'query', titles: categoriesChunk.join("|"), prop: 'categoryinfo', format: 'json' }, function (data) { var result = []; if (!data || !data.query || !data.query.pages) { return; } Object.keys(data.query.pages).forEach(function (key) { var pageInfo = data.query.pages[key]; if (pageInfo.title && pageInfo.categoryinfo && pageInfo.categoryinfo.files && pageInfo.categoryinfo.files > 0) { result.push(pageInfo.title); } }); onSuccess(result); }); }, maxChunkSize, categories, onSuccess); }, /** * * @param categories list of category titles, e.g. ['Novosibirsk', 'Tomsk', 'Culture_of_Novosibirsk'] * @param onSuccess function which accepts single argument - list where each item has category * title and files count, e.g. [ * {category: 'Novosibirsk', files: 51}, * {category: 'Tomsk', files: 42} * {category: 'Culture_of_Novosibirsk', files: 48} * ] */ countCategoriesFiles: function countCategoriesFiles(categories, onSuccess) { var _this2 = this; var maxChunkSize = 30; _async_utils__WEBPACK_IMPORTED_MODULE_0__["AsyncUtils"].runChunks(function (categoriesChunk, onSuccess) { _this2.executeRequest({ action: 'query', titles: categoriesChunk.join("|"), prop: 'categoryinfo', format: 'json' }, function (data) { var result = []; if (!data || !data.query || !data.query.pages) { return; } Object.keys(data.query.pages).forEach(function (key) { var pageInfo = data.query.pages[key]; if (pageInfo.title) { var filesCount = pageInfo.categoryinfo && pageInfo.categoryinfo.files ? pageInfo.categoryinfo.files : 0; result.push({ category: pageInfo.title, files: filesCount }); } }); onSuccess(result); }); }, maxChunkSize, categories, onSuccess); } }; /***/ }), /* 28 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CommonsImagesLoader", function() { return CommonsImagesLoader; }); /* harmony import */ var _commons_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27); var CommonsImagesLoader = { loadImagesFromWLMCategory: function loadImagesFromWLMCategory(knid, onSuccess) { var _this = this; if (!knid) { onSuccess([]); } else { _commons_api__WEBPACK_IMPORTED_MODULE_0__["CommonsApi"].getCategoryImages('WLM/' + knid, 'max', function (images) { return _this.loadImages(images, onSuccess); }); } }, loadImagesFromWLECategory: function loadImagesFromWLECategory(knid, onSuccess) { var _this2 = this; if (!knid) { onSuccess([]); } else { _commons_api__WEBPACK_IMPORTED_MODULE_0__["CommonsApi"].getCategoryImages('Protected_areas_of_Russia/' + knid, 'max', function (images) { return _this2.loadImages(images, onSuccess); }); } }, loadImagesFromCommonsCategory: function loadImagesFromCommonsCategory(commonsCat, onSuccess) { var _this3 = this; if (!commonsCat) { onSuccess([]); } else { _commons_api__WEBPACK_IMPORTED_MODULE_0__["CommonsApi"].getCategoryImages(commonsCat, 'max', function (images) { return _this3.loadImages(images, onSuccess); }); } }, loadImages: function loadImages(images, onSuccess) { _commons_api__WEBPACK_IMPORTED_MODULE_0__["CommonsApi"].getImagesInfo(images, onSuccess); } }; /***/ }), /* 29 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CulturalGalleryImages", function() { return CulturalGalleryImages; }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var CulturalGalleryImages = /*#__PURE__*/ function () { function CulturalGalleryImages(wlmImages, commonsImages) { _classCallCheck(this, CulturalGalleryImages); this._wlmImages = wlmImages; this._commonsImages = commonsImages; } _createClass(CulturalGalleryImages, [{ key: "getWlmImages", value: function getWlmImages() { return this._wlmImages; } }, { key: "hasWlmImages", value: function hasWlmImages() { return CulturalGalleryImages._hasImages(this.getWlmImages()); } }, { key: "getCommonsImages", value: function getCommonsImages() { return this._commonsImages; } }, { key: "hasCommonsImages", value: function hasCommonsImages() { return CulturalGalleryImages._hasImages(this.getCommonsImages()); } }], [{ key: "_hasImages", value: function _hasImages(images) { return images !== undefined && images !== null && images.length > 0; } }]); return CulturalGalleryImages; }(); /***/ }) /******/ ]);