2013-08-21 22:22:53 +02:00
|
|
|
/**
|
|
|
|
* EGroupware idots template javascript
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package phpgwapi
|
|
|
|
* @subpackage idots
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* idots javascript
|
|
|
|
*/
|
2014-01-16 09:27:33 +01:00
|
|
|
egw_LAB.wait(function() {
|
2014-01-16 09:56:23 +01:00
|
|
|
// add quick-add select box, but only if parent is present (not for login page!)
|
|
|
|
var quick_add = document.getElementById('quick_add');
|
|
|
|
if (quick_add) egw.link_quick_add(quick_add);
|
2013-08-21 22:22:53 +02:00
|
|
|
|
2014-03-03 18:45:18 +01:00
|
|
|
// Handle sliding menues of extra apps and sidebox
|
|
|
|
var egw_script = document.getElementById('egw_script_id');
|
|
|
|
var mouseHandler = 'click';
|
|
|
|
if (egw_script)
|
|
|
|
{
|
|
|
|
var data_slide_out = egw_script.getAttribute('data-slide-out');
|
|
|
|
mouseHandler = data_slide_out == 'mouseover'?'mouseover':'click';
|
2014-03-10 12:55:33 +01:00
|
|
|
}
|
2014-03-03 17:03:39 +01:00
|
|
|
var extra_icons_show = jQuery('#extra_icons_show');
|
2014-03-12 13:18:35 +01:00
|
|
|
if (extra_icons_show.length)
|
|
|
|
{
|
|
|
|
var menu1Container = jQuery('#menu1Container')
|
2014-03-03 17:03:39 +01:00
|
|
|
.width(180)
|
|
|
|
.offset({top:extra_icons_show.offset().top+extra_icons_show.height()});
|
2014-03-12 13:18:35 +01:00
|
|
|
//Click handler for extra apps menu
|
|
|
|
extra_icons_show.on(mouseHandler,function (event){
|
|
|
|
var extraIcon = event;
|
|
|
|
$j('html').on(mouseHandler,function(event) {
|
|
|
|
if ($j(event.target).parents('#menu1Container').length==0 && event.target !== extraIcon.target)
|
|
|
|
{
|
|
|
|
menu1Container.slideUp();
|
|
|
|
$j(this).unbind(event);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
menu1Container.slideToggle();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2014-03-03 17:03:39 +01:00
|
|
|
var menu2show = jQuery('#menu2show');
|
|
|
|
var menu2Container = jQuery('#menu2Container');
|
|
|
|
// Click handler for sidebox menu
|
2014-03-03 18:45:18 +01:00
|
|
|
menu2show.on(mouseHandler,function (event){
|
2014-03-03 17:03:39 +01:00
|
|
|
var m2showIcon = event;
|
|
|
|
var options = {
|
|
|
|
direction: "left"
|
|
|
|
};
|
|
|
|
$j('html').on('click',function(event) {
|
2014-03-10 12:55:33 +01:00
|
|
|
if (event.target !== m2showIcon.target)
|
2013-08-21 22:22:53 +02:00
|
|
|
{
|
2014-03-03 17:03:39 +01:00
|
|
|
menu2Container.toggle('slide',options);
|
|
|
|
$j(this).unbind(event);
|
2013-08-21 22:22:53 +02:00
|
|
|
}
|
2014-03-03 17:03:39 +01:00
|
|
|
});
|
|
|
|
menu2Container.toggle("slide",options);
|
2013-08-21 22:22:53 +02:00
|
|
|
}
|
2014-03-03 18:45:18 +01:00
|
|
|
);
|
2013-11-03 10:30:25 +01:00
|
|
|
|
2013-10-04 13:58:13 +02:00
|
|
|
/**
|
2013-10-05 15:33:28 +02:00
|
|
|
* Initialisation, when DOM is ready
|
2013-10-04 13:58:13 +02:00
|
|
|
*/
|
|
|
|
$j(function()
|
|
|
|
{
|
2013-10-05 15:33:28 +02:00
|
|
|
// Installing resize handler for divAppbox and et2_container, as et2 otherwise can not correctly size nextmatch
|
2013-10-04 13:58:13 +02:00
|
|
|
$j(window).resize(function(){
|
|
|
|
var appbox_height = $j(window).height()-$j('#topmenu').height()-$j('#divAppIconBar').height()-
|
|
|
|
$j('#divStatusBar').height()-$j('#divAppboxHeader').height()-$j('#divPoweredBy').height()-20;
|
|
|
|
//console.log('setting height of '+appbox_height);
|
|
|
|
$j('#divAppbox').css('min-height', appbox_height+'px');
|
2014-08-25 22:54:28 +02:00
|
|
|
$j('.et2_container').height(appbox_height-7);
|
2013-10-04 13:58:13 +02:00
|
|
|
});
|
|
|
|
$j(window).resize();
|
2013-10-05 15:33:28 +02:00
|
|
|
$j(window).load(function(){ // fixes sometimes not called resize, probably due to timing issues
|
|
|
|
$j(window).resize();
|
|
|
|
});
|
2013-11-03 10:30:25 +01:00
|
|
|
|
2013-10-05 15:33:28 +02:00
|
|
|
// allowing javascript urls in topmenu and sidebox only under CSP by binding click handlers to them
|
|
|
|
var href_regexp = /^javascript:([^\(]+)\((.*)?\);?$/;
|
2014-02-17 12:18:59 +01:00
|
|
|
jQuery('#topmenu_items,#thesideboxcolumn').on('click','a[href^="javascript:"]',function(ev){
|
|
|
|
ev.stopPropagation(); // do NOT execute regular event, as it will violate CSP, when handler does NOT return false
|
2013-10-05 15:33:28 +02:00
|
|
|
var matches = this.href.match(href_regexp);
|
2014-02-07 15:04:12 +01:00
|
|
|
var args = [];
|
|
|
|
if (matches.length > 1 && matches[2] !== undefined)
|
2013-10-05 15:33:28 +02:00
|
|
|
{
|
2014-02-19 16:11:57 +01:00
|
|
|
try {
|
|
|
|
args = JSON.parse('['+matches[2]+']');
|
|
|
|
}
|
|
|
|
catch(e) { // deal with '-encloded strings (JSON allows only ")
|
|
|
|
args = JSON.parse('['+matches[2].replace(/','/g, '","').replace(/((^|,)'|'(,|$))/g, '$2"$3')+']');
|
|
|
|
}
|
2013-10-05 15:33:28 +02:00
|
|
|
}
|
2014-02-07 15:04:12 +01:00
|
|
|
args.unshift(matches[1]);
|
2014-02-26 13:35:56 +01:00
|
|
|
et2_call.apply(this, args);
|
|
|
|
return false; // IE11 seems to require this, ev.stopPropagation() does NOT stop link from being executed
|
2013-10-05 15:33:28 +02:00
|
|
|
});
|
2013-11-03 10:30:25 +01:00
|
|
|
|
2013-10-08 14:06:07 +02:00
|
|
|
// make sidebox resizable with jQueryUI resizable
|
|
|
|
jQuery('#thesideboxcolumn').resizable({handles: 'e', minWidth: 200, stop: function(event, ui){
|
|
|
|
egw.set_preference(egw_appName, 'idotssideboxwidth', ui.size.width);
|
|
|
|
}});
|
2014-06-13 13:36:46 +02:00
|
|
|
jQuery('form[name^="tz_selection"]').children().on('change', function(){this.form.submit();});
|
2013-10-04 13:58:13 +02:00
|
|
|
});
|
2014-01-16 09:27:33 +01:00
|
|
|
});
|