Drop tutorials

This commit is contained in:
Hadi Nategh
2022-09-12 13:24:00 +02:00
parent e916dda8a6
commit f7c8c09a4b
13 changed files with 3 additions and 910 deletions

View File

@ -120,8 +120,6 @@ export abstract class EgwApp
et2_view : any;
favorite_popup : JQuery | any;
tutorial_initialised : boolean;
dom_id : string;
mailvelopeSyncHandlerObj : any;
@ -803,18 +801,7 @@ export abstract class EgwApp
*/
_init_sidebox(sidebox)
{
// Initialize egw tutorial sidebox, but only for non-popups, as calendar edit app.js has this.et2 set to tutorial et2 object
if(!this.egw.is_popup())
{
var egw_fw = egw_getFramework();
var tutorial = jQuery('#egw_tutorial_' + this.appname + '_sidebox', egw_fw ? egw_fw.sidemenuDiv : document);
// _init_sidebox gets currently called multiple times, which needs to be fixed
if(tutorial.length && !this.tutorial_initialised)
{
this.egwTutorial_init(tutorial[0]);
this.tutorial_initialised = true;
}
}
if(sidebox.length)
{
var self = this;
@ -1345,142 +1332,6 @@ export abstract class EgwApp
}
}
/**
* Get json data for videos from the given url
*
* @return {Promise, object} return Promise, json object as resolved result and error message in case of failure
*/
egwTutorialGetData()
{
var self = this;
return new Promise(function(_resolve, _reject)
{
var resolve = _resolve;
var reject = _reject;
// delay the execution and let the rendering catches up. Seems only FF problem
window.setTimeout(function()
{
self.egw.json('EGroupware\\Api\\Framework\\Tutorial::ajax_data', [self.egw.app_name()], function(_data)
{
resolve(_data);
}).sendRequest();
}, 0);
});
}
/**
* Create and Render etemplate2 for egroupware tutorial
* sidebox option. The .xet file is stored in api/templates/default/egw_tutorials
*
* @description tutorials json object should have the following structure:
* object:
* {
* [app name]:{
* [language tag]:[
* {src:"",thumbnail:"",title:"",desc:""}
* ]
* }
* }
*
* *Note: "desc" and "title" are optional attributes, which "desc" would appears as tooltip for the video.
*
* example:
* {
* "mail":{
* "en":[
* {src:"https://www.youtube.com/embed/mCDJndpjO40", thumbnail:"http://img.youtube.com/vi/mCDJndpjO40/0.jpg", "title":"PGP Encryption", "desc":""},
* {src:"https://www.youtube.com/embed/mCDJndpjO", thumbnail:"http://img.youtube.com/vi/mCDJndpjO/0.jpg", "title":"Subscription", "desc":""},
* ],
* "de":[
* {src:"https://www.youtube.com/embed/m40", thumbnail:"http://img.youtube.com/vi/m40/0.jpg", "title":"PGP Verschlüsselung", "desc":""},
* {src:"https://www.youtube.com/embed/mpjO", thumbnail:"http://img.youtube.com/vi/mpjO/0.jpg", "title":"Ordner Abonnieren", "desc":""},
* ]
* }
* }
*
* @param {DOMNode} div
*/
egwTutorial_init(div)
{
// et2 object
var etemplate = new etemplate2(div, '');
var template = egw.webserverUrl + '/api/templates/default/egw_tutorial.xet?1';
this.egwTutorialGetData().then(function(_data)
{
var lang = egw.preference('lang');
var content = {content: {list: []}};
if(_data && _data[egw.app_name()])
{
if (!_data[egw.app_name()][lang]) lang = 'en';
if(typeof _data[egw.app_name()][lang] != 'undefined'
&& _data[egw.app_name()][lang].length > 0)
{
for(var i = 0; i < _data[egw.app_name()][lang].length; i++)
{
var tuid = egw.app_name() + '-' + lang + '-' + i;
_data[egw.app_name()][lang][i]['onclick'] = 'app.' + egw.app_name() + '.egwTutorialPopup("' + tuid + '")';
}
content.content.list = _data[egw.app_name()][lang];
if(template.indexOf('.xet') > 0)
{
etemplate.load('', template, content, function() {});
}
else
{
etemplate.load(template, '', content);
}
}
}
},
function(_err)
{
console.log(_err);
});
}
/**
* Open popup to show given tutorial id
* @param {string} _tuid tutorial object id
* - tuid: appname-lang-index
*/
egwTutorialPopup(_tuid)
{
var url = egw.link('/index.php', 'menuaction=api.EGroupware\\Api\\Framework\\Tutorial.popup&tuid=' + _tuid);
egw.open_link(url, '_blank', '960x580');
}
/**
* Function to set video iframe base on selected tutorial from tutorials box
*
* @param {string} _url
*/
tutorial_videoOnClick(_url)
{
var frame = etemplate2.getByApplication('api')[0].widgetContainer.getWidgetById('src');
if(frame)
{
frame.set_value(_url);
}
}
/**
* Function calls on discard checkbox and will set
* the egw_tutorial_noautoload preference
*
* @param {type} egw
* @param {type} widget
*/
tutorial_autoloadDiscard(egw, widget)
{
if(widget)
{
this.egw.set_preference('common', 'egw_tutorial_noautoload', widget.get_value());
}
}
/**
* Check if Mailvelope is available, open (or create) "egroupware" keyring and call callback with it
*