"use strict";
-import moment from 'moment';
-import 'moment/locale/en-gb';
-import editorOptions from "./pages/page-form";
+const moment = require('moment');
+require('moment/locale/en-gb');
+const editorOptions = require("./pages/page-form");
moment.locale('en-gb');
-export default function (ngApp, events) {
+module.exports = function (ngApp, events) {
ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService',
function ($scope, $attrs, $http, $timeout, imageManagerService) {
$scope.$apply(() => {
$scope.images.unshift(data);
});
- events.emit('success', 'Image uploaded');
+ events.emit('success', trans('components.image_upload_success'));
};
/**
if ($scope.searching) components['term'] = $scope.searchTerm;
- let urlQueryString = Object.keys(components).map((key) => {
+ url += Object.keys(components).map((key) => {
return key + '=' + encodeURIComponent(components[key]);
}).join('&');
- url += urlQueryString;
$http.get(url).then((response) => {
$scope.images = $scope.images.concat(response.data.images);
event.preventDefault();
let url = window.baseUrl('/images/update/' + $scope.selectedImage.id);
$http.put(url, this.selectedImage).then(response => {
- events.emit('success', 'Image details updated');
+ events.emit('success', trans('components.image_update_success'));
}, (response) => {
if (response.status === 422) {
let errors = response.data;
$http.delete(url).then((response) => {
$scope.images.splice($scope.images.indexOf($scope.selectedImage), 1);
$scope.selectedImage = false;
- events.emit('success', 'Image successfully deleted');
+ events.emit('success', trans('components.image_delete_success'));
}, (response) => {
// Pages failure
if (response.status === 400) {
}]);
-
- ngApp.controller('BookShowController', ['$scope', '$http', '$attrs', '$sce', function ($scope, $http, $attrs, $sce) {
- $scope.searching = false;
- $scope.searchTerm = '';
- $scope.searchResults = '';
-
- $scope.searchBook = function (e) {
- e.preventDefault();
- let term = $scope.searchTerm;
- if (term.length == 0) return;
- $scope.searching = true;
- $scope.searchResults = '';
- let searchUrl = window.baseUrl('/search/book/' + $attrs.bookId);
- searchUrl += '?term=' + encodeURIComponent(term);
- $http.get(searchUrl).then((response) => {
- $scope.searchResults = $sce.trustAsHtml(response.data);
- });
- };
-
- $scope.checkSearchForm = function () {
- if ($scope.searchTerm.length < 1) {
- $scope.searching = false;
- }
- };
-
- $scope.clearSearch = function () {
- $scope.searching = false;
- $scope.searchTerm = '';
- };
-
- }]);
-
-
ngApp.controller('PageEditController', ['$scope', '$http', '$attrs', '$interval', '$timeout', '$sce',
function ($scope, $http, $attrs, $interval, $timeout, $sce) {
// Set initial header draft text
if ($scope.isUpdateDraft || $scope.isNewPageDraft) {
- $scope.draftText = 'Editing Draft'
+ $scope.draftText = trans('entities.pages_editing_draft');
} else {
- $scope.draftText = 'Editing Page'
+ $scope.draftText = trans('entities.pages_editing_page');
}
let autoSave = false;
lastSave = Date.now();
}, errorRes => {
if (draftErroring) return;
- events.emit('error', 'Failed to save draft. Ensure you have internet connection before saving this page.')
+ events.emit('error', trans('errors.page_draft_autosave_fail'));
draftErroring = true;
});
}
let url = window.baseUrl('/ajax/page/' + pageId);
$http.get(url).then((responseData) => {
if (autoSave) $interval.cancel(autoSave);
- $scope.draftText = 'Editing Page';
+ $scope.draftText = trans('entities.pages_editing_page');
$scope.isUpdateDraft = false;
$scope.$broadcast('html-update', responseData.data.html);
$scope.$broadcast('markdown-update', responseData.data.markdown || responseData.data.html);
$timeout(() => {
startAutoSave();
}, 1000);
- events.emit('success', 'Draft discarded, The editor has been updated with the current page content');
+ events.emit('success', trans('entities.pages_draft_discarded'));
});
};
* Get files for the current page from the server.
*/
function getFiles() {
- let url = window.baseUrl(`/attachments/get/page/${pageId}`)
+ let url = window.baseUrl(`/attachments/get/page/${pageId}`);
$http.get(url).then(resp => {
$scope.files = resp.data;
currentOrder = resp.data.map(file => {return file.id}).join(':');
$scope.$apply(() => {
$scope.files.push(data);
});
- events.emit('success', 'File uploaded');
+ events.emit('success', trans('entities.attachments_file_uploaded'));
};
/**
data.link = '';
}
});
- events.emit('success', 'File updated');
+ events.emit('success', trans('entities.attachments_file_updated'));
};
/**
file.uploaded_to = pageId;
$http.post(window.baseUrl('/attachments/link'), file).then(resp => {
$scope.files.push(resp.data);
- events.emit('success', 'Link attached');
+ events.emit('success', trans('entities.attachments_link_attached'));
$scope.file = getCleanFile();
}, checkError('link'));
};
$scope.editFile.link = '';
}
$scope.editFile = false;
- events.emit('success', 'Attachment details updated');
+ events.emit('success', trans('entities.attachments_updated_success'));
}, checkError('edit'));
};