diff --git a/.eslintrc b/.eslintrc index 47746837d..c70f3cbf2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,11 +19,11 @@ "arrow-spacing": [2, { "before": true, "after": true }], "arrow-parens": [2, "always"], "eqeqeq": [2, "smart"], - "indent": [2, 4, {SwitchCase: 1}], - "quotes": [2, 'single'], + "indent": [2, 4, {"SwitchCase": 1}], + "quotes": [2, "single"], "linebreak-style": [2, "unix"], "prefer-arrow-callback": 2, - "dot-notation": [2, {allowKeywords: true}], //some libraries use keywords like catch or delete + "dot-notation": [2, {"allowKeywords": true}], //some libraries use keywords like catch or delete "no-use-before-define": 0, "no-unused-vars": 0, // see https://github.com/babel/babel-eslint/issues/21 "semi": [2, "always"], diff --git a/actions/history/loadContentHistory.js b/actions/history/loadContentHistory.js index 3ebc43b43..f2cbdcc62 100644 --- a/actions/history/loadContentHistory.js +++ b/actions/history/loadContentHistory.js @@ -2,7 +2,7 @@ import { shortTitle } from '../../configs/general'; import deckContentTypeError from '../error/deckContentTypeError'; import slideIdTypeError from '../error/slideIdTypeError'; import { AllowedPattern } from '../error/util/allowedPattern'; -import DeckTreeStore from '../../stores/DeckTreeStore.js' +import DeckTreeStore from '../../stores/DeckTreeStore.js'; import { isEmpty } from '../../common.js'; export default function loadContentHistory(context, payload, done) { diff --git a/actions/user/userSignOut.js b/actions/user/userSignOut.js index 6d80ce675..6eab44419 100644 --- a/actions/user/userSignOut.js +++ b/actions/user/userSignOut.js @@ -1,31 +1,30 @@ import async from 'async'; -import { navigateAction } from 'fluxible-router'; +import {navigateAction} from 'fluxible-router'; export default function userSignOut(context, payload, done) { async.series([ - // (callback) => { - // context.dispatch('USER_SIGNOUT', payload); - // callback(); - // }, - (callback) => { - console.log(location.pathname.split('/')[location.pathname.split('/').length - 1]); + // (callback) => { + // context.dispatch('USER_SIGNOUT', payload); + // callback(); + // }, + (callback) => { + console.log(location.pathname.split('/')[location.pathname.split('/').length - 1]); - if(location.pathname.split('/').pop() !== payload.username && location.pathname.includes(payload.username)) - context.executeAction(navigateAction, { url: '/' }, callback); - else if(location.pathname.split('/').pop() === 'edit') { - let newPath = location.pathname.substring(0,location.pathname.length - 4).concat('view'); - context.executeAction(navigateAction, { url: newPath}, callback); - } - else - callback(); - }, - (callback) => { - context.deleteUser(); //clear user (is cookie) via userStoragePlugin - callback(); + if (location.pathname.split('/').pop() !== payload.username && location.pathname.includes(payload.username)) + context.executeAction(navigateAction, {url: '/'}, callback); + else if (location.pathname.split('/').pop() === 'edit') { + let newPath = location.pathname.substring(0, location.pathname.length - 4).concat('view'); + context.executeAction(navigateAction, {url: newPath}, callback); } - ], - (err, result) => { - if(err) console.log(err); - done(); - }); + else + callback(); + }, + (callback) => { + context.deleteUser(); //clear user (is cookie) via userStoragePlugin + callback(); + } + ], (err, result) => { + if (err) console.log(err); + done(); + }); } diff --git a/components/AddDeck/AddDeck.js b/components/AddDeck/AddDeck.js index cf3cb9e4c..b9363bbb3 100644 --- a/components/AddDeck/AddDeck.js +++ b/components/AddDeck/AddDeck.js @@ -270,9 +270,9 @@ class AddDeck extends React.Component { if (this.props.ImportStore.deckId !== null && this.props.ImportStore.uploadProgress < 100 && this.props.ImportStore.error === null) { - setTimeout( () => { - this.context.executeAction(checkNoOfSlides, {id: this.props.ImportStore.deckId}); - }, 100); + setTimeout( () => { + this.context.executeAction(checkNoOfSlides, {id: this.props.ImportStore.deckId}); + }, 100); } return ( diff --git a/components/Deck/ContentModulesPanel/ContentQuestionsPanel/ContentQuestionAnswersItem.js b/components/Deck/ContentModulesPanel/ContentQuestionsPanel/ContentQuestionAnswersItem.js index c37614871..06ff3b09e 100644 --- a/components/Deck/ContentModulesPanel/ContentQuestionsPanel/ContentQuestionAnswersItem.js +++ b/components/Deck/ContentModulesPanel/ContentQuestionsPanel/ContentQuestionAnswersItem.js @@ -7,9 +7,9 @@ class ContentQuestionAnswersItem extends React.Component { let rightIcon = (); switch (answer.correct) { - case true: - rightIcon = (); - break; + case true: + rightIcon = (); + break; } return ( diff --git a/components/Deck/ContentModulesPanel/ContentUsagePanel/ContentUsagePanel.js b/components/Deck/ContentModulesPanel/ContentUsagePanel/ContentUsagePanel.js index 691f5687e..b843090a4 100644 --- a/components/Deck/ContentModulesPanel/ContentUsagePanel/ContentUsagePanel.js +++ b/components/Deck/ContentModulesPanel/ContentUsagePanel/ContentUsagePanel.js @@ -10,7 +10,7 @@ class ContentUsagePanel extends React.Component { this {this.props.ContentUsageStore.selector.stype}.; const usageListComp =
+ selector={this.props.ContentUsageStore.selector}/>; return (
{(this.props.ContentUsageStore.usage.length === 0) ? noUsageMessage : usageListComp}
diff --git a/components/Deck/ContentModulesPanel/ContributorsPanel/util/ContributorsUtil.js b/components/Deck/ContentModulesPanel/ContributorsPanel/util/ContributorsUtil.js index 3422b1529..f3bbfad7b 100644 --- a/components/Deck/ContentModulesPanel/ContributorsPanel/util/ContributorsUtil.js +++ b/components/Deck/ContentModulesPanel/ContributorsPanel/util/ContributorsUtil.js @@ -7,8 +7,8 @@ class ContributorsUtil { } static contains(slides, slide) { - var found = false; - for (var i = 0; i < slides.length; i++) { + let found = false; + for (let i = 0; i < slides.length; i++) { if (slides[i] === slide) { found = true; break; diff --git a/components/Deck/ContentPanel/ContentActions/ContentActionsFooter.js b/components/Deck/ContentPanel/ContentActions/ContentActionsFooter.js index 1f64ee60f..ec66c1058 100644 --- a/components/Deck/ContentPanel/ContentActions/ContentActionsFooter.js +++ b/components/Deck/ContentPanel/ContentActions/ContentActionsFooter.js @@ -60,7 +60,7 @@ class ContentActionsFooter extends React.Component { getExportHref(type){ if (type !== 'EPub' && type !== 'PDF') { - return; + return; } if (this.props.ContentStore.selector.id !== undefined && this.props.ContentStore.selector.id !== '' && this.props.ContentStore.selector.id !== 0) { diff --git a/components/Deck/ContentPanel/DeckModes/DeckEditPanel/DeckPropertiesEditor.js b/components/Deck/ContentPanel/DeckModes/DeckEditPanel/DeckPropertiesEditor.js index 2caf88199..6022d2a37 100644 --- a/components/Deck/ContentPanel/DeckModes/DeckEditPanel/DeckPropertiesEditor.js +++ b/components/Deck/ContentPanel/DeckModes/DeckEditPanel/DeckPropertiesEditor.js @@ -84,7 +84,7 @@ class DeckPropertiesEditor extends React.Component { } handleChange(fieldName, event) { - var stateChange = {}; + let stateChange = {}; stateChange[fieldName] = event.target.value; this.setState(stateChange); } diff --git a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js index 8b2ad5729..d2e7b9d23 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js +++ b/components/Deck/ContentPanel/SlideModes/SlideEditPanel/SlideContentEditor.js @@ -31,15 +31,7 @@ class SlideContentEditor extends React.Component { handleSaveButton(){ - - if (this.props.UserProfileStore.username === '') - { - //TODO: show login modal via context action - alert('you need to login to save changes'); - } - else - { - + if (this.props.UserProfileStore.username !== '') { // Replace the onbeforeunload function by a Blank Function because it is not neccesary when saved. swal({ title: 'Saving Content...', @@ -54,10 +46,10 @@ class SlideContentEditor extends React.Component { //remove editing borders: $('.pptx2html [style*="absolute"]') .css({'borderStyle': '', 'borderColor': ''}); - $(".pptx2html") + $('.pptx2html') .css({'borderStyle': '', 'borderColor': '', 'box-shadow': ''}); //reset scaling of pptx2html element to get original size - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); //ReactDOM.findDOMNode(this.refs.inlineContent).attr('value'); //ReactDOM.findDOMNode(this.refs.inlineContent).getContent(); @@ -183,21 +175,20 @@ class SlideContentEditor extends React.Component { //CKEDITOR.inline('inlineContent', {filebrowserUploadUrl: Microservices.import.uri + '/importImage/' + userId, customConfig: '../../../../../../custom_modules/ckeditor/config.js'}); CKEDITOR.inline('inlineContent', { customConfig: '/assets/ckeditor_config.js', - filebrowserUploadUrl: Microservices.import.uri + '/importImage/' + userId}); //leave all buttons + filebrowserUploadUrl: Microservices.import.uri + '/importImage/' + userId}); //leave all buttons } this.currentcontent = this.props.content; - ReactDOM.findDOMNode(this.refs.container).addEventListener('resize', (evt) => - { - if(process.env.BROWSER){ - //this.resize(); - //alert('resize'); - this.forceUpdate(); - } + ReactDOM.findDOMNode(this.refs.container).addEventListener('resize', (evt) => { + if(process.env.BROWSER){ + //this.resize(); + // alert('resize'); + this.forceUpdate(); + } }); - CKEDITOR.instances.inlineContent.on("instanceReady", function() { + CKEDITOR.instances.inlineContent.on('instanceReady', function() { //needs copy of resize function == cannot find this.something in this context. //tried ReactDOM.findDOMNode(this.refs.inlineContent).addEventListener('instanceReady', (evt) => //but did not work @@ -207,13 +198,13 @@ class SlideContentEditor extends React.Component { //this.forceUpdate(); //this.resize(); // } - if ($(".pptx2html [style*='absolute']").not('.drawing-container').css('borderStyle') !== 'dashed') + if ($('.pptx2html [style*="absolute"]').not('.drawing-container').css('borderStyle') !== 'dashed') { - $(".pptx2html [style*='absolute']").not('.drawing-container').css({'borderStyle': 'dashed', 'borderColor': '#33cc33'}); + $('.pptx2html [style*="absolute"]').not('.drawing-container').css({'borderStyle': 'dashed', 'borderColor': '#33cc33'}); } let containerwidth = document.getElementById('container').offsetWidth; let containerheight = document.getElementById('container').offsetHeight; - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); let pptxwidth = $('.pptx2html').width(); let pptxheight = $('.pptx2html').height(); if (containerwidth > pptxwidth) @@ -222,25 +213,25 @@ class SlideContentEditor extends React.Component { } else { this.scaleratio = containerwidth / pptxwidth; } - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); - $(".pptx2html").css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); require('../../../../../custom_modules/simple-draggable/lib/index.js'); - SimpleDraggable(".pptx2html [style*='absolute']", { - onlyX: false - , onlyY: false - , ratio: this.scaleratio + SimpleDraggable('.pptx2html [style*="absolute"]', { + onlyX: false, + onlyY: false, + ratio: this.scaleratio }); - SimpleDraggable(".pptx2html > [style*='absolute'] > [style*='absolute']", { + SimpleDraggable('.pptx2html > [style*="absolute"] > [style*="absolute"]', { onlyX: false , onlyY: false , ratio: this.scaleratio }); - if(document.domain != "localhost") + if(document.domain !== 'localhost') { document.domain = 'slidewiki.org'; } - $(".pptx2html").css({'borderStyle': 'none none double none', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); + $('.pptx2html').css({'borderStyle': 'none none double none', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); }); @@ -257,8 +248,7 @@ class SlideContentEditor extends React.Component { this.resize(); } } - resize() - { + resize() { //if(process.env.BROWSER){ //require('../../../../../bower_components/reveal.js/css/reveal.css'); // Uncomment this to see with the different themes. Assuming testing for PPTPX2HTML for now @@ -268,10 +258,9 @@ class SlideContentEditor extends React.Component { //require('../../SetupReveal.css'); /*add border*/ //alert($(".pptx2html [style*='absolute']").css('borderStyle')); - if ($(".pptx2html [style*='absolute']").not('.drawing-container').css('borderStyle') !== 'dashed') - { - $(".pptx2html [style*='absolute']").not('.drawing-container').css({'borderStyle': 'dashed', 'borderColor': '#33cc33'}); - } + if ($('.pptx2html [style*="absolute"]').not('.drawing-container').css('borderStyle') !== 'dashed') { + $('.pptx2html [style*="absolute"]').not('.drawing-container').css({'borderStyle': 'dashed', 'borderColor': '#33cc33'}); + } //} let containerwidth = document.getElementById('container').offsetWidth; @@ -279,7 +268,7 @@ class SlideContentEditor extends React.Component { //console.log('Component has been resized! Width =' + containerwidth + 'height' + containerheight); //reset scaling of pptx2html element to get original size - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); //Function to fit contents in edit and view component //let pptxwidth = document.getElementByClassName('pptx2html').offsetWidth; @@ -290,17 +279,17 @@ class SlideContentEditor extends React.Component { this.scaleratio = containerwidth / pptxwidth; - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); - $(".pptx2html").css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); require('../../../../../custom_modules/simple-draggable/lib/index.js'); //TODO: remove previous event listeners! - SimpleDraggable(".pptx2html [style*='absolute']", { + SimpleDraggable('.pptx2html [style*="absolute"]', { onlyX: false , onlyY: false , ratio: this.scaleratio }); - SimpleDraggable(".pptx2html > [style*='absolute'] > [style*='absolute']", { + SimpleDraggable('.pptx2html > [style*="absolute"] > [style*="absolute"]', { onlyX: false , onlyY: false , ratio: this.scaleratio @@ -310,10 +299,10 @@ class SlideContentEditor extends React.Component { this.refs.inlineContent.style.height = ((pptxheight + 0 + 20) * this.scaleratio) + 'px'; //show that content is outside of pptx2html box - $(".pptx2html").css({'borderStyle': 'none none double none', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); + $('.pptx2html').css({'borderStyle': 'none none double none', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); //fix bug with speakernotes overlapping soure dialog/other elements - SWIK-832 - $("#inlineSpeakerNotes [style*='absolute']").css({'position': 'relative', 'zIndex': '0'}); + $('#inlineSpeakerNotes [style*="absolute"]').css({'position': 'relative', 'zIndex': '0'}); } componentWillUnmount() { @@ -405,7 +394,7 @@ class SlideContentEditor extends React.Component { this.addBoxButtonHTML = + ; } else {this.addBoxButtonHTML = '';} return ( @@ -440,12 +429,10 @@ class SlideContentEditor extends React.Component { }*/ emitChange() { - - window.onbeforeunload = () => { - return 'If you don\'t save the slide, it won\'t be updated. ' + - 'Are you sure you want to exit this page?'; - - }; + window.onbeforeunload = () => { + return 'If you don\'t save the slide, it won\'t be updated. ' + + 'Are you sure you want to exit this page?'; + }; } /* confirmExit() { diff --git a/components/Deck/ContentPanel/SlideModes/SlideViewPanel/SlideViewPanel.js b/components/Deck/ContentPanel/SlideModes/SlideViewPanel/SlideViewPanel.js index 4b241bd5d..794586171 100644 --- a/components/Deck/ContentPanel/SlideModes/SlideViewPanel/SlideViewPanel.js +++ b/components/Deck/ContentPanel/SlideModes/SlideViewPanel/SlideViewPanel.js @@ -34,7 +34,7 @@ class SlideViewPanel extends React.Component { const containerMinHeight = { - } + }; return ( @@ -74,7 +74,7 @@ class SlideViewPanel extends React.Component { } */ //initial resize - this.resize() + this.resize(); ReactDOM.findDOMNode(this.refs.container).addEventListener('resize', (evt) => { //console.log('resize'); @@ -86,7 +86,7 @@ class SlideViewPanel extends React.Component { componentDidUpdate() { // update mathjax rendering // add to the mathjax rendering queue the command to type-set the inlineContent - MathJax.Hub.Queue(["Typeset",MathJax.Hub,"inlineContent"]); + MathJax.Hub.Queue(['Typeset',MathJax.Hub,'inlineContent']); this.resize(); } @@ -97,7 +97,7 @@ class SlideViewPanel extends React.Component { //console.log('Component has been resized! Width =' + containerwidth + 'height' + containerheight); //reset scaling of pptx2html element to get original size - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); //Function to fit contents in edit and view component let pptxwidth = $('.pptx2html').width(); @@ -108,8 +108,8 @@ class SlideViewPanel extends React.Component { if ($('.pptx2html').length) { - $(".pptx2html").css({'transform': '', 'transform-origin': ''}); - $(".pptx2html").css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); + $('.pptx2html').css({'transform': '', 'transform-origin': ''}); + $('.pptx2html').css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'}); //set height of content panel to at least size of pptx2html + (100 pixels * scaleratio). //width = pptxwidth + 40 @@ -120,7 +120,7 @@ class SlideViewPanel extends React.Component { //style.padding left = 20 px, top 20 px this.refs.slideViewPanel.style.height = ((pptxheight + 0 + 20) * this.scaleratio) + 'px'; - $(".pptx2html").css({'borderStyle': 'none none double none ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); + $('.pptx2html').css({'borderStyle': 'none none double none ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); //all borders //$(".pptx2html").css({'borderStyle': 'double double double double ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'}); } diff --git a/components/Deck/Presentation/Presentation.js b/components/Deck/Presentation/Presentation.js index df8ad990f..926f1b222 100644 --- a/components/Deck/Presentation/Presentation.js +++ b/components/Deck/Presentation/Presentation.js @@ -89,7 +89,7 @@ class Presentation extends React.Component{ if(slides){ for (let i = 0; i < slides.length; i++) { let slide = slides[i]; - let notes = '' + let notes = ''; if(slide.speakernotes){ notes = ''; } diff --git a/components/Deck/Presentation/PresentationPrint.js b/components/Deck/Presentation/PresentationPrint.js index 7e99e88eb..dac726554 100644 --- a/components/Deck/Presentation/PresentationPrint.js +++ b/components/Deck/Presentation/PresentationPrint.js @@ -20,7 +20,7 @@ let clearStyle = { let pdf; if(process.env.BROWSER){ - pdf = require('../../../custom_modules/reveal.js/css/print/pdf.css'); + pdf = require('../../../custom_modules/reveal.js/css/print/pdf.css'); } @@ -95,7 +95,7 @@ class Presentation extends React.Component{ if(slides){ for (let i = 0; i < slides.length; i++) { let slide = slides[i]; - let notes = '' + let notes = ''; if(slide.speakernotes){ notes = ''; } diff --git a/components/Deck/Presentation/PresentationSlide.js b/components/Deck/Presentation/PresentationSlide.js index 785cab59a..8577eca1f 100644 --- a/components/Deck/Presentation/PresentationSlide.js +++ b/components/Deck/Presentation/PresentationSlide.js @@ -8,15 +8,14 @@ import SlideViewStore from '../../../stores/SlideViewStore'; let sectionStyle = { 'top': 'unset !important'}; class PresentationSlide extends React.Component { - componentDidMount(){ + componentDidMount(){ //this.props.style = sectionStyle; - } - render(){ - - return ( -
- ); - } + } + render(){ + return ( +
+ ); + } } diff --git a/components/Import/Import.js b/components/Import/Import.js index 608103842..058ef3094 100644 --- a/components/Import/Import.js +++ b/components/Import/Import.js @@ -112,7 +112,7 @@ class Import extends React.Component {

Select your presentation file and upload it to SlideWiki.

Only PowerPoint (.pptx) is supported (Max size: {MAX_FILESIZE_MB}MB).

- +
diff --git a/components/User/UserProfile/PrivatePublicUserProfile.js b/components/User/UserProfile/PrivatePublicUserProfile.js index 1e6b6b0b8..7b83a85ff 100644 --- a/components/User/UserProfile/PrivatePublicUserProfile.js +++ b/components/User/UserProfile/PrivatePublicUserProfile.js @@ -44,10 +44,9 @@ class PrivatePublicUserProfile extends React.Component {
-
+
- - ); + ); } } diff --git a/test/unit/ContentModulesStore.js b/test/unit/ContentModulesStore.js index 39361ac4b..ad81fd5b1 100644 --- a/test/unit/ContentModulesStore.js +++ b/test/unit/ContentModulesStore.js @@ -3,34 +3,30 @@ import createMockComponentContext from 'fluxible/utils/createMockComponentContex import provideContext from 'fluxible-addons-react/provideContext'; import connectToStores from 'fluxible-addons-react/connectToStores'; import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; +import {expect} from 'chai'; import ContentModuleStore from '../../stores/ContentModulesStore'; -import createStore from 'fluxible/addons/createStore'; +describe('ContentModulesStore', () => { + let component = null; -describe('ContentModulesStore', function(){ - var component = null; + beforeEach('render and locate element', (done) => { + let testStores = [ContentModuleStore]; + let context = createMockComponentContext({ + stores: testStores + }); - beforeEach('render and locate element', function(done){ + let testComponent = provideContext(connectToStores(component, testStores, () => { + return {}; + })); + let x = 42; + component = TestUtils.renderIntoDocument(); - let testStores = [ContentModuleStore]; - let context = createMockComponentContext({ - stores : testStores + done(); }); - let testComponent = provideContext(connectToStores(component, testStores, function(){ - return {}; - })); - let x = 42; - component = TestUtils.renderIntoDocument(); - - done(); - - }); - - it('should render', function(){ - expect(component).to.exist; - }); + it('should render', () => { + expect(component).to.exist; + }); });