Gitlab CSE Unil

Commit b915f0e8 authored by M. Chardon's avatar M. Chardon
Browse files

documentation php et javascript

parent 185d8614
This diff is collapsed.
......@@ -19,6 +19,20 @@
*/
/**
* @module mod_assignfeedback_editpdfplus/admin_panel
* @param {Jquery} $
* @param {core/notification} notification
* @param {core/templates} templates
* @param {core/fragment} fragment
* @param {core/ajax} ajax
* @param {core/str} str
* @param {assignfeedback_editpdfplus/tool} Tool
* @param {assignfeedback_editpdfplus/tooltype} ToolType
* @param {assignfeedback_editpdfplus/annotationhighlightplus} AnnotationHighlightplus
* @param {assignfeedback_editpdfplus/annotationstampplus} AnnotationStampplus
* @param {assignfeedback_editpdfplus/annotationframe} AnnotationFrame
* @param {assignfeedback_editpdfplus/annotationcommentplus} AnnotationCommentplus
* @param {assignfeedback_editpdfplus/annotationverticalline} AnnotationVerticalline
* @param {assignfeedback_editpdfplus/annotationstampcomment} AnnotationStampcomment
*/
define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
'core/ajax', 'core/str', 'assignfeedback_editpdfplus/tool', 'assignfeedback_editpdfplus/tooltype',
......@@ -30,14 +44,46 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame,
AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) {
/********************
* GLOBAL VARIABLES *
********************/
/**
* Context id
* @type {Integer}
*/
var contextid = null;
/**
* Current tool in process
* @type {Tool}
*/
var currentTool = null;
/**
* Current action
* @type {String}
*/
var action = null;
/**
* All type tools
* @type {Array<assignfeedback_edipdfplus\typetool>}
*/
var typetools = null;
/**
* Current annotation in process
* @type {Annotation}
*/
var annotationcurrent = null;
/****************
* CONSTRUCTOR *
****************/
/**
* AdminPanel class.
*
* @class AdminPanel
* @param {Integer} contextidP
* @param {String} typetoolsP
*/
var AdminPanel = function (contextidP, typetoolsP) {
//this.registerEventListeners();
......@@ -45,18 +91,75 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
this.initTypeTool(typetoolsP);
this.init();
};
var annotationcurrent = null;
/**************
* Parameters *
**************/
//messages
/**
* Message ok in delete case
*/
AdminPanel.messageDelOk = "";
/**
* Message ko in delete case
*/
AdminPanel.messageDelKo = "";
/**
* Message ko in all case
*/
AdminPanel.messageko = "";
/**
* Message ok in add case
*/
AdminPanel.messageaddok = "";
/**
* Message ko in add case
*/
AdminPanel.messageaddlibelleko = "";
/**
* Message ok in edit case
*/
AdminPanel.messageEditOk = "";
//
//AdminPanel.prototype.contextid;
//
/**
* Current select button
* @type {Jquery node}
*/
AdminPanel.prototype.selectTool = null;
/*************
* FUNCTIONS *
*************/
/**
* Initalisation of all messages with ajax
*/
var initMessages = function () {
str.get_string('admindeltool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageDelOk = message;
}).fail(notification.exception);
str.get_string('admindeltool_messageko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageDelKo = message;
}).fail(notification.exception);
str.get_string('adminaddtool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageaddok = message;
}).fail(notification.exception);
str.get_string('admin_messageko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageko = message;
}).fail(notification.exception);
str.get_string('adminedittool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageEditOk = message;
}).fail(notification.exception);
str.get_string('adminaddtool_messagelibelleko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageaddlibelleko = message;
}).fail(notification.exception);
};
/**
* Set typetool list from json request
* @param {object} typeToolsP
*/
AdminPanel.prototype.initTypeTool = function (typeToolsP) {
var typetoolsTmp = JSON.parse(typeToolsP);
typetools = [];
......@@ -66,7 +169,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
typetools[i] = typeToolTmp;
}
};
//
/**
* Init IHM
*/
AdminPanel.prototype.init = function () {
$("#editpdlplus_axes").on("change", function () {
$(".toolbar").hide();
......@@ -91,7 +197,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$('#toolworkspace').html("");
});
$("#editpdlplus_axes").change();
//
$(".editpdlplus_tool").on("click", refreshToolView);
this.selectTool = $(".editpdlplus_tool").first();
this.initToolUI();
......@@ -106,38 +212,18 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
initMessages();
};
//init message
var initMessages = function () {
str.get_string('admindeltool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageDelOk = message;
}).fail(notification.exception);
str.get_string('admindeltool_messageko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageDelKo = message;
}).fail(notification.exception);
str.get_string('adminaddtool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageaddok = message;
}).fail(notification.exception);
str.get_string('admin_messageko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageko = message;
}).fail(notification.exception);
str.get_string('adminedittool_messageok', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageEditOk = message;
}).fail(notification.exception);
str.get_string('adminaddtool_messagelibelleko', 'assignfeedback_editpdfplus').done(function (message) {
AdminPanel.messageaddlibelleko = message;
}).fail(notification.exception);
};
//
AdminPanel.prototype.test = function () {
alert("test");
refreshToolView();
};
//
/**
* Init too UI for select element
*/
AdminPanel.prototype.initToolUI = function () {
$(this.selectTool).removeClass("btn-default");
$(this.selectTool).addClass("btn-primary");
};
//
/**
* Init tool form and preview
*/
AdminPanel.prototype.refreshPrevisu = function () {
currentTool.typetool = $("#typetool").val();
currentTool.colors = $("#color").val();
......@@ -163,7 +249,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
initCanevas();
initToolDisplay();
};
//
/**
* Get type tool object from an id
* @param {Integer} toolid
* @return {Typetool}
*/
var getTypeTool = function (toolid) {
for (var i = 0; i < typetools.length; i++) {
if (typetools[i].id == toolid) {
......@@ -171,6 +262,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}
}
};
/**
* Init tool form display with custom configurable parameters
*/
var initToolDisplay = function () {
var typetool = parseInt($("#typetool").val());
var typetoolEntity = getTypeTool(typetool);
......@@ -230,7 +325,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#collapse4").parent().show();
}
};
//
/**
* Init tool preview
*/
var initCanevas = function () {
$('#canevas').html("");
annotationcurrent = null;
......@@ -271,7 +369,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}
}
};
//
/**
* Load content for adding an axis
*/
AdminPanel.prototype.openDivAddAxis = function () {
var selectAxis = $("#editpdlplus_axes").val();
if (selectAxis && selectAxis !== "") {
......@@ -293,7 +394,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
html, js);
}.bind(this)).fail(notification.exception);
};
//
/**
* Load content for editing an axis
*/
AdminPanel.prototype.openDivEditAxis = function () {
$("#message_edit_tool").hide();
$("#axistool").hide();
......@@ -302,15 +406,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled');
/*var context = {name: 'Tweety bird', intelligence: 2};
templates.render('assignfeedback_editpdfplus/admin_axis_add', context)
// It returns a promise that needs to be resoved.
.then(function (html, js) {
// Here eventually I have my compiled template, and any javascript that it generated.
// The templates object has append, prepend and replace functions.
templates.appendNodeContents('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body',
html, js);
}).fail(notification.exception);*/
var axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisedit', contextid, params)
......@@ -319,7 +414,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
html, js);
}.bind(this)).fail(notification.exception);
};
//
/**
* Load content for deleting an axis
*/
AdminPanel.prototype.openDivDelAxis = function () {
var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
if (canBeDelete !== null && parseInt(canBeDelete) === 0) {
......@@ -339,11 +437,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}.bind(this)).fail(notification.exception);
}
};
/**
* Fade the dom node out, update it, and fade it back.
*
* @private
* @method _hello
* @method fillResultAjax
* @param {JQuery} node
* @param {String} html
* @param {String} js
......@@ -358,9 +457,11 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
});
});
return promise.promise();
//return true;
};
//
/**
* Import an axis to the current's user's toolbar
*/
AdminPanel.prototype.importAxis = function () {
var axisimportid = $(this).data('axis');
if (axisimportid && parseInt(axisimportid) > 0) {
......@@ -381,7 +482,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_import_axis").removeClass("alert-danger");
$("#message_import_axis").removeClass("alert-warning");
$("#message_import_axis").fadeOut(5000);
//maj axe
//maj axis
var divAxis = "<div id='editpdlplus_toolbar_"
+ toolbar[0].axeid
+ "' class='btn-group toolbar' style='display: none;'></div>";
......@@ -426,7 +527,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}).fail(notification.exception);
}
};
//
/**
* Refresh tool view, preview and form for editing
*/
var refreshToolView = function () {
var selectid = $(this).val();
$(".editpdlplus_tool").each(function () {
......@@ -449,7 +553,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
//load proprieties
$('#editpdlplus_tool_item').html("");
var params = {toolid: selectid};
//this.test();
fragment.loadFragment('assignfeedback_editpdfplus', 'tooledit', contextid, params)
.done(function (html, js) {
fillResultAjax($('#editpdlplus_tool_item'), html, js)
......@@ -516,7 +619,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_edit_tool").removeClass("alert-warning");
//mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
//var newtool = null;
for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]);
......@@ -524,9 +626,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
}
$(".editpdlplus_tool").on("click", refreshToolView);
//AdminPanel.prototype.refreshPrevisu();
$("#editpdlplus_tool_" + toolbar[0].selecttool).click();
//refreshToolView();
} else {
$("#message_edit_tool").show();
$("#message_edit_tool").html(toolbar[0].message);
......@@ -604,12 +704,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
//maj tool worspkace
initToolDisplay();
}.bind(this)).fail(notification.exception);
//templates.appendNodeContents('#editpdlplus_tool_item', html, js).done(function () {
//$(".editpdlplus_tool").on("click", this.refreshToolView);
//}.bind(this))/*.fail(notification.exception)*/;
}.bind(this)).fail(notification.exception);
};
//
/**
* Load content for adding a tool
*/
AdminPanel.prototype.openDivAddTool = function () {
$("#message_edit_tool").hide();
$('#editpdlplus_tool_item').html("");
......@@ -709,5 +809,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}.bind(this)).fail(notification.exception);
}.bind(this)).fail(notification.exception);
};
return AdminPanel;
});
\ No newline at end of file
......@@ -19,9 +19,16 @@
*/
/**
* @module mod_assignfeedback_editpdfplus/annotation
* @param {Jquery} $
* @param {Global} global constantes
*/
define(['jquery', './global'],
function ($, global) {
/********************************
* CONSTRUCTOR and SUPER-CLASS *
********************************/
// I am the internal, static counter for the number of models
// that have been created in the system. This is used to
// power the unique identifier of each instance.
......@@ -54,8 +61,11 @@ define(['jquery', './global'],
Annotation.prototype.getInstanceID = function () {
return(this._instanceID);
};
/*var Annotation = function () {
};*/
/**************
* Parameters *
**************/
/**
* X position
* @property x
......@@ -133,7 +143,22 @@ define(['jquery', './global'],
* @public
*/
Annotation.cartridgey = 0;
/**
* mode readonly demo or not
* @property adminDemo
* @type Boolean
* @public
*/
Annotation.adminDemo = 0;
/*************
* FUNCTIONS *
*************/
/**
* Initialize tooltype object from an object from database with its base's id
* @param {object} config
*/
Annotation.prototype.init = function (config) {
this.cartridgex = parseInt(config.cartridgex, 10) || 0;
this.cartridgey = parseInt(config.cartridgey, 10) || 0;
......@@ -148,6 +173,10 @@ define(['jquery', './global'],
this.toolid = config.toolid;
};
/**
* Initialize tooltype object from an object from database
* @param {Tool} currentTool
*/
Annotation.prototype.initAdminDemo = function (currentTool) {
this.id = 'previsu_annot';
this.displaylock = 1;
......@@ -155,19 +184,18 @@ define(['jquery', './global'],
this.tooltype = currentTool;
this.colour = currentTool.get_color();
};
/**
* Draw an annotation
* @public
* @method draw
* @return M.assignfeedback_editpdfplus.drawable|false
* Draw an annotation - super class
* @returns {Annotation} this annotation
*/
Annotation.prototype.draw = function () {
// Should be overridden by the subclass.
};
/**
* Get the final color for the annotation
* @return string
* @protected
*/
Annotation.prototype.get_color = function () {
var color = global.ANNOTATIONCOLOUR[this.colour];
......@@ -180,10 +208,10 @@ define(['jquery', './global'],
}
return color;
};
/**
* Get the final color for the cartridge
* @return string
* @protected
*/
Annotation.prototype.get_color_cartridge = function () {
var color = global.ANNOTATIONCOLOUR[this.tooltype.get_color_cartridge()];
......@@ -196,9 +224,9 @@ define(['jquery', './global'],
}
return color;
};
/**
* Init the HTML id for the annotation
* @protected
* Init the HTML id for the cartridge's annotation
*/
Annotation.prototype.init_div_cartridge_id = function () {
var date = (new Date().toJSON()).replace(/:/g, '').replace(/\./g, '');
......@@ -208,10 +236,12 @@ define(['jquery', './global'],
this.divcartridge = 'ct_' + this.id + '_' + date;
}
};
/**
* get the html node for the cartridge
* @param {string} colorcartridge
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_div_cartridge = function (colorcartridge, canevas) {
var div = "<div ";
......@@ -230,11 +260,12 @@ define(['jquery', './global'],
}
return divdisplay;
};
/**
* get the html node for the label cartridge
* @param {string} colorcartridge
* @param {boolean} draggable
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_div_cartridge_label = function (colorcartridge, canevas/*, draggable*/) {
var divcartridge = "<div ";
......@@ -258,10 +289,12 @@ define(['jquery', './global'],
}*/
return divcartridgedisplay;
};
/**
* get the html node for the textannot associated to the annotation
* @param {string} colorcartridge
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_div_input = function (colorcartridge, canevas) {
var divinput = "<div ";
......@@ -278,9 +311,11 @@ define(['jquery', './global'],
//}
return divinputdisplay;
};
/**
* get the html node for the edition of comment and parameters
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_div_edition = function (canevas) {
var divedition = "<div ";
......@@ -327,10 +362,12 @@ define(['jquery', './global'],
}
return diveditiondisplay;
};
/**
* get the html node for the text annotation, tools and options
* @param {string} colorcartridge
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_div_container = function (colorcartridge, canevas) {
var divconteneur = "<div ";
......@@ -368,6 +405,7 @@ define(['jquery', './global'],
return divconteneurdisplay;
};
/**
* get the html node for the hidden input to keep information about question state
* @return node
......@@ -379,9 +417,11 @@ define(['jquery', './global'],
}
return "<input type='hidden' id='" + this.divcartridge + "_question' value='" + qst + "'/>";
};
/**
* get the html node for the button to set visibility on right
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_button_visibility_right = function (canevas) {
var buttonvisibility = "<button id='"
......@@ -402,9 +442,11 @@ define(['jquery', './global'],
}
return buttonvisibilitydisplay;
};
/**
* get the html node for the button to set visibility on left
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_button_visibility_left = function (canevas) {
var buttonvisibility = "<button id='"
......@@ -428,7 +470,8 @@ define(['jquery', './global'],
/**
* get the html node for the button to save the text in the annotation
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_button_save = function (canevas) {
var buttonsave = "<button id='"
......@@ -451,7 +494,8 @@ define(['jquery', './global'],
};
/**
* get the html node for the button to cancel the text edition of the annotation
* @return node
* @param {JQuery Entity} canevas
* @return {JQuery Entity} node
*/
Annotation.prototype.get_button_cancel = function (canevas) {
var buttoncancel = "<button id='"
......@@ -475,7 +519,8 @@ define(['jquery', './global'],
/**