From 970fef9b3a289b8d408199543ffa8b0cabe1d72d Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 30 May 2014 13:28:11 +0000 Subject: [PATCH] Add app.js to preferences --- preferences/js/app.js | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 preferences/js/app.js diff --git a/preferences/js/app.js b/preferences/js/app.js new file mode 100644 index 0000000000..e9e81836dd --- /dev/null +++ b/preferences/js/app.js @@ -0,0 +1,104 @@ +/** + * EGroupware - Preferences - Javascript UI + * + * @link http://www.egroupware.org + * @package preferences + * @author Hadi Nategh + * @copyright (c) 2008-13 by Ralf Becker + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id: app.js 47099 2014-05-27 13:36:40Z hnategh $ + */ + +/** + * UI for Preferences + * + * @augments AppJS + */ +app.classes.preferences = AppJS.extend( +{ + appname: 'preferences', + + /** + * Constructor + * + * @memberOf app.preferences + */ + init: function() + { + // call parent + this._super.apply(this, arguments); + }, + + /** + * Destructor + */ + destroy: function() + { + // call parent + this._super.apply(this, arguments); + }, + + /** + * This function is called when the etemplate2 object is loaded + * and ready. If you must store a reference to the et2 object, + * make sure to clean it up in destroy(). + * + * @param {etemplate2} _et2 newly ready object + * @param {string} _name template name + */ + et2_ready: function(_et2, _name) + { + // call parent + this._super.apply(this, arguments); + + var app = this.et2.getWidgetById('appname'); + switch (app.get_value()) + { + case 'calendar': + var defAlarmWidgets = ['default-alarm', 'default-alarm-wholeday']; + for(var key in defAlarmWidgets) + { + this.def_alarm_onchange(null, this.et2.getWidgetById(defAlarmWidgets[key])); + } + break; + } + }, + + /** + * Set/Unset Calendar custom-default-alarm for regular and wholeday event preferences + * + * @param {object} _egw + * @param {widget object} _widget + * @todo options need to be implemented in preferences to be able to set options for widget, + * then node.options should be removed from here and set by template. + */ + cal_def_alarm_onchange: function (_egw,_widget) + { + var node = {}; + if (typeof _widget != 'undefined' && _widget != null) + { + switch (_widget.id) + { + case 'default-alarm': + node = this.et2.getWidgetById('custom-default-alarm'); + break; + case 'default-alarm-wholeday': + node = this.et2.getWidgetById('custom-default-alarm-wholeday'); + } + if (typeof node != 'undefined' && node != null) + { + node.options.display_format = 'dhm'; + node.options.hours_per_day = 24; + node.set_value(node.options.value); + if (_widget.get_value() == -1) + { + jQuery(node.getParent().parentNode.parentNode).show(); + } + else + { + jQuery(node.getParent().parentNode.parentNode).hide(); + } + } + } + } +}); \ No newline at end of file