Skip to content

Commit

Permalink
Last code style improvements. arsnova.click should new be in common w…
Browse files Browse the repository at this point in the history
…ith our rule set.
  • Loading branch information
Tjark Wilhelm Hoeck committed Apr 27, 2016
1 parent 7dd77d9 commit c0a47d5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
104 changes: 52 additions & 52 deletions arsnova.click/client/plugins/splashscreen/scripts/lib.js
Expand Up @@ -15,9 +15,9 @@
* You should have received a copy of the GNU General Public License
* along with ARSnova Click. If not, see <http://www.gnu.org/licenses/>.*/

import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import {Blaze} from 'meteor/blaze';
import {Template} from 'meteor/templating';
import {TAPi18n} from 'meteor/tap:i18n';

/**
* This class will construct an empty splashscreen which can be modified via JQuery.
Expand All @@ -42,19 +42,19 @@ import { TAPi18n } from 'meteor/tap:i18n';
*/
export class Splashscreen {
/**
* Constructs and returns a new instance of Splashscreen
*
* @param options Must be an object with optional parameters
*/
constructor(options) {
* Constructs and returns a new instance of Splashscreen
*
* @param options Must be an object with optional parameters
*/
constructor (options) {
this.options = {
autostart: options.autostart || false,
templateName: options.templateName || "splashscreen",
instanceId: options.instanceId || 0,
closeOnButton: options.closeOnButton || false,
onCreated: options.onCreated || undefined,
onDestroyed: options.onDestroyed || undefined,
onRendered: options.onRendered || undefined
autostart: options.autostart || false,
templateName: options.templateName || "splashscreen",
instanceId: options.instanceId || 0,
closeOnButton: options.closeOnButton || false,
onCreated: options.onCreated || undefined,
onDestroyed: options.onDestroyed || undefined,
onRendered: options.onRendered || undefined
};
this.templateInstance = null;
this.templateSelector = null;
Expand All @@ -65,24 +65,24 @@ export class Splashscreen {
}

/**
* This method will be called after the options have been parsed by the constructor
* If a callback to options.onCreated has been specified this method will run the callback
*/
created() {
* This method will be called after the options have been parsed by the constructor
* If a callback to options.onCreated has been specified this method will run the callback
*/
created () {
if (typeof this.options.onCreated === "function") {
this.options.onCreated(this);
}
}

/**
* This method will be called after the created method
* If a callback to options.onRendered has been specified this method will run the callback
*/
rendered() {
* This method will be called after the created method
* If a callback to options.onRendered has been specified this method will run the callback
*/
rendered () {
let template = Template[this.options.templateName];
if (template) {
this.templateInstance = Blaze.render(Template[this.options.templateName], document.body);
$(this.templateInstance.firstNode()).addClass(this.options.templateName).attr("id",this.options.templateName + "_" + this.options.instanceId);
$(this.templateInstance.firstNode()).addClass(this.options.templateName).attr("id", this.options.templateName + "_" + this.options.instanceId);
} else {
throw new Error('Invalid template name');
}
Expand All @@ -101,10 +101,10 @@ export class Splashscreen {
}

/**
* This method must be called manually
* If a callback to options.onDestroyed has been specified this method will run the callback
*/
destroy() {
* This method must be called manually
* If a callback to options.onDestroyed has been specified this method will run the callback
*/
destroy () {
if (!this.templateInstance) {
return;
}
Expand All @@ -118,9 +118,9 @@ export class Splashscreen {
}

/**
* A call of this method will close (hide) the splashscreen
*/
close() {
* A call of this method will close (hide) the splashscreen
*/
close () {
if (this.options.closeOnButton) {
this.templateSelector.off('hide.bs.modal').off('click', this.options.closeOnButton);
}
Expand All @@ -130,25 +130,25 @@ export class Splashscreen {
}

/**
* A call of this method will show (display) the splashscreen
*/
open() {
* A call of this method will show (display) the splashscreen
*/
open () {
let self = this;
if (this.options.closeOnButton) {
let hasClickedOnCloseButton = false;
this.templateSelector.on('hide.bs.modal',function (event) {
if (!hasClickedOnCloseButton) {
event.stopPropagation();
event.preventDefault();
}
}).on('click', this.options.closeOnButton, function () {
hasClickedOnCloseButton = true;
self.close();
});
this.templateSelector.on('hide.bs.modal', function (event) {
if (!hasClickedOnCloseButton) {
event.stopPropagation();
event.preventDefault();
}
}).on('click', this.options.closeOnButton, function () {
hasClickedOnCloseButton = true;
self.close();
});
} else {
this.templateSelector.on('hide.bs.modal',function () {
self.destroy();
});
this.templateSelector.on('hide.bs.modal', function () {
self.destroy();
});
}

this.templateSelector.modal("show");
Expand All @@ -158,11 +158,11 @@ export class Splashscreen {


class ErrorSplashscreen extends Splashscreen {
constructor(options) {
constructor (options) {
super(options);
}

setErrorText(text) {
setErrorText (text) {
if (this.isRendered) {
$(this.templateSelector).find(".modal-body").text(text);
} else {
Expand All @@ -175,8 +175,8 @@ export let splashscreenError = null;

export function setErrorSplashscreen() {
splashscreenError = new ErrorSplashscreen({
autostart: false,
templateName: "errorSplashscreen",
closeOnButton: "#js-btn-hideErrorMessageModal"
});
autostart: false,
templateName: "errorSplashscreen",
closeOnButton: "#js-btn-hideErrorMessageModal"
});
}
6 changes: 3 additions & 3 deletions arsnova.click/shared/answeroptions.js
Expand Up @@ -21,7 +21,7 @@ import { AnswerOptions } from '/lib/answeroptions.js';
import { Hashtags } from '/lib/hashtags.js';

Meteor.methods({
'AnswerOptions.addOption'({privateKey, hashtag, questionIndex, answerText, answerOptionNumber, isCorrect}) {
'AnswerOptions.addOption': function ({privateKey, hashtag, questionIndex, answerText, answerOptionNumber, isCorrect}) {
new SimpleSchema({
privateKey: {type: String},
hashtag: {type: String},
Expand Down Expand Up @@ -60,7 +60,7 @@ Meteor.methods({
}
});
}},
'AnswerOptions.deleteOption'({privateKey, hashtag, questionIndex, answerOptionNumber}) {
'AnswerOptions.deleteOption': function ({privateKey, hashtag, questionIndex, answerOptionNumber}) {
if (Meteor.isServer) {
new SimpleSchema({
privateKey: {type: String},
Expand Down Expand Up @@ -95,7 +95,7 @@ Meteor.methods({
}
}
},
'AnswerOptions.updateAnswerTextAndIsCorrect'({privateKey, hashtag, questionIndex, answerOptionNumber, answerText, isCorrect}) {
'AnswerOptions.updateAnswerTextAndIsCorrect': function ({privateKey, hashtag, questionIndex, answerOptionNumber, answerText, isCorrect}) {
new SimpleSchema({
privateKey: {type: String},
hashtag: {type: String},
Expand Down
2 changes: 1 addition & 1 deletion arsnova.click/shared/responses.js
Expand Up @@ -22,7 +22,7 @@ import {QuestionGroup} from '/lib/questions.js';
import {Hashtags} from '/lib/hashtags.js';

Meteor.methods({
'Responses.addResponse'(responseDoc) {
'Responses.addResponse': function (responseDoc) {
var timestamp = new Date().getTime();
var hashtag = responseDoc.hashtag;
if (Meteor.isServer) {
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Expand Up @@ -23,7 +23,7 @@ var stylish = require('jshint-stylish');

var paths = [
'./arsnova.click/{lib,server,shared}/**/*.js',
'./arsnova.click/client/{layout,lib,plugins}/**/*.js',
'./arsnova.click/client/{layout,plugins}/**/*.js',
'./arsnova.click/client/routes.js'
];

Expand Down

0 comments on commit c0a47d5

Please sign in to comment.