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 @@ ...@@ -19,6 +19,20 @@
*/ */
/** /**
* @module mod_assignfeedback_editpdfplus/admin_panel * @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', define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
'core/ajax', 'core/str', 'assignfeedback_editpdfplus/tool', 'assignfeedback_editpdfplus/tooltype', 'core/ajax', 'core/str', 'assignfeedback_editpdfplus/tool', 'assignfeedback_editpdfplus/tooltype',
...@@ -30,14 +44,46 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -30,14 +44,46 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame, AnnotationHighlightplus, AnnotationStampplus, AnnotationFrame,
AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) { AnnotationCommentplus, AnnotationVerticalline, AnnotationStampcomment) {
/********************
* GLOBAL VARIABLES *
********************/
/**
* Context id
* @type {Integer}
*/
var contextid = null; var contextid = null;
/**
* Current tool in process
* @type {Tool}
*/
var currentTool = null; var currentTool = null;
/**
* Current action
* @type {String}
*/
var action = null; var action = null;
/**
* All type tools
* @type {Array<assignfeedback_edipdfplus\typetool>}
*/
var typetools = null; var typetools = null;
/**
* Current annotation in process
* @type {Annotation}
*/
var annotationcurrent = null;
/****************
* CONSTRUCTOR *
****************/
/** /**
* AdminPanel class. * AdminPanel class.
* *
* @class AdminPanel * @class AdminPanel
* @param {Integer} contextidP
* @param {String} typetoolsP
*/ */
var AdminPanel = function (contextidP, typetoolsP) { var AdminPanel = function (contextidP, typetoolsP) {
//this.registerEventListeners(); //this.registerEventListeners();
...@@ -45,18 +91,75 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -45,18 +91,75 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
this.initTypeTool(typetoolsP); this.initTypeTool(typetoolsP);
this.init(); this.init();
}; };
var annotationcurrent = null;
/**************
* Parameters *
**************/
//messages //messages
/**
* Message ok in delete case
*/
AdminPanel.messageDelOk = ""; AdminPanel.messageDelOk = "";
/**
* Message ko in delete case
*/
AdminPanel.messageDelKo = ""; AdminPanel.messageDelKo = "";
/**
* Message ko in all case
*/
AdminPanel.messageko = ""; AdminPanel.messageko = "";
/**
* Message ok in add case
*/
AdminPanel.messageaddok = ""; AdminPanel.messageaddok = "";
/**
* Message ko in add case
*/
AdminPanel.messageaddlibelleko = ""; AdminPanel.messageaddlibelleko = "";
/**
* Message ok in edit case
*/
AdminPanel.messageEditOk = ""; AdminPanel.messageEditOk = "";
//
//AdminPanel.prototype.contextid; /**
// * Current select button
* @type {Jquery node}
*/
AdminPanel.prototype.selectTool = null; 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) { AdminPanel.prototype.initTypeTool = function (typeToolsP) {
var typetoolsTmp = JSON.parse(typeToolsP); var typetoolsTmp = JSON.parse(typeToolsP);
typetools = []; typetools = [];
...@@ -66,7 +169,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -66,7 +169,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
typetools[i] = typeToolTmp; typetools[i] = typeToolTmp;
} }
}; };
//
/**
* Init IHM
*/
AdminPanel.prototype.init = function () { AdminPanel.prototype.init = function () {
$("#editpdlplus_axes").on("change", function () { $("#editpdlplus_axes").on("change", function () {
$(".toolbar").hide(); $(".toolbar").hide();
...@@ -91,7 +197,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -91,7 +197,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$('#toolworkspace').html(""); $('#toolworkspace').html("");
}); });
$("#editpdlplus_axes").change(); $("#editpdlplus_axes").change();
//
$(".editpdlplus_tool").on("click", refreshToolView); $(".editpdlplus_tool").on("click", refreshToolView);
this.selectTool = $(".editpdlplus_tool").first(); this.selectTool = $(".editpdlplus_tool").first();
this.initToolUI(); this.initToolUI();
...@@ -106,38 +212,18 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -106,38 +212,18 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
initMessages(); initMessages();
}; };
//init message
var initMessages = function () { /**
str.get_string('admindeltool_messageok', 'assignfeedback_editpdfplus').done(function (message) { * Init too UI for select element
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();
};
//
AdminPanel.prototype.initToolUI = function () { AdminPanel.prototype.initToolUI = function () {
$(this.selectTool).removeClass("btn-default"); $(this.selectTool).removeClass("btn-default");
$(this.selectTool).addClass("btn-primary"); $(this.selectTool).addClass("btn-primary");
}; };
//
/**
* Init tool form and preview
*/
AdminPanel.prototype.refreshPrevisu = function () { AdminPanel.prototype.refreshPrevisu = function () {
currentTool.typetool = $("#typetool").val(); currentTool.typetool = $("#typetool").val();
currentTool.colors = $("#color").val(); currentTool.colors = $("#color").val();
...@@ -163,7 +249,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -163,7 +249,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
initCanevas(); initCanevas();
initToolDisplay(); initToolDisplay();
}; };
//
/**
* Get type tool object from an id
* @param {Integer} toolid
* @return {Typetool}
*/
var getTypeTool = function (toolid) { var getTypeTool = function (toolid) {
for (var i = 0; i < typetools.length; i++) { for (var i = 0; i < typetools.length; i++) {
if (typetools[i].id == toolid) { if (typetools[i].id == toolid) {
...@@ -171,6 +262,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -171,6 +262,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
} }
} }
}; };
/**
* Init tool form display with custom configurable parameters
*/
var initToolDisplay = function () { var initToolDisplay = function () {
var typetool = parseInt($("#typetool").val()); var typetool = parseInt($("#typetool").val());
var typetoolEntity = getTypeTool(typetool); var typetoolEntity = getTypeTool(typetool);
...@@ -230,7 +325,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -230,7 +325,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#collapse4").parent().show(); $("#collapse4").parent().show();
} }
}; };
//
/**
* Init tool preview
*/
var initCanevas = function () { var initCanevas = function () {
$('#canevas').html(""); $('#canevas').html("");
annotationcurrent = null; annotationcurrent = null;
...@@ -271,7 +369,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -271,7 +369,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
} }
} }
}; };
//
/**
* Load content for adding an axis
*/
AdminPanel.prototype.openDivAddAxis = function () { AdminPanel.prototype.openDivAddAxis = function () {
var selectAxis = $("#editpdlplus_axes").val(); var selectAxis = $("#editpdlplus_axes").val();
if (selectAxis && selectAxis !== "") { if (selectAxis && selectAxis !== "") {
...@@ -293,7 +394,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -293,7 +394,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
html, js); html, js);
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
//
/**
* Load content for editing an axis
*/
AdminPanel.prototype.openDivEditAxis = function () { AdminPanel.prototype.openDivEditAxis = function () {
$("#message_edit_tool").hide(); $("#message_edit_tool").hide();
$("#axistool").hide(); $("#axistool").hide();
...@@ -302,15 +406,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -302,15 +406,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$('#assignfeedback_editpdfplus_widget_admin_toolheader').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
$('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide(); $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
$("#editpdlplus_axes").prop('disabled', 'disabled'); $("#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 axeid = $("#editpdlplus_axes option:selected").val();
var params = {axeid: axeid}; var params = {axeid: axeid};
fragment.loadFragment('assignfeedback_editpdfplus', 'axisedit', contextid, params) fragment.loadFragment('assignfeedback_editpdfplus', 'axisedit', contextid, params)
...@@ -319,7 +414,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -319,7 +414,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
html, js); html, js);
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
//
/**
* Load content for deleting an axis
*/
AdminPanel.prototype.openDivDelAxis = function () { AdminPanel.prototype.openDivDelAxis = function () {
var canBeDelete = $("#editpdlplus_axes option:selected").data('delete'); var canBeDelete = $("#editpdlplus_axes option:selected").data('delete');
if (canBeDelete !== null && parseInt(canBeDelete) === 0) { if (canBeDelete !== null && parseInt(canBeDelete) === 0) {
...@@ -339,11 +437,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -339,11 +437,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
} }
}; };
/** /**
* Fade the dom node out, update it, and fade it back. * Fade the dom node out, update it, and fade it back.
* *
* @private * @private
* @method _hello * @method fillResultAjax
* @param {JQuery} node * @param {JQuery} node
* @param {String} html * @param {String} html
* @param {String} js * @param {String} js
...@@ -358,9 +457,11 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -358,9 +457,11 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}); });
}); });
return promise.promise(); return promise.promise();
//return true;
}; };
//
/**
* Import an axis to the current's user's toolbar
*/
AdminPanel.prototype.importAxis = function () { AdminPanel.prototype.importAxis = function () {
var axisimportid = $(this).data('axis'); var axisimportid = $(this).data('axis');
if (axisimportid && parseInt(axisimportid) > 0) { if (axisimportid && parseInt(axisimportid) > 0) {
...@@ -381,7 +482,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -381,7 +482,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_import_axis").removeClass("alert-danger"); $("#message_import_axis").removeClass("alert-danger");
$("#message_import_axis").removeClass("alert-warning"); $("#message_import_axis").removeClass("alert-warning");
$("#message_import_axis").fadeOut(5000); $("#message_import_axis").fadeOut(5000);
//maj axe //maj axis
var divAxis = "<div id='editpdlplus_toolbar_" var divAxis = "<div id='editpdlplus_toolbar_"
+ toolbar[0].axeid + toolbar[0].axeid
+ "' class='btn-group toolbar' style='display: none;'></div>"; + "' class='btn-group toolbar' style='display: none;'></div>";
...@@ -426,7 +527,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -426,7 +527,10 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}).fail(notification.exception); }).fail(notification.exception);
} }
}; };
//
/**
* Refresh tool view, preview and form for editing
*/
var refreshToolView = function () { var refreshToolView = function () {
var selectid = $(this).val(); var selectid = $(this).val();
$(".editpdlplus_tool").each(function () { $(".editpdlplus_tool").each(function () {
...@@ -449,7 +553,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -449,7 +553,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
//load proprieties //load proprieties
$('#editpdlplus_tool_item').html(""); $('#editpdlplus_tool_item').html("");
var params = {toolid: selectid}; var params = {toolid: selectid};
//this.test();
fragment.loadFragment('assignfeedback_editpdfplus', 'tooledit', contextid, params) fragment.loadFragment('assignfeedback_editpdfplus', 'tooledit', contextid, params)
.done(function (html, js) { .done(function (html, js) {
fillResultAjax($('#editpdlplus_tool_item'), html, js) fillResultAjax($('#editpdlplus_tool_item'), html, js)
...@@ -516,7 +619,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -516,7 +619,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#message_edit_tool").removeClass("alert-warning"); $("#message_edit_tool").removeClass("alert-warning");
//mise à jour bar d'outils //mise à jour bar d'outils
$("#editpdlplus_toolbar_" + toolbar[0].axeid).html(""); $("#editpdlplus_toolbar_" + toolbar[0].axeid).html("");
//var newtool = null;
for (var i = 0; i < toolbar.length; i++) { for (var i = 0; i < toolbar.length; i++) {
var toolTmp = new Tool(); var toolTmp = new Tool();
toolTmp.initAdmin(toolbar[i]); toolTmp.initAdmin(toolbar[i]);
...@@ -524,9 +626,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -524,9 +626,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
$("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp); $("#editpdlplus_toolbar_" + toolbar[0].axeid).append(buttonTmp);
} }
$(".editpdlplus_tool").on("click", refreshToolView); $(".editpdlplus_tool").on("click", refreshToolView);
//AdminPanel.prototype.refreshPrevisu();
$("#editpdlplus_tool_" + toolbar[0].selecttool).click(); $("#editpdlplus_tool_" + toolbar[0].selecttool).click();
//refreshToolView();
} else { } else {
$("#message_edit_tool").show(); $("#message_edit_tool").show();
$("#message_edit_tool").html(toolbar[0].message); $("#message_edit_tool").html(toolbar[0].message);
...@@ -604,12 +704,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -604,12 +704,12 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
//maj tool worspkace //maj tool worspkace
initToolDisplay(); initToolDisplay();
}.bind(this)).fail(notification.exception); }.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); }.bind(this)).fail(notification.exception);
}; };
//
/**
* Load content for adding a tool
*/
AdminPanel.prototype.openDivAddTool = function () { AdminPanel.prototype.openDivAddTool = function () {
$("#message_edit_tool").hide(); $("#message_edit_tool").hide();
$('#editpdlplus_tool_item').html(""); $('#editpdlplus_tool_item').html("");
...@@ -709,5 +809,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment', ...@@ -709,5 +809,6 @@ define(['jquery', 'core/notification', 'core/templates', 'core/fragment',
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
return AdminPanel; return AdminPanel;
}); });
\ No newline at end of file
...@@ -19,9 +19,16 @@ ...@@ -19,9 +19,16 @@
*/ */
/** /**
* @module mod_assignfeedback_editpdfplus/annotation * @module mod_assignfeedback_editpdfplus/annotation
* @param {Jquery} $
* @param {Global} global constantes
*/ */
define(['jquery', './global'], define(['jquery', './global'],
function ($, global) { function ($, global) {
/********************************
* CONSTRUCTOR and SUPER-CLASS *
********************************/
// I am the internal, static counter for the number of models // I am the internal, static counter for the number of models
// that have been created in the system. This is used to // that have been created in the system. This is used to
// power the unique identifier of each instance. // power the unique identifier of each instance.
...@@ -54,8 +61,11 @@ define(['jquery', './global'], ...@@ -54,8 +61,11 @@ define(['jquery', './global'],
Annotation.prototype.getInstanceID = function () { Annotation.prototype.getInstanceID = function () {
return(this._instanceID); return(this._instanceID);
}; };
/*var Annotation = function () {
};*/ /**************
* Parameters *
**************/
/** /**
* X position * X position
* @property x * @property x
...@@ -133,7 +143,22 @@ define(['jquery', './global'], ...@@ -133,7 +143,22 @@ define(['jquery', './global'],
* @public * @public
*/ */
Annotation.cartridgey = 0; Annotation.cartridgey = 0;
/**
* mode readonly demo or not
* @property adminDemo
* @type Boolean
* @public
*/
Annotation.adminDemo = 0; 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) { Annotation.prototype.init = function (config) {
this.cartridgex = parseInt(config.cartridgex, 10) || 0; this.cartridgex = parseInt(config.cartridgex, 10) || 0;
this.cartridgey = parseInt(config.cartridgey, 10) || 0; this.cartridgey = parseInt(config.cartridgey, 10) || 0;
...@@ -148,6 +173,10 @@ define(['jquery', './global'], ...@@ -148,6 +173,10 @@ define(['jquery', './global'],
this.toolid = config.toolid; this.toolid = config.toolid;
}; };
/**
* Initialize tooltype object from an object from database
* @param {Tool} currentTool
*/
Annotation.prototype.initAdminDemo = function (currentTool) { Annotation.prototype.initAdminDemo = function (currentTool) {
this.id = 'previsu_annot'; this.id = 'previsu_annot';
this.displaylock = 1; this.displaylock = 1;
...@@ -155,19 +184,18 @@ define(['jquery', './global'], ...@@ -155,19 +184,18 @@ define(['jquery', './global'],
this.tooltype = currentTool;