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

@@ -568,18 +568,6 @@ export const AppJS = (function(){ "use strict"; return Class.extend(
*/
_init_sidebox: function(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;
@@ -1185,137 +1173,6 @@ export const AppJS = (function(){ "use strict"; return Class.extend(
}
},
/**
* 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: function(){
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: function(div)
{
// et2 object
var etemplate = new etemplate2 (div, false);
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: function (_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: function (_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: function (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
*

View File

@@ -434,37 +434,6 @@ window.app = {classes: {}};
window.scrollTo(0, 1);
}
try {
// Open tutorial popup with an introduction video about egroupware
if (window.framework === window.top.framework && typeof Et2Dialog != 'undefined' &&
!egw.preference('egw_tutorial_noautoload', 'common') &&
!parseInt(egw_script.getAttribute('data-framework-reload')) &&
(!egw.config('egw_tutorial_disable', 'phpgwapi') || egw.config('egw_tutorial_disable', 'phpgwapi') == 'sidebox'))
{
// we need to wait until common translations are loaded
egw.langRequireApp(window, 'common', function ()
{
var buttons = [
{label: egw.lang("Show now"), id: "show", image: "check", default: "true"},
{label: egw.lang("Show next login"), id: "later", image: "right"},
{label: egw.lang("No thanks"), id: "never", image: "cancel"}
];
Et2Dialog.show_dialog(function (_button_id)
{
if (_button_id == "show")
{
egw.open_link(egw.link('/index.php', 'menuaction=api.EGroupware\\Api\\Framework\\Tutorial.popup&tuid=introduction-' + egw.preference('lang') + '-0-a'), '_blank', '960x580');
}
if (_button_id != "later")
{
egw.set_preference('common', 'egw_tutorial_noautoload', true);
}
},
egw.lang('We would like to introduce you to EGroupware by showing a short introduction video.'),
egw.lang('Introduction'),
{}, buttons, Et2Dialog.QUESTION_MESSAGE, undefined, egw(window));
}, this);
}
// open websocket to push server for our top window
if (egw === window.top.egw && egw_script.getAttribute('data-websocket-url'))
{

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
*