diff --git a/home/inc/class.home_tutorial_ui.inc.php b/home/inc/class.home_tutorial_ui.inc.php
index a93ffb9cb4..86dacc5a0e 100644
--- a/home/inc/class.home_tutorial_ui.inc.php
+++ b/home/inc/class.home_tutorial_ui.inc.php
@@ -34,13 +34,38 @@ class home_tutorial_ui {
// Get tutorial object id
$tuid_indx = explode('-',$_GET['tuid']);
-
- // read tutorials json file to fetch data
- $tutorials = json_decode(self::getJsonData(), true);
-
- $content = $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]];
+ if (!is_array($content))
+ {
+ // read tutorials json file to fetch data
+ $tutorials = json_decode(self::getJsonData(), true);
+ $apps = array();
+ foreach ($tutorials as $app => $val)
+ {
+ $apps [$app] = $app;
+ }
+ $sel_options = array(
+ 'apps' => $apps,
+ );
+ $content = array (
+ 'src' => $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]['src'],
+ 'title' => $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]['title'],
+ );
+ }
- $tmpl->exec('home.home_tutorial_ui.popup', $content,array(),array(),array(),array(),2);
+ $tmpl->exec('home.home_tutorial_ui.popup', $content,$sel_options,array(),array(),array(),2);
+ }
+
+ /**
+ * Ajax function to retrive selected app's tutorials based on prefered user lang
+ *
+ * @param type $_app application name
+ */
+ function ajax_getAppsTutorials($_app)
+ {
+ $tutorials = json_decode(self::getJsonData(), true);
+ $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
+ $response = egw_json_response::get();
+ $response->data($tutorials[$_app][$lang]);
}
/**
diff --git a/home/js/app.js b/home/js/app.js
index a4630292be..74a89c5934 100644
--- a/home/js/app.js
+++ b/home/js/app.js
@@ -746,6 +746,46 @@ app.classes.home = AppJS.extend(
nm.div.toggleClass('header_hidden');
nm.set_hide_header(nm.div.hasClass('header_hidden'));
nm.resize();
+ },
+
+ /**
+ * Function to set apps and tutorials selectboxes values
+ *
+ * @param {type} egw
+ * @param {type} widget apps selectbox widget
+ */
+ tutorial_appChange: function (egw, widget) {
+ var tutorials = etemplate2.getByApplication('home')[0].widgetContainer.getWidgetById('tutorials');
+ var sel_options = {};
+ if (widget)
+ {
+ this.egw.json('home.home_tutorial_ui.ajax_getAppsTutorials', [widget.get_value()], function(_data){
+ if(_data && tutorials)
+ {
+ for (var i=0;i<_data.length;i++)
+ {
+ sel_options[i] = {label:_data[i].title, value:_data[i].src};
+ }
+ tutorials.set_select_options(sel_options);
+ }
+ }).sendRequest();
+ }
+ },
+
+ /**
+ * Function to set video iframe base on selected tutorial from
+ * tutorials selectbox
+ *
+ * @param {type} egw
+ * @param {type} widget tutorials selectbox
+ */
+ tutorial_tutorialsChange: function (egw, widget)
+ {
+ var frame = etemplate2.getByApplication('home')[0].widgetContainer.getWidgetById('src');
+ if (frame)
+ {
+ frame.set_value(widget.get_value());
+ }
}
});
diff --git a/home/templates/default/tutorial.xet b/home/templates/default/tutorial.xet
index 6d2e3c04ae..8cfbbf2352 100644
--- a/home/templates/default/tutorial.xet
+++ b/home/templates/default/tutorial.xet
@@ -7,7 +7,15 @@