Showing
5 changed files
with
209 additions
and
208 deletions
| ... | @@ -2,6 +2,8 @@ | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | ||
| 3 | import moment from 'moment'; | 3 | import moment from 'moment'; |
| 4 | import 'moment/locale/en-gb'; | 4 | import 'moment/locale/en-gb'; |
| 5 | +import editorOptions from "./pages/page-form"; | ||
| 6 | + | ||
| 5 | moment.locale('en-gb'); | 7 | moment.locale('en-gb'); |
| 6 | 8 | ||
| 7 | export default function (ngApp, events) { | 9 | export default function (ngApp, events) { |
| ... | @@ -23,14 +25,14 @@ export default function (ngApp, events) { | ... | @@ -23,14 +25,14 @@ export default function (ngApp, events) { |
| 23 | $scope.searching = false; | 25 | $scope.searching = false; |
| 24 | $scope.searchTerm = ''; | 26 | $scope.searchTerm = ''; |
| 25 | 27 | ||
| 26 | - var page = 0; | 28 | + let page = 0; |
| 27 | - var previousClickTime = 0; | 29 | + let previousClickTime = 0; |
| 28 | - var previousClickImage = 0; | 30 | + let previousClickImage = 0; |
| 29 | - var dataLoaded = false; | 31 | + let dataLoaded = false; |
| 30 | - var callback = false; | 32 | + let callback = false; |
| 31 | 33 | ||
| 32 | - var preSearchImages = []; | 34 | + let preSearchImages = []; |
| 33 | - var preSearchHasMore = false; | 35 | + let preSearchHasMore = false; |
| 34 | 36 | ||
| 35 | /** | 37 | /** |
| 36 | * Used by dropzone to get the endpoint to upload to. | 38 | * Used by dropzone to get the endpoint to upload to. |
| ... | @@ -79,9 +81,9 @@ export default function (ngApp, events) { | ... | @@ -79,9 +81,9 @@ export default function (ngApp, events) { |
| 79 | * @param image | 81 | * @param image |
| 80 | */ | 82 | */ |
| 81 | $scope.imageSelect = function (image) { | 83 | $scope.imageSelect = function (image) { |
| 82 | - var dblClickTime = 300; | 84 | + let dblClickTime = 300; |
| 83 | - var currentTime = Date.now(); | 85 | + let currentTime = Date.now(); |
| 84 | - var timeDiff = currentTime - previousClickTime; | 86 | + let timeDiff = currentTime - previousClickTime; |
| 85 | 87 | ||
| 86 | if (timeDiff < dblClickTime && image.id === previousClickImage) { | 88 | if (timeDiff < dblClickTime && image.id === previousClickImage) { |
| 87 | // If double click | 89 | // If double click |
| ... | @@ -137,19 +139,19 @@ export default function (ngApp, events) { | ... | @@ -137,19 +139,19 @@ export default function (ngApp, events) { |
| 137 | $('#image-manager').find('.overlay').fadeOut(240); | 139 | $('#image-manager').find('.overlay').fadeOut(240); |
| 138 | }; | 140 | }; |
| 139 | 141 | ||
| 140 | - var baseUrl = window.baseUrl('/images/' + $scope.imageType + '/all/'); | 142 | + let baseUrl = window.baseUrl('/images/' + $scope.imageType + '/all/'); |
| 141 | 143 | ||
| 142 | /** | 144 | /** |
| 143 | * Fetch the list image data from the server. | 145 | * Fetch the list image data from the server. |
| 144 | */ | 146 | */ |
| 145 | function fetchData() { | 147 | function fetchData() { |
| 146 | - var url = baseUrl + page + '?'; | 148 | + let url = baseUrl + page + '?'; |
| 147 | - var components = {}; | 149 | + let components = {}; |
| 148 | if ($scope.uploadedTo) components['page_id'] = $scope.uploadedTo; | 150 | if ($scope.uploadedTo) components['page_id'] = $scope.uploadedTo; |
| 149 | if ($scope.searching) components['term'] = $scope.searchTerm; | 151 | if ($scope.searching) components['term'] = $scope.searchTerm; |
| 150 | 152 | ||
| 151 | 153 | ||
| 152 | - var urlQueryString = Object.keys(components).map((key) => { | 154 | + let urlQueryString = Object.keys(components).map((key) => { |
| 153 | return key + '=' + encodeURIComponent(components[key]); | 155 | return key + '=' + encodeURIComponent(components[key]); |
| 154 | }).join('&'); | 156 | }).join('&'); |
| 155 | url += urlQueryString; | 157 | url += urlQueryString; |
| ... | @@ -205,13 +207,13 @@ export default function (ngApp, events) { | ... | @@ -205,13 +207,13 @@ export default function (ngApp, events) { |
| 205 | */ | 207 | */ |
| 206 | $scope.saveImageDetails = function (event) { | 208 | $scope.saveImageDetails = function (event) { |
| 207 | event.preventDefault(); | 209 | event.preventDefault(); |
| 208 | - var url = window.baseUrl('/images/update/' + $scope.selectedImage.id); | 210 | + let url = window.baseUrl('/images/update/' + $scope.selectedImage.id); |
| 209 | $http.put(url, this.selectedImage).then(response => { | 211 | $http.put(url, this.selectedImage).then(response => { |
| 210 | events.emit('success', 'Image details updated'); | 212 | events.emit('success', 'Image details updated'); |
| 211 | }, (response) => { | 213 | }, (response) => { |
| 212 | if (response.status === 422) { | 214 | if (response.status === 422) { |
| 213 | - var errors = response.data; | 215 | + let errors = response.data; |
| 214 | - var message = ''; | 216 | + let message = ''; |
| 215 | Object.keys(errors).forEach((key) => { | 217 | Object.keys(errors).forEach((key) => { |
| 216 | message += errors[key].join('\n'); | 218 | message += errors[key].join('\n'); |
| 217 | }); | 219 | }); |
| ... | @@ -230,8 +232,8 @@ export default function (ngApp, events) { | ... | @@ -230,8 +232,8 @@ export default function (ngApp, events) { |
| 230 | */ | 232 | */ |
| 231 | $scope.deleteImage = function (event) { | 233 | $scope.deleteImage = function (event) { |
| 232 | event.preventDefault(); | 234 | event.preventDefault(); |
| 233 | - var force = $scope.dependantPages !== false; | 235 | + let force = $scope.dependantPages !== false; |
| 234 | - var url = window.baseUrl('/images/' + $scope.selectedImage.id); | 236 | + let url = window.baseUrl('/images/' + $scope.selectedImage.id); |
| 235 | if (force) url += '?force=true'; | 237 | if (force) url += '?force=true'; |
| 236 | $http.delete(url).then((response) => { | 238 | $http.delete(url).then((response) => { |
| 237 | $scope.images.splice($scope.images.indexOf($scope.selectedImage), 1); | 239 | $scope.images.splice($scope.images.indexOf($scope.selectedImage), 1); |
| ... | @@ -266,11 +268,11 @@ export default function (ngApp, events) { | ... | @@ -266,11 +268,11 @@ export default function (ngApp, events) { |
| 266 | 268 | ||
| 267 | $scope.searchBook = function (e) { | 269 | $scope.searchBook = function (e) { |
| 268 | e.preventDefault(); | 270 | e.preventDefault(); |
| 269 | - var term = $scope.searchTerm; | 271 | + let term = $scope.searchTerm; |
| 270 | if (term.length == 0) return; | 272 | if (term.length == 0) return; |
| 271 | $scope.searching = true; | 273 | $scope.searching = true; |
| 272 | $scope.searchResults = ''; | 274 | $scope.searchResults = ''; |
| 273 | - var searchUrl = window.baseUrl('/search/book/' + $attrs.bookId); | 275 | + let searchUrl = window.baseUrl('/search/book/' + $attrs.bookId); |
| 274 | searchUrl += '?term=' + encodeURIComponent(term); | 276 | searchUrl += '?term=' + encodeURIComponent(term); |
| 275 | $http.get(searchUrl).then((response) => { | 277 | $http.get(searchUrl).then((response) => { |
| 276 | $scope.searchResults = $sce.trustAsHtml(response.data); | 278 | $scope.searchResults = $sce.trustAsHtml(response.data); |
| ... | @@ -294,13 +296,13 @@ export default function (ngApp, events) { | ... | @@ -294,13 +296,13 @@ export default function (ngApp, events) { |
| 294 | ngApp.controller('PageEditController', ['$scope', '$http', '$attrs', '$interval', '$timeout', '$sce', | 296 | ngApp.controller('PageEditController', ['$scope', '$http', '$attrs', '$interval', '$timeout', '$sce', |
| 295 | function ($scope, $http, $attrs, $interval, $timeout, $sce) { | 297 | function ($scope, $http, $attrs, $interval, $timeout, $sce) { |
| 296 | 298 | ||
| 297 | - $scope.editorOptions = require('./pages/page-form'); | 299 | + $scope.editorOptions = editorOptions(); |
| 298 | $scope.editContent = ''; | 300 | $scope.editContent = ''; |
| 299 | $scope.draftText = ''; | 301 | $scope.draftText = ''; |
| 300 | - var pageId = Number($attrs.pageId); | 302 | + let pageId = Number($attrs.pageId); |
| 301 | - var isEdit = pageId !== 0; | 303 | + let isEdit = pageId !== 0; |
| 302 | - var autosaveFrequency = 30; // AutoSave interval in seconds. | 304 | + let autosaveFrequency = 30; // AutoSave interval in seconds. |
| 303 | - var isMarkdown = $attrs.editorType === 'markdown'; | 305 | + let isMarkdown = $attrs.editorType === 'markdown'; |
| 304 | $scope.draftsEnabled = $attrs.draftsEnabled === 'true'; | 306 | $scope.draftsEnabled = $attrs.draftsEnabled === 'true'; |
| 305 | $scope.isUpdateDraft = Number($attrs.pageUpdateDraft) === 1; | 307 | $scope.isUpdateDraft = Number($attrs.pageUpdateDraft) === 1; |
| 306 | $scope.isNewPageDraft = Number($attrs.pageNewDraft) === 1; | 308 | $scope.isNewPageDraft = Number($attrs.pageNewDraft) === 1; |
| ... | @@ -312,9 +314,9 @@ export default function (ngApp, events) { | ... | @@ -312,9 +314,9 @@ export default function (ngApp, events) { |
| 312 | $scope.draftText = 'Editing Page' | 314 | $scope.draftText = 'Editing Page' |
| 313 | } | 315 | } |
| 314 | 316 | ||
| 315 | - var autoSave = false; | 317 | + let autoSave = false; |
| 316 | 318 | ||
| 317 | - var currentContent = { | 319 | + let currentContent = { |
| 318 | title: false, | 320 | title: false, |
| 319 | html: false | 321 | html: false |
| 320 | }; | 322 | }; |
| ... | @@ -351,8 +353,8 @@ export default function (ngApp, events) { | ... | @@ -351,8 +353,8 @@ export default function (ngApp, events) { |
| 351 | autoSave = $interval(() => { | 353 | autoSave = $interval(() => { |
| 352 | // Return if manually saved recently to prevent bombarding the server | 354 | // Return if manually saved recently to prevent bombarding the server |
| 353 | if (Date.now() - lastSave < (1000*autosaveFrequency)/2) return; | 355 | if (Date.now() - lastSave < (1000*autosaveFrequency)/2) return; |
| 354 | - var newTitle = $('#name').val(); | 356 | + let newTitle = $('#name').val(); |
| 355 | - var newHtml = $scope.editContent; | 357 | + let newHtml = $scope.editContent; |
| 356 | 358 | ||
| 357 | if (newTitle !== currentContent.title || newHtml !== currentContent.html) { | 359 | if (newTitle !== currentContent.title || newHtml !== currentContent.html) { |
| 358 | currentContent.html = newHtml; | 360 | currentContent.html = newHtml; |
| ... | @@ -369,7 +371,7 @@ export default function (ngApp, events) { | ... | @@ -369,7 +371,7 @@ export default function (ngApp, events) { |
| 369 | */ | 371 | */ |
| 370 | function saveDraft() { | 372 | function saveDraft() { |
| 371 | if (!$scope.draftsEnabled) return; | 373 | if (!$scope.draftsEnabled) return; |
| 372 | - var data = { | 374 | + let data = { |
| 373 | name: $('#name').val(), | 375 | name: $('#name').val(), |
| 374 | html: isMarkdown ? $sce.getTrustedHtml($scope.displayContent) : $scope.editContent | 376 | html: isMarkdown ? $sce.getTrustedHtml($scope.displayContent) : $scope.editContent |
| 375 | }; | 377 | }; |
| ... | @@ -379,7 +381,7 @@ export default function (ngApp, events) { | ... | @@ -379,7 +381,7 @@ export default function (ngApp, events) { |
| 379 | let url = window.baseUrl('/ajax/page/' + pageId + '/save-draft'); | 381 | let url = window.baseUrl('/ajax/page/' + pageId + '/save-draft'); |
| 380 | $http.put(url, data).then(responseData => { | 382 | $http.put(url, data).then(responseData => { |
| 381 | draftErroring = false; | 383 | draftErroring = false; |
| 382 | - var updateTime = moment.utc(moment.unix(responseData.data.timestamp)).toDate(); | 384 | + let updateTime = moment.utc(moment.unix(responseData.data.timestamp)).toDate(); |
| 383 | $scope.draftText = responseData.data.message + moment(updateTime).format('HH:mm'); | 385 | $scope.draftText = responseData.data.message + moment(updateTime).format('HH:mm'); |
| 384 | if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true; | 386 | if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true; |
| 385 | showDraftSaveNotification(); | 387 | showDraftSaveNotification(); | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | -const DropZone = require('dropzone'); | 2 | +import DropZone from "dropzone"; |
| 3 | -const markdown = require('marked'); | 3 | +import markdown from "marked"; |
| 4 | 4 | ||
| 5 | -module.exports = function (ngApp, events) { | 5 | +export default function (ngApp, events) { |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | * Toggle Switches | 8 | * Toggle Switches |
| ... | @@ -190,14 +190,14 @@ module.exports = function (ngApp, events) { | ... | @@ -190,14 +190,14 @@ module.exports = function (ngApp, events) { |
| 190 | }, | 190 | }, |
| 191 | link: function (scope, element, attrs) { | 191 | link: function (scope, element, attrs) { |
| 192 | if (attrs.placeholder) element[0].querySelector('.dz-message').textContent = attrs.placeholder; | 192 | if (attrs.placeholder) element[0].querySelector('.dz-message').textContent = attrs.placeholder; |
| 193 | - var dropZone = new DropZone(element[0].querySelector('.dropzone-container'), { | 193 | + let dropZone = new DropZone(element[0].querySelector('.dropzone-container'), { |
| 194 | url: scope.uploadUrl, | 194 | url: scope.uploadUrl, |
| 195 | init: function () { | 195 | init: function () { |
| 196 | - var dz = this; | 196 | + let dz = this; |
| 197 | dz.on('sending', function (file, xhr, data) { | 197 | dz.on('sending', function (file, xhr, data) { |
| 198 | - var token = window.document.querySelector('meta[name=token]').getAttribute('content'); | 198 | + let token = window.document.querySelector('meta[name=token]').getAttribute('content'); |
| 199 | data.append('_token', token); | 199 | data.append('_token', token); |
| 200 | - var uploadedTo = typeof scope.uploadedTo === 'undefined' ? 0 : scope.uploadedTo; | 200 | + let uploadedTo = typeof scope.uploadedTo === 'undefined' ? 0 : scope.uploadedTo; |
| 201 | data.append('uploaded_to', uploadedTo); | 201 | data.append('uploaded_to', uploadedTo); |
| 202 | }); | 202 | }); |
| 203 | if (typeof scope.eventSuccess !== 'undefined') dz.on('success', scope.eventSuccess); | 203 | if (typeof scope.eventSuccess !== 'undefined') dz.on('success', scope.eventSuccess); |
| ... | @@ -273,7 +273,7 @@ module.exports = function (ngApp, events) { | ... | @@ -273,7 +273,7 @@ module.exports = function (ngApp, events) { |
| 273 | 273 | ||
| 274 | function tinyMceSetup(editor) { | 274 | function tinyMceSetup(editor) { |
| 275 | editor.on('ExecCommand change NodeChange ObjectResized', (e) => { | 275 | editor.on('ExecCommand change NodeChange ObjectResized', (e) => { |
| 276 | - var content = editor.getContent(); | 276 | + let content = editor.getContent(); |
| 277 | $timeout(() => { | 277 | $timeout(() => { |
| 278 | scope.mceModel = content; | 278 | scope.mceModel = content; |
| 279 | }); | 279 | }); |
| ... | @@ -301,9 +301,9 @@ module.exports = function (ngApp, events) { | ... | @@ -301,9 +301,9 @@ module.exports = function (ngApp, events) { |
| 301 | // Custom tinyMCE plugins | 301 | // Custom tinyMCE plugins |
| 302 | tinymce.PluginManager.add('customhr', function (editor) { | 302 | tinymce.PluginManager.add('customhr', function (editor) { |
| 303 | editor.addCommand('InsertHorizontalRule', function () { | 303 | editor.addCommand('InsertHorizontalRule', function () { |
| 304 | - var hrElem = document.createElement('hr'); | 304 | + let hrElem = document.createElement('hr'); |
| 305 | - var cNode = editor.selection.getNode(); | 305 | + let cNode = editor.selection.getNode(); |
| 306 | - var parentNode = cNode.parentNode; | 306 | + let parentNode = cNode.parentNode; |
| 307 | parentNode.insertBefore(hrElem, cNode); | 307 | parentNode.insertBefore(hrElem, cNode); |
| 308 | }); | 308 | }); |
| 309 | 309 | ||
| ... | @@ -474,9 +474,9 @@ module.exports = function (ngApp, events) { | ... | @@ -474,9 +474,9 @@ module.exports = function (ngApp, events) { |
| 474 | function editorPaste(e) { | 474 | function editorPaste(e) { |
| 475 | e = e.originalEvent; | 475 | e = e.originalEvent; |
| 476 | if (!e.clipboardData) return | 476 | if (!e.clipboardData) return |
| 477 | - var items = e.clipboardData.items; | 477 | + let items = e.clipboardData.items; |
| 478 | if (!items) return; | 478 | if (!items) return; |
| 479 | - for (var i = 0; i < items.length; i++) { | 479 | + for (let i = 0; i < items.length; i++) { |
| 480 | uploadImage(items[i].getAsFile()); | 480 | uploadImage(items[i].getAsFile()); |
| 481 | } | 481 | } |
| 482 | } | 482 | } |
| ... | @@ -498,12 +498,12 @@ module.exports = function (ngApp, events) { | ... | @@ -498,12 +498,12 @@ module.exports = function (ngApp, events) { |
| 498 | // Handle image upload and add image into markdown content | 498 | // Handle image upload and add image into markdown content |
| 499 | function uploadImage(file) { | 499 | function uploadImage(file) { |
| 500 | if (file.type.indexOf('image') !== 0) return; | 500 | if (file.type.indexOf('image') !== 0) return; |
| 501 | - var formData = new FormData(); | 501 | + let formData = new FormData(); |
| 502 | - var ext = 'png'; | 502 | + let ext = 'png'; |
| 503 | - var xhr = new XMLHttpRequest(); | 503 | + let xhr = new XMLHttpRequest(); |
| 504 | 504 | ||
| 505 | if (file.name) { | 505 | if (file.name) { |
| 506 | - var fileNameMatches = file.name.match(/\.(.+)$/); | 506 | + let fileNameMatches = file.name.match(/\.(.+)$/); |
| 507 | if (fileNameMatches) { | 507 | if (fileNameMatches) { |
| 508 | ext = fileNameMatches[1]; | 508 | ext = fileNameMatches[1]; |
| 509 | } | 509 | } |
| ... | @@ -531,7 +531,7 @@ module.exports = function (ngApp, events) { | ... | @@ -531,7 +531,7 @@ module.exports = function (ngApp, events) { |
| 531 | xhr.onload = function () { | 531 | xhr.onload = function () { |
| 532 | let selectStart = input[0].selectionStart; | 532 | let selectStart = input[0].selectionStart; |
| 533 | if (xhr.status === 200 || xhr.status === 201) { | 533 | if (xhr.status === 200 || xhr.status === 201) { |
| 534 | - var result = JSON.parse(xhr.responseText); | 534 | + let result = JSON.parse(xhr.responseText); |
| 535 | input[0].value = input[0].value.replace(placeholderImage, result.thumbs.display); | 535 | input[0].value = input[0].value.replace(placeholderImage, result.thumbs.display); |
| 536 | input.change(); | 536 | input.change(); |
| 537 | } else { | 537 | } else { |
| ... | @@ -732,14 +732,13 @@ module.exports = function (ngApp, events) { | ... | @@ -732,14 +732,13 @@ module.exports = function (ngApp, events) { |
| 732 | // Build suggestions | 732 | // Build suggestions |
| 733 | $suggestionBox[0].innerHTML = ''; | 733 | $suggestionBox[0].innerHTML = ''; |
| 734 | for (let i = 0; i < suggestions.length; i++) { | 734 | for (let i = 0; i < suggestions.length; i++) { |
| 735 | - var suggestion = document.createElement('li'); | 735 | + let suggestion = document.createElement('li'); |
| 736 | suggestion.textContent = suggestions[i]; | 736 | suggestion.textContent = suggestions[i]; |
| 737 | suggestion.onclick = suggestionClick; | 737 | suggestion.onclick = suggestionClick; |
| 738 | if (i === 0) { | 738 | if (i === 0) { |
| 739 | - suggestion.className = 'active' | 739 | + suggestion.className = 'active'; |
| 740 | active = 0; | 740 | active = 0; |
| 741 | } | 741 | } |
| 742 | - ; | ||
| 743 | $suggestionBox[0].appendChild(suggestion); | 742 | $suggestionBox[0].appendChild(suggestion); |
| 744 | } | 743 | } |
| 745 | 744 | ||
| ... | @@ -748,12 +747,11 @@ module.exports = function (ngApp, events) { | ... | @@ -748,12 +747,11 @@ module.exports = function (ngApp, events) { |
| 748 | 747 | ||
| 749 | // Suggestion click event | 748 | // Suggestion click event |
| 750 | function suggestionClick(event) { | 749 | function suggestionClick(event) { |
| 751 | - let text = this.textContent; | 750 | + currentInput[0].value = this.textContent; |
| 752 | - currentInput[0].value = text; | ||
| 753 | currentInput.focus(); | 751 | currentInput.focus(); |
| 754 | $suggestionBox.hide(); | 752 | $suggestionBox.hide(); |
| 755 | isShowing = false; | 753 | isShowing = false; |
| 756 | - }; | 754 | + } |
| 757 | 755 | ||
| 758 | // Get suggestions & cache | 756 | // Get suggestions & cache |
| 759 | function getSuggestions(input, url) { | 757 | function getSuggestions(input, url) { |
| ... | @@ -843,7 +841,7 @@ module.exports = function (ngApp, events) { | ... | @@ -843,7 +841,7 @@ module.exports = function (ngApp, events) { |
| 843 | const input = element.find('[entity-selector-input]').first(); | 841 | const input = element.find('[entity-selector-input]').first(); |
| 844 | 842 | ||
| 845 | // Detect double click events | 843 | // Detect double click events |
| 846 | - var lastClick = 0; | 844 | + let lastClick = 0; |
| 847 | function isDoubleClick() { | 845 | function isDoubleClick() { |
| 848 | let now = Date.now(); | 846 | let now = Date.now(); |
| 849 | let answer = now - lastClick < 300; | 847 | let answer = now - lastClick < 300; | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | 2 | ||
| 3 | // AngularJS - Create application and load components | 3 | // AngularJS - Create application and load components |
| 4 | -var angular = require('angular'); | 4 | +import angular from "angular"; |
| 5 | -var ngResource = require('angular-resource'); | 5 | +import "angular-resource"; |
| 6 | -var ngAnimate = require('angular-animate'); | 6 | +import "angular-animate"; |
| 7 | -var ngSanitize = require('angular-sanitize'); | 7 | +import "angular-sanitize"; |
| 8 | -require('angular-ui-sortable'); | 8 | +import "angular-ui-sortable"; |
| 9 | 9 | ||
| 10 | // Url retrieval function | 10 | // Url retrieval function |
| 11 | window.baseUrl = function(path) { | 11 | window.baseUrl = function(path) { |
| ... | @@ -15,7 +15,7 @@ window.baseUrl = function(path) { | ... | @@ -15,7 +15,7 @@ window.baseUrl = function(path) { |
| 15 | return basePath + '/' + path; | 15 | return basePath + '/' + path; |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | -var ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.sortable']); | 18 | +let ngApp = angular.module('bookStack', ['ngResource', 'ngAnimate', 'ngSanitize', 'ui.sortable']); |
| 19 | 19 | ||
| 20 | // Global Event System | 20 | // Global Event System |
| 21 | class EventManager { | 21 | class EventManager { |
| ... | @@ -25,9 +25,9 @@ class EventManager { | ... | @@ -25,9 +25,9 @@ class EventManager { |
| 25 | 25 | ||
| 26 | emit(eventName, eventData) { | 26 | emit(eventName, eventData) { |
| 27 | if (typeof this.listeners[eventName] === 'undefined') return this; | 27 | if (typeof this.listeners[eventName] === 'undefined') return this; |
| 28 | - var eventsToStart = this.listeners[eventName]; | 28 | + let eventsToStart = this.listeners[eventName]; |
| 29 | for (let i = 0; i < eventsToStart.length; i++) { | 29 | for (let i = 0; i < eventsToStart.length; i++) { |
| 30 | - var event = eventsToStart[i]; | 30 | + let event = eventsToStart[i]; |
| 31 | event(eventData); | 31 | event(eventData); |
| 32 | } | 32 | } |
| 33 | return this; | 33 | return this; |
| ... | @@ -72,10 +72,10 @@ jQuery.expr[":"].contains = $.expr.createPseudo(function (arg) { | ... | @@ -72,10 +72,10 @@ jQuery.expr[":"].contains = $.expr.createPseudo(function (arg) { |
| 72 | // Global jQuery Elements | 72 | // Global jQuery Elements |
| 73 | $(function () { | 73 | $(function () { |
| 74 | 74 | ||
| 75 | - var notifications = $('.notification'); | 75 | + let notifications = $('.notification'); |
| 76 | - var successNotification = notifications.filter('.pos'); | 76 | + let successNotification = notifications.filter('.pos'); |
| 77 | - var errorNotification = notifications.filter('.neg'); | 77 | + let errorNotification = notifications.filter('.neg'); |
| 78 | - var warningNotification = notifications.filter('.warning'); | 78 | + let warningNotification = notifications.filter('.warning'); |
| 79 | // Notification Events | 79 | // Notification Events |
| 80 | window.Events.listen('success', function (text) { | 80 | window.Events.listen('success', function (text) { |
| 81 | successNotification.hide(); | 81 | successNotification.hide(); |
| ... | @@ -109,9 +109,9 @@ $(function () { | ... | @@ -109,9 +109,9 @@ $(function () { |
| 109 | $('#back-to-top').click(function() { | 109 | $('#back-to-top').click(function() { |
| 110 | $('#header').smoothScrollTo(); | 110 | $('#header').smoothScrollTo(); |
| 111 | }); | 111 | }); |
| 112 | - var scrollTopShowing = false; | 112 | + let scrollTopShowing = false; |
| 113 | - var scrollTop = document.getElementById('back-to-top'); | 113 | + let scrollTop = document.getElementById('back-to-top'); |
| 114 | - var scrollTopBreakpoint = 1200; | 114 | + let scrollTopBreakpoint = 1200; |
| 115 | window.addEventListener('scroll', function() { | 115 | window.addEventListener('scroll', function() { |
| 116 | let scrollTopPos = document.documentElement.scrollTop || document.body.scrollTop || 0; | 116 | let scrollTopPos = document.documentElement.scrollTop || document.body.scrollTop || 0; |
| 117 | if (!scrollTopShowing && scrollTopPos > scrollTopBreakpoint) { | 117 | if (!scrollTopShowing && scrollTopPos > scrollTopBreakpoint) { |
| ... | @@ -159,4 +159,4 @@ $(function () { | ... | @@ -159,4 +159,4 @@ $(function () { |
| 159 | }); | 159 | }); |
| 160 | 160 | ||
| 161 | // Page specific items | 161 | // Page specific items |
| 162 | -require('./pages/page-show'); | 162 | +import "./pages/page-show"; | ... | ... |
| ... | @@ -60,108 +60,108 @@ function registerEditorShortcuts(editor) { | ... | @@ -60,108 +60,108 @@ function registerEditorShortcuts(editor) { |
| 60 | editor.addShortcut('meta+shift+E', '', ['FormatBlock', false, 'code']); | 60 | editor.addShortcut('meta+shift+E', '', ['FormatBlock', false, 'code']); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | -var mceOptions = module.exports = { | 63 | +export default function() { |
| 64 | - selector: '#html-editor', | 64 | + let settings = { |
| 65 | - content_css: [ | 65 | + selector: '#html-editor', |
| 66 | - window.baseUrl('/css/styles.css'), | 66 | + content_css: [ |
| 67 | - window.baseUrl('/libs/material-design-iconic-font/css/material-design-iconic-font.min.css') | 67 | + window.baseUrl('/css/styles.css'), |
| 68 | - ], | 68 | + window.baseUrl('/libs/material-design-iconic-font/css/material-design-iconic-font.min.css') |
| 69 | - body_class: 'page-content', | 69 | + ], |
| 70 | - relative_urls: false, | 70 | + body_class: 'page-content', |
| 71 | - remove_script_host: false, | 71 | + relative_urls: false, |
| 72 | - document_base_url: window.baseUrl('/'), | 72 | + remove_script_host: false, |
| 73 | - statusbar: false, | 73 | + document_base_url: window.baseUrl('/'), |
| 74 | - menubar: false, | 74 | + statusbar: false, |
| 75 | - paste_data_images: false, | 75 | + menubar: false, |
| 76 | - extended_valid_elements: 'pre[*]', | 76 | + paste_data_images: false, |
| 77 | - automatic_uploads: false, | 77 | + extended_valid_elements: 'pre[*]', |
| 78 | - valid_children: "-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]", | 78 | + automatic_uploads: false, |
| 79 | - plugins: "image table textcolor paste link fullscreen imagetools code customhr autosave lists", | 79 | + valid_children: "-div[p|pre|h1|h2|h3|h4|h5|h6|blockquote]", |
| 80 | - imagetools_toolbar: 'imageoptions', | 80 | + plugins: "image table textcolor paste link fullscreen imagetools code customhr autosave lists", |
| 81 | - toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen", | 81 | + imagetools_toolbar: 'imageoptions', |
| 82 | - content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", | 82 | + toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr | removeformat code fullscreen", |
| 83 | - style_formats: [ | 83 | + content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", |
| 84 | - {title: "Header Large", format: "h2"}, | 84 | + style_formats: [ |
| 85 | - {title: "Header Medium", format: "h3"}, | 85 | + {title: "Header Large", format: "h2"}, |
| 86 | - {title: "Header Small", format: "h4"}, | 86 | + {title: "Header Medium", format: "h3"}, |
| 87 | - {title: "Header Tiny", format: "h5"}, | 87 | + {title: "Header Small", format: "h4"}, |
| 88 | - {title: "Paragraph", format: "p", exact: true, classes: ''}, | 88 | + {title: "Header Tiny", format: "h5"}, |
| 89 | - {title: "Blockquote", format: "blockquote"}, | 89 | + {title: "Paragraph", format: "p", exact: true, classes: ''}, |
| 90 | - {title: "Code Block", icon: "code", format: "pre"}, | 90 | + {title: "Blockquote", format: "blockquote"}, |
| 91 | - {title: "Inline Code", icon: "code", inline: "code"}, | 91 | + {title: "Code Block", icon: "code", format: "pre"}, |
| 92 | - {title: "Callouts", items: [ | 92 | + {title: "Inline Code", icon: "code", inline: "code"}, |
| 93 | - {title: "Success", block: 'p', exact: true, attributes : {'class' : 'callout success'}}, | 93 | + {title: "Callouts", items: [ |
| 94 | - {title: "Info", block: 'p', exact: true, attributes : {'class' : 'callout info'}}, | 94 | + {title: "Success", block: 'p', exact: true, attributes : {'class' : 'callout success'}}, |
| 95 | - {title: "Warning", block: 'p', exact: true, attributes : {'class' : 'callout warning'}}, | 95 | + {title: "Info", block: 'p', exact: true, attributes : {'class' : 'callout info'}}, |
| 96 | - {title: "Danger", block: 'p', exact: true, attributes : {'class' : 'callout danger'}} | 96 | + {title: "Warning", block: 'p', exact: true, attributes : {'class' : 'callout warning'}}, |
| 97 | - ]} | 97 | + {title: "Danger", block: 'p', exact: true, attributes : {'class' : 'callout danger'}} |
| 98 | - ], | 98 | + ]} |
| 99 | - style_formats_merge: false, | 99 | + ], |
| 100 | - formats: { | 100 | + style_formats_merge: false, |
| 101 | - alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-left'}, | 101 | + formats: { |
| 102 | - aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-center'}, | 102 | + alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-left'}, |
| 103 | - alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-right'}, | 103 | + aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-center'}, |
| 104 | - }, | 104 | + alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'align-right'}, |
| 105 | - file_browser_callback: function (field_name, url, type, win) { | 105 | + }, |
| 106 | - | 106 | + file_browser_callback: function (field_name, url, type, win) { |
| 107 | - if (type === 'file') { | 107 | + |
| 108 | - window.showEntityLinkSelector(function(entity) { | 108 | + if (type === 'file') { |
| 109 | - let originalField = win.document.getElementById(field_name); | 109 | + window.showEntityLinkSelector(function(entity) { |
| 110 | - originalField.value = entity.link; | 110 | + let originalField = win.document.getElementById(field_name); |
| 111 | - $(originalField).closest('.mce-form').find('input').eq(2).val(entity.name); | 111 | + originalField.value = entity.link; |
| 112 | - }); | 112 | + $(originalField).closest('.mce-form').find('input').eq(2).val(entity.name); |
| 113 | - } | 113 | + }); |
| 114 | + } | ||
| 114 | 115 | ||
| 115 | - if (type === 'image') { | 116 | + if (type === 'image') { |
| 116 | - // Show image manager | 117 | + // Show image manager |
| 117 | - window.ImageManager.showExternal(function (image) { | 118 | + window.ImageManager.showExternal(function (image) { |
| 118 | - | ||
| 119 | - // Set popover link input to image url then fire change event | ||
| 120 | - // to ensure the new value sticks | ||
| 121 | - win.document.getElementById(field_name).value = image.url; | ||
| 122 | - if ("createEvent" in document) { | ||
| 123 | - let evt = document.createEvent("HTMLEvents"); | ||
| 124 | - evt.initEvent("change", false, true); | ||
| 125 | - win.document.getElementById(field_name).dispatchEvent(evt); | ||
| 126 | - } else { | ||
| 127 | - win.document.getElementById(field_name).fireEvent("onchange"); | ||
| 128 | - } | ||
| 129 | 119 | ||
| 130 | - // Replace the actively selected content with the linked image | 120 | + // Set popover link input to image url then fire change event |
| 131 | - let html = `<a href="${image.url}" target="_blank">`; | 121 | + // to ensure the new value sticks |
| 132 | - html += `<img src="${image.thumbs.display}" alt="${image.name}">`; | 122 | + win.document.getElementById(field_name).value = image.url; |
| 133 | - html += '</a>'; | 123 | + if ("createEvent" in document) { |
| 134 | - win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html); | 124 | + let evt = document.createEvent("HTMLEvents"); |
| 135 | - }); | 125 | + evt.initEvent("change", false, true); |
| 136 | - } | 126 | + win.document.getElementById(field_name).dispatchEvent(evt); |
| 127 | + } else { | ||
| 128 | + win.document.getElementById(field_name).fireEvent("onchange"); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + // Replace the actively selected content with the linked image | ||
| 132 | + let html = `<a href="${image.url}" target="_blank">`; | ||
| 133 | + html += `<img src="${image.thumbs.display}" alt="${image.name}">`; | ||
| 134 | + html += '</a>'; | ||
| 135 | + win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html); | ||
| 136 | + }); | ||
| 137 | + } | ||
| 137 | 138 | ||
| 138 | - }, | 139 | + }, |
| 139 | - paste_preprocess: function (plugin, args) { | 140 | + paste_preprocess: function (plugin, args) { |
| 140 | - let content = args.content; | 141 | + let content = args.content; |
| 141 | - if (content.indexOf('<img src="file://') !== -1) { | 142 | + if (content.indexOf('<img src="file://') !== -1) { |
| 142 | - args.content = ''; | 143 | + args.content = ''; |
| 143 | - } | 144 | + } |
| 144 | - }, | 145 | + }, |
| 145 | - extraSetups: [], | 146 | + extraSetups: [], |
| 146 | - setup: function (editor) { | 147 | + setup: function (editor) { |
| 147 | - | 148 | + |
| 148 | - // Run additional setup actions | 149 | + // Run additional setup actions |
| 149 | - // Used by the angular side of things | 150 | + // Used by the angular side of things |
| 150 | - for (let i = 0; i < mceOptions.extraSetups.length; i++) { | 151 | + for (let i = 0; i < settings.extraSetups.length; i++) { |
| 151 | - mceOptions.extraSetups[i](editor); | 152 | + settings.extraSetups[i](editor); |
| 152 | - } | 153 | + } |
| 153 | 154 | ||
| 154 | - registerEditorShortcuts(editor); | 155 | + registerEditorShortcuts(editor); |
| 155 | 156 | ||
| 156 | - (function () { | 157 | + let wrap; |
| 157 | - var wrap; | ||
| 158 | 158 | ||
| 159 | function hasTextContent(node) { | 159 | function hasTextContent(node) { |
| 160 | return node && !!( node.textContent || node.innerText ); | 160 | return node && !!( node.textContent || node.innerText ); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | editor.on('dragstart', function () { | 163 | editor.on('dragstart', function () { |
| 164 | - var node = editor.selection.getNode(); | 164 | + let node = editor.selection.getNode(); |
| 165 | 165 | ||
| 166 | if (node.nodeName !== 'IMG') return; | 166 | if (node.nodeName !== 'IMG') return; |
| 167 | wrap = editor.dom.getParent(node, '.mceTemp'); | 167 | wrap = editor.dom.getParent(node, '.mceTemp'); |
| ... | @@ -172,7 +172,7 @@ var mceOptions = module.exports = { | ... | @@ -172,7 +172,7 @@ var mceOptions = module.exports = { |
| 172 | }); | 172 | }); |
| 173 | 173 | ||
| 174 | editor.on('drop', function (event) { | 174 | editor.on('drop', function (event) { |
| 175 | - var dom = editor.dom, | 175 | + let dom = editor.dom, |
| 176 | rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc()); | 176 | rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc()); |
| 177 | 177 | ||
| 178 | // Don't allow anything to be dropped in a captioned image. | 178 | // Don't allow anything to be dropped in a captioned image. |
| ... | @@ -190,26 +190,27 @@ var mceOptions = module.exports = { | ... | @@ -190,26 +190,27 @@ var mceOptions = module.exports = { |
| 190 | 190 | ||
| 191 | wrap = null; | 191 | wrap = null; |
| 192 | }); | 192 | }); |
| 193 | - })(); | ||
| 194 | - | ||
| 195 | - // Custom Image picker button | ||
| 196 | - editor.addButton('image-insert', { | ||
| 197 | - title: 'My title', | ||
| 198 | - icon: 'image', | ||
| 199 | - tooltip: 'Insert an image', | ||
| 200 | - onclick: function () { | ||
| 201 | - window.ImageManager.showExternal(function (image) { | ||
| 202 | - let html = `<a href="${image.url}" target="_blank">`; | ||
| 203 | - html += `<img src="${image.thumbs.display}" alt="${image.name}">`; | ||
| 204 | - html += '</a>'; | ||
| 205 | - editor.execCommand('mceInsertContent', false, html); | ||
| 206 | - }); | ||
| 207 | - } | ||
| 208 | - }); | ||
| 209 | 193 | ||
| 210 | - // Paste image-uploads | ||
| 211 | - editor.on('paste', function(event) { | ||
| 212 | - editorPaste(event, editor); | ||
| 213 | - }); | ||
| 214 | - } | ||
| 215 | -}; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 194 | + // Custom Image picker button | ||
| 195 | + editor.addButton('image-insert', { | ||
| 196 | + title: 'My title', | ||
| 197 | + icon: 'image', | ||
| 198 | + tooltip: 'Insert an image', | ||
| 199 | + onclick: function () { | ||
| 200 | + window.ImageManager.showExternal(function (image) { | ||
| 201 | + let html = `<a href="${image.url}" target="_blank">`; | ||
| 202 | + html += `<img src="${image.thumbs.display}" alt="${image.name}">`; | ||
| 203 | + html += '</a>'; | ||
| 204 | + editor.execCommand('mceInsertContent', false, html); | ||
| 205 | + }); | ||
| 206 | + } | ||
| 207 | + }); | ||
| 208 | + | ||
| 209 | + // Paste image-uploads | ||
| 210 | + editor.on('paste', function(event) { | ||
| 211 | + editorPaste(event, editor); | ||
| 212 | + }); | ||
| 213 | + } | ||
| 214 | + }; | ||
| 215 | + return settings; | ||
| 216 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | // Configure ZeroClipboard | 2 | // Configure ZeroClipboard |
| 3 | -var zeroClipBoard = require('zeroclipboard'); | 3 | +import zeroClipBoard from "zeroclipboard"; |
| 4 | -zeroClipBoard.config({ | ||
| 5 | - swfPath: window.baseUrl('/ZeroClipboard.swf') | ||
| 6 | -}); | ||
| 7 | 4 | ||
| 8 | -window.setupPageShow = module.exports = function (pageId) { | 5 | +export default window.setupPageShow = function (pageId) { |
| 9 | 6 | ||
| 10 | // Set up pointer | 7 | // Set up pointer |
| 11 | - var $pointer = $('#pointer').detach(); | 8 | + let $pointer = $('#pointer').detach(); |
| 12 | - var $pointerInner = $pointer.children('div.pointer').first(); | 9 | + let $pointerInner = $pointer.children('div.pointer').first(); |
| 13 | - var isSelection = false; | 10 | + let isSelection = false; |
| 14 | 11 | ||
| 15 | // Select all contents on input click | 12 | // Select all contents on input click |
| 16 | $pointer.on('click', 'input', function (e) { | 13 | $pointer.on('click', 'input', function (e) { |
| ... | @@ -19,6 +16,9 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -19,6 +16,9 @@ window.setupPageShow = module.exports = function (pageId) { |
| 19 | }); | 16 | }); |
| 20 | 17 | ||
| 21 | // Set up copy-to-clipboard | 18 | // Set up copy-to-clipboard |
| 19 | + zeroClipBoard.config({ | ||
| 20 | + swfPath: window.baseUrl('/ZeroClipboard.swf') | ||
| 21 | + }); | ||
| 22 | new zeroClipBoard($pointer.find('button').first()[0]); | 22 | new zeroClipBoard($pointer.find('button').first()[0]); |
| 23 | 23 | ||
| 24 | // Hide pointer when clicking away | 24 | // Hide pointer when clicking away |
| ... | @@ -31,11 +31,11 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -31,11 +31,11 @@ window.setupPageShow = module.exports = function (pageId) { |
| 31 | // Show pointer when selecting a single block of tagged content | 31 | // Show pointer when selecting a single block of tagged content |
| 32 | $('.page-content [id^="bkmrk"]').on('mouseup keyup', function (e) { | 32 | $('.page-content [id^="bkmrk"]').on('mouseup keyup', function (e) { |
| 33 | e.stopPropagation(); | 33 | e.stopPropagation(); |
| 34 | - var selection = window.getSelection(); | 34 | + let selection = window.getSelection(); |
| 35 | if (selection.toString().length === 0) return; | 35 | if (selection.toString().length === 0) return; |
| 36 | 36 | ||
| 37 | // Show pointer and set link | 37 | // Show pointer and set link |
| 38 | - var $elem = $(this); | 38 | + let $elem = $(this); |
| 39 | let link = window.baseUrl('/link/' + pageId + '#' + $elem.attr('id')); | 39 | let link = window.baseUrl('/link/' + pageId + '#' + $elem.attr('id')); |
| 40 | if (link.indexOf('http') !== 0) link = window.location.protocol + "//" + window.location.host + link; | 40 | if (link.indexOf('http') !== 0) link = window.location.protocol + "//" + window.location.host + link; |
| 41 | $pointer.find('input').val(link); | 41 | $pointer.find('input').val(link); |
| ... | @@ -44,9 +44,9 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -44,9 +44,9 @@ window.setupPageShow = module.exports = function (pageId) { |
| 44 | $pointer.show(); | 44 | $pointer.show(); |
| 45 | 45 | ||
| 46 | // Set pointer to sit near mouse-up position | 46 | // Set pointer to sit near mouse-up position |
| 47 | - var pointerLeftOffset = (e.pageX - $elem.offset().left - ($pointerInner.width() / 2)); | 47 | + let pointerLeftOffset = (e.pageX - $elem.offset().left - ($pointerInner.width() / 2)); |
| 48 | if (pointerLeftOffset < 0) pointerLeftOffset = 0; | 48 | if (pointerLeftOffset < 0) pointerLeftOffset = 0; |
| 49 | - var pointerLeftOffsetPercent = (pointerLeftOffset / $elem.width()) * 100; | 49 | + let pointerLeftOffsetPercent = (pointerLeftOffset / $elem.width()) * 100; |
| 50 | $pointerInner.css('left', pointerLeftOffsetPercent + '%'); | 50 | $pointerInner.css('left', pointerLeftOffsetPercent + '%'); |
| 51 | 51 | ||
| 52 | isSelection = true; | 52 | isSelection = true; |
| ... | @@ -57,7 +57,7 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -57,7 +57,7 @@ window.setupPageShow = module.exports = function (pageId) { |
| 57 | 57 | ||
| 58 | // Go to, and highlight if necessary, the specified text. | 58 | // Go to, and highlight if necessary, the specified text. |
| 59 | function goToText(text) { | 59 | function goToText(text) { |
| 60 | - var idElem = $('.page-content #' + text).first(); | 60 | + let idElem = $('.page-content #' + text).first(); |
| 61 | if (idElem.length !== 0) { | 61 | if (idElem.length !== 0) { |
| 62 | idElem.smoothScrollTo(); | 62 | idElem.smoothScrollTo(); |
| 63 | idElem.css('background-color', 'rgba(244, 249, 54, 0.25)'); | 63 | idElem.css('background-color', 'rgba(244, 249, 54, 0.25)'); |
| ... | @@ -68,19 +68,19 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -68,19 +68,19 @@ window.setupPageShow = module.exports = function (pageId) { |
| 68 | 68 | ||
| 69 | // Check the hash on load | 69 | // Check the hash on load |
| 70 | if (window.location.hash) { | 70 | if (window.location.hash) { |
| 71 | - var text = window.location.hash.replace(/\%20/g, ' ').substr(1); | 71 | + let text = window.location.hash.replace(/\%20/g, ' ').substr(1); |
| 72 | goToText(text); | 72 | goToText(text); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | // Make the book-tree sidebar stick in view on scroll | 75 | // Make the book-tree sidebar stick in view on scroll |
| 76 | - var $window = $(window); | 76 | + let $window = $(window); |
| 77 | - var $bookTree = $(".book-tree"); | 77 | + let $bookTree = $(".book-tree"); |
| 78 | - var $bookTreeParent = $bookTree.parent(); | 78 | + let $bookTreeParent = $bookTree.parent(); |
| 79 | // Check the page is scrollable and the content is taller than the tree | 79 | // Check the page is scrollable and the content is taller than the tree |
| 80 | - var pageScrollable = ($(document).height() > $window.height()) && ($bookTree.height() < $('.page-content').height()); | 80 | + let pageScrollable = ($(document).height() > $window.height()) && ($bookTree.height() < $('.page-content').height()); |
| 81 | // Get current tree's width and header height | 81 | // Get current tree's width and header height |
| 82 | - var headerHeight = $("#header").height() + $(".toolbar").height(); | 82 | + let headerHeight = $("#header").height() + $(".toolbar").height(); |
| 83 | - var isFixed = $window.scrollTop() > headerHeight; | 83 | + let isFixed = $window.scrollTop() > headerHeight; |
| 84 | // Function to fix the tree as a sidebar | 84 | // Function to fix the tree as a sidebar |
| 85 | function stickTree() { | 85 | function stickTree() { |
| 86 | $bookTree.width($bookTreeParent.width() + 15); | 86 | $bookTree.width($bookTreeParent.width() + 15); |
| ... | @@ -95,7 +95,7 @@ window.setupPageShow = module.exports = function (pageId) { | ... | @@ -95,7 +95,7 @@ window.setupPageShow = module.exports = function (pageId) { |
| 95 | } | 95 | } |
| 96 | // Checks if the tree stickiness state should change | 96 | // Checks if the tree stickiness state should change |
| 97 | function checkTreeStickiness(skipCheck) { | 97 | function checkTreeStickiness(skipCheck) { |
| 98 | - var shouldBeFixed = $window.scrollTop() > headerHeight; | 98 | + let shouldBeFixed = $window.scrollTop() > headerHeight; |
| 99 | if (shouldBeFixed && (!isFixed || skipCheck)) { | 99 | if (shouldBeFixed && (!isFixed || skipCheck)) { |
| 100 | stickTree(); | 100 | stickTree(); |
| 101 | } else if (!shouldBeFixed && (isFixed || skipCheck)) { | 101 | } else if (!shouldBeFixed && (isFixed || skipCheck)) { | ... | ... |
-
Please register or sign in to post a comment