Commit 0260115c authored by Curtis Adam's avatar Curtis Adam

Refactor editor and markdeep templates

parent e728869c
......@@ -10,8 +10,8 @@
@import '../imports/ui/card/sidebar/sidebar.scss';
@import '../imports/ui/card/sidebar/item/zoomText';
@import '../imports/ui/card/navigation/navigation.scss';
@import '../imports/ui/markdeepEditor/content/content';
@import '../imports/ui/markdeepEditor/navigation/navigation';
@import '../imports/ui/markdeep/editor/content/content';
@import '../imports/ui/markdeep/editor/navigation/navigation';
@import '../imports/ui/filter/navigation/navigation.scss';
@import '../imports/ui/forms/bonusForm.scss';
@import '../imports/ui/forms/cardsetForm.scss';
......
......@@ -58,4 +58,4 @@
{{else}}
{{> accessDenied}}
{{/if}}
</template>
\ No newline at end of file
</template>
import "./editor.html";
import "../card/card.js";
import {Session} from "meteor/session";
import {CardType} from "../../api/cardTypes";
import {CardType} from "../../../api/cardTypes";
import {Template} from "meteor/templating";
import {Cardsets} from "../../api/cardsets";
import {CardEditor} from "../../api/cardEditor.js";
import {CardVisuals} from "../../api/cardVisuals";
import ResizeSensor from "../../../client/resize_sensor/ResizeSensor";
import {Cards} from "../../api/cards";
import {Cardsets} from "../../../api/cardsets";
import {CardEditor} from "../../../api/cardEditor.js";
import {CardVisuals} from "../../../api/cardVisuals";
import ResizeSensor from "../../../../client/resize_sensor/ResizeSensor";
import {Cards} from "../../../api/cards";
import "../card.js";
import "./modal/learningUnit.js";
import "./item/buttons.js";
import "./item/learningGoalLevel.js";
import "./item/subject.js";
import "./editor.html";
/*
* ############################################################################
......
<template name="btnCard">
<div id="button-row" class="col-xs-12 actionButtons editorElement">
<button id="cardSave"
class="btn btn-success btn-raised saveFirst col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="13">
{{_ "savecard"}}
</button>
<button id="cardSaveReturn"
class="btn btn-default btn-raised save col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="14">
{{_ "savecardReturn"}}
</button>
<button id="cardCancel" class="btn btn-danger btn-raised cancel col-xs-12 col-sm-3 pull-right"
tabindex="15" data-toggle="modal"
data-target="#cancelEditModal">{{_
"declinecard"}}</button>
</div>
</template>
import {Route} from "../../../../api/route.js";
import {CardEditor} from "../../../../api/cardEditor.js";
import {Cardsets} from "../../../../api/cardsets.js";
import "./buttons.html";
/*
* ############################################################################
* btnCard
* ############################################################################
*/
Template.btnCard.helpers({
isEditMode: function () {
return Route.isEditMode();
},
learningActive: function () {
return Cardsets.findOne(Router.current().params._id).learningActive;
}
});
Template.btnCard.events({
"click #cardSave": function () {
CardEditor.saveCard(Router.current().params.card_id, false);
},
"click #cardSaveReturn": function () {
CardEditor.saveCard(Router.current().params.card_id, true);
}
});
<template name="learningGoalLevel">
<div id="learningGoalLevelGroup" class="form-group btn-group col-xs-12" role="group" data-toggle="buttons">
<button id="learningGoalLevel0"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
0}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 0}}active{{/if}}"
data-lvl="0">
{{#if isLearningGoalLevel 0}}
<input type="radio" name="learningGoalLevel" value="0" checked tabindex="4" data-lvl="0">
{{else}}
<input type="radio" name="learningGoalLevel" value="0" data-lvl="0">
{{/if}}
{{_ "learning-goal.level1"}}
</button>
<button id="learningGoalLevel1"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
1}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 1}}active{{/if}}"
data-lvl="1">
{{#if isLearningGoalLevel 1}}
<input type="radio" name="learningGoalLevel" value="1" checked tabindex="4" data-lvl="1">
{{else}}
<input type="radio" name="learningGoalLevel" value="1" data-lvl="1">
{{/if}}
{{_ "learning-goal.level2"}}
</button>
<button id="learningGoalLevel2"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
2}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 2}}active{{/if}}"
data-lvl="2">
{{#if isLearningGoalLevel 2}}
<input type="radio" name="learningGoalLevel" value="2" checked tabindex="4" data-lvl="2">
{{else}}
<input type="radio" name="learningGoalLevel" value="2" data-lvl="2">
{{/if}}
{{_ "learning-goal.level3"}}
</button>
<button id="learningGoalLevel3"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
3}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 3}}active{{/if}}"
data-lvl="3">
{{#if isLearningGoalLevel 3}}
<input type="radio" name="learningGoalLevel" value="3" checked tabindex="4" data-lvl="3">
{{else}}
<input type="radio" name="learningGoalLevel" value="3" data-lvl="3">
{{/if}}
{{_ "learning-goal.level4"}}
</button>
<button id="learningGoalLevel4"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
4}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 4}}active{{/if}}"
data-lvl="4">
{{#if isLearningGoalLevel 4}}
<input type="radio" name="learningGoalLevel" value="4" checked tabindex="4" data-lvl="4">
{{else}}
<input type="radio" name="learningGoalLevel" value="4" data-lvl="4">
{{/if}}
{{_ "learning-goal.level5"}}
</button>
<button id="learningGoalLevel5"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
5}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 5}}active{{/if}}"
data-lvl="5">
{{#if isLearningGoalLevel 5}}
<input type="radio" name="learningGoalLevel" value="5" checked tabindex="4" data-lvl="5">
{{else}}
<input type="radio" name="learningGoalLevel" value="5" data-lvl="5">
{{/if}}
{{_ "learning-goal.level6"}}
</button>
</div>
</template>
import {Session} from "meteor/session";
import {CardEditor} from "../../../../api/cardEditor.js";
import "./learningGoalLevel.html";
/*
* ############################################################################
* learningGoalLevel
* ############################################################################
*/
Template.learningGoalLevel.helpers({
isLearningGoalLevelChecked: function (learningGoalLevel) {
return learningGoalLevel <= Session.get('learningGoalLevel');
},
isLearningGoalLevel: function (learningGoalLevel) {
return learningGoalLevel === Session.get('learningGoalLevel');
}
});
Template.learningGoalLevel.events({
'click #learningGoalLevelGroup': function (event) {
CardEditor.setEditorButtonIndex(1);
Session.set('learningGoalLevel', Number($(event.target).data('lvl')));
}
});
<template name="subjectEditor">
{{#if gotLearningUnit}}
<button class="btn btn-raised btn-success col-xs-4 col-sm-3 subjectEditorButton" data-toggle="modal"
data-target="#showSelectLearningUnitModal">{{_ "learningUnit.choose"}}</button>
{{/if}}
<form class="subjectEditor {{#if gotLearningUnit}}col-xs-8 col-sm-9{{/if}}">
<input class="form-control editorBackground" id="subjectEditor" name="content"
placeholder="{{getSubjectPlaceholder}}" value="{{getSubject}}"
tabindex="1" autofocus>
</form>
</template>
import {CardType} from "../../../../api/cardTypes";
import {CardEditor} from "../../../../api/cardEditor.js";
import {Cards} from "../../../../api/cards.js";
import {Session} from "meteor/session";
import "./subject.html";
/*
* ############################################################################
* SubjectEditor
* ############################################################################
*/
Template.subjectEditor.helpers({
getSubject: function () {
if (CardType.gotLearningUnit(Session.get('cardType')) && Session.get('learningUnit') !== "0") {
let card = Cards.findOne({_id: Session.get('learningUnit')});
if (card !== undefined && card.subject !== undefined) {
return card.subject;
} else {
return "";
}
}
return Session.get('subject');
},
getSubjectPlaceholder: function () {
return CardType.getSubjectPlaceholderText(Session.get('cardType'));
},
gotLearningUnit: function () {
return CardType.gotLearningUnit(this.cardType);
}
});
Template.subjectEditor.events({
'click #subjectEditor': function () {
CardEditor.setEditorButtonIndex(0);
},
'input #subjectEditor': function () {
$('#subjectEditor').css('border', 0);
CardEditor.setEditorButtonIndex(0);
Session.set('subject', $('#subjectEditor').val());
},
'click .subjectEditorButton': function () {
Session.set('tempLearningIndex', Session.get('learningIndex'));
Session.set('tempLearningUnit', Session.get('learningUnit'));
}
});
Template.subjectEditor.rendered = function () {
Session.set('subject', $('#subjectEditor').val());
};
<template name="learningGoalLevel">
<div id="learningGoalLevelGroup" class="form-group btn-group col-xs-12" role="group" data-toggle="buttons">
<button id="learningGoalLevel0"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
0}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 0}}active{{/if}}"
data-lvl="0">
{{#if isLearningGoalLevel 0}}
<input type="radio" name="learningGoalLevel" value="0" checked tabindex="4" data-lvl="0">
{{else}}
<input type="radio" name="learningGoalLevel" value="0" data-lvl="0">
{{/if}}
{{_ "learning-goal.level1"}}
</button>
<button id="learningGoalLevel1"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
1}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 1}}active{{/if}}"
data-lvl="1">
{{#if isLearningGoalLevel 1}}
<input type="radio" name="learningGoalLevel" value="1" checked tabindex="4" data-lvl="1">
{{else}}
<input type="radio" name="learningGoalLevel" value="1" data-lvl="1">
{{/if}}
{{_ "learning-goal.level2"}}
</button>
<button id="learningGoalLevel2"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
2}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 2}}active{{/if}}"
data-lvl="2">
{{#if isLearningGoalLevel 2}}
<input type="radio" name="learningGoalLevel" value="2" checked tabindex="4" data-lvl="2">
{{else}}
<input type="radio" name="learningGoalLevel" value="2" data-lvl="2">
{{/if}}
{{_ "learning-goal.level3"}}
</button>
<button id="learningGoalLevel3"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
3}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 3}}active{{/if}}"
data-lvl="3">
{{#if isLearningGoalLevel 3}}
<input type="radio" name="learningGoalLevel" value="3" checked tabindex="4" data-lvl="3">
{{else}}
<input type="radio" name="learningGoalLevel" value="3" data-lvl="3">
{{/if}}
{{_ "learning-goal.level4"}}
</button>
<button id="learningGoalLevel4"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
4}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 4}}active{{/if}}"
data-lvl="4">
{{#if isLearningGoalLevel 4}}
<input type="radio" name="learningGoalLevel" value="4" checked tabindex="4" data-lvl="4">
{{else}}
<input type="radio" name="learningGoalLevel" value="4" data-lvl="4">
{{/if}}
{{_ "learning-goal.level5"}}
</button>
<button id="learningGoalLevel5"
class="col-xs-6 col-sm-2 learningGoalLevelButton btn btn-raised {{#if isLearningGoalLevelChecked
5}}btn-primary{{else}}btn-white{{/if}} {{#if
isLearningGoalLevel 5}}active{{/if}}"
data-lvl="5">
{{#if isLearningGoalLevel 5}}
<input type="radio" name="learningGoalLevel" value="5" checked tabindex="4" data-lvl="5">
{{else}}
<input type="radio" name="learningGoalLevel" value="5" data-lvl="5">
{{/if}}
{{_ "learning-goal.level6"}}
</button>
</div>
</template>
<template name="subjectEditor">
{{#if gotLearningUnit}}
<button class="btn btn-raised btn-success col-xs-4 col-sm-3 subjectEditorButton" data-toggle="modal"
data-target="#showSelectLearningUnitModal">{{_ "learningUnit.choose"}}</button>
{{/if}}
<form class="subjectEditor {{#if gotLearningUnit}}col-xs-8 col-sm-9{{/if}}">
<input class="form-control editorBackground" id="subjectEditor" name="content"
placeholder="{{getSubjectPlaceholder}}" value="{{getSubject}}"
tabindex="1" autofocus>
</form>
</template>
<template name="selectLearningUnit">
<div class="modal fade" id="showSelectLearningUnitModal" role="dialog">
<div class="modal-dialog" aria-labelledby="showSelectLearningUnitTitle">
......@@ -148,22 +58,3 @@
</div>
</div>
</template>
<template name="btnCard">
<div id="button-row" class="col-xs-12 actionButtons editorElement">
<button id="cardSave"
class="btn btn-success btn-raised saveFirst col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="13">
{{_ "savecard"}}
</button>
<button id="cardSaveReturn"
class="btn btn-default btn-raised save col-xs-12 col-sm-4" {{disableIfOffline}}
tabindex="14">
{{_ "savecardReturn"}}
</button>
<button id="cardCancel" class="btn btn-danger btn-raised cancel col-xs-12 col-sm-3 pull-right"
tabindex="15" data-toggle="modal"
data-target="#cancelEditModal">{{_
"declinecard"}}</button>
</div>
</template>
import "./cardEditor.html";
import "../card/card.js";
import {Cardsets} from "../../../../api/cardsets";
import {Session} from "meteor/session";
import {CardType} from "../../api/cardTypes";
import {Template} from "meteor/templating";
import {Cards} from "../../api/cards";
import {Cardsets} from "../../api/cardsets";
import {CardEditor} from "../../api/cardEditor.js";
import {Route} from "../../api/route.js";
import "./learningUnit.html";
/*
* ############################################################################
......@@ -53,87 +47,3 @@ Template.selectLearningUnit.events({
$('#showSelectLearningUnitModal').modal('hide');
}
});
Template.btnCard.helpers({
isEditMode: function () {
return Route.isEditMode();
},
learningActive: function () {
return Cardsets.findOne(Router.current().params._id).learningActive;
}
});
Template.btnCard.events({
"click #cardSave": function () {
CardEditor.saveCard(Router.current().params.card_id, false);
},
"click #cardSaveReturn": function () {
CardEditor.saveCard(Router.current().params.card_id, true);
}
});
/*
* ############################################################################
* SubjectEditor
* ############################################################################
*/
Template.subjectEditor.helpers({
getSubject: function () {
if (CardType.gotLearningUnit(Session.get('cardType')) && Session.get('learningUnit') !== "0") {
let card = Cards.findOne({_id: Session.get('learningUnit')});
if (card !== undefined && card.subject !== undefined) {
return card.subject;
} else {
return "";
}
}
return Session.get('subject');
},
getSubjectPlaceholder: function () {
return CardType.getSubjectPlaceholderText(Session.get('cardType'));
},
gotLearningUnit: function () {
return CardType.gotLearningUnit(this.cardType);
}
});
Template.subjectEditor.events({
'click #subjectEditor': function () {
CardEditor.setEditorButtonIndex(0);
},
'input #subjectEditor': function () {
$('#subjectEditor').css('border', 0);
CardEditor.setEditorButtonIndex(0);
Session.set('subject', $('#subjectEditor').val());
},
'click .subjectEditorButton': function () {
Session.set('tempLearningIndex', Session.get('learningIndex'));
Session.set('tempLearningUnit', Session.get('learningUnit'));
}
});
Template.subjectEditor.rendered = function () {
Session.set('subject', $('#subjectEditor').val());
};
/*
* ############################################################################
* learningGoalLevel
* ############################################################################
*/
Template.learningGoalLevel.helpers({
isLearningGoalLevelChecked: function (learningGoalLevel) {
return learningGoalLevel <= Session.get('learningGoalLevel');
},
isLearningGoalLevel: function (learningGoalLevel) {
return learningGoalLevel === Session.get('learningGoalLevel');
}
});
Template.learningGoalLevel.events({
'click #learningGoalLevelGroup': function (event) {
CardEditor.setEditorButtonIndex(1);
Session.set('learningGoalLevel', Number($(event.target).data('lvl')));
}
});
......@@ -10,8 +10,8 @@ import "../wordcloud/wordcloud.js";
import "../impressum/impressum.js";
import "../help/help.js";
import "../filter/index/index.js";
import "../markdeepEditor/navigation/navigation.js";
import "../markdeepEditor/content/content.js";
import "../markdeep/editor/navigation/navigation.js";
import "../markdeep/editor/content/content.js";
import "../filter/index/item/cardset.js";
import "../cardTypesList/cardTypesList.js";
import "../learn/progress.js";
......@@ -20,13 +20,12 @@ import "../admin/admin.js";
import "../filter/filter.js";
import "../accessDenied/accessDenied.js";
import "../firstLogin/firstLogin.js";
import "../editor/editor.js";
import "../editor/cardEditor.js";
import "../pomodoroTimer/pomodoroTimer.js";
import "../../api/cardIndex.js";
import "./overlays/zoomText.js";
import "../card/sidebar/sidebar.js";
import "../loadingScreen/loadingScreen.js";
import "../card/editor/editor.js";
import {Route} from "../../api/route";
import {CardVisuals} from "../../api/cardVisuals";
......
import {Session} from "meteor/session";
import {CardType} from "../../../api/cardTypes";
import {CardType} from "../../../../api/cardTypes";
import {Template} from "meteor/templating";
import {CardVisuals} from "../../../api/cardVisuals";
import {CardVisuals} from "../../../../api/cardVisuals";
import "./content.html";
import {Route} from "../../../api/route";
import {isNewCardset} from "../../forms/cardsetForm";
import {Route} from "../../../../api/route";
import {isNewCardset} from "../../../forms/cardsetForm";
/*
* ############################################################################
......
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {MarkdeepEditor} from "../../../api/markdeepEditor.js";
import {MarkdeepEditor} from "../../../../api/markdeepEditor.js";
import "./navigation.html";
import {CardVisuals} from "../../../api/cardVisuals";
import {CardVisuals} from "../../../../api/cardVisuals";
/*
* ############################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment