2014-12-09 15:25:52 +01:00
|
|
|
/**
|
2021-06-08 14:11:59 +02:00
|
|
|
* EGroupware Pixelegg template
|
2014-12-09 15:25:52 +01:00
|
|
|
*
|
|
|
|
* @package framework
|
|
|
|
* @author Hadi Nategh <hn@stylite.de>
|
|
|
|
* @author Andreas Stoeckel <as@stylite.de>
|
2021-06-08 14:11:59 +02:00
|
|
|
* @copyright EGroupware GmbH 2014-2021
|
|
|
|
* @description Create Pixelegg framework
|
2014-12-09 15:25:52 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*egw:uses
|
2016-06-06 17:38:20 +02:00
|
|
|
/vendor/bower-asset/jquery/dist/jquery.js;
|
2014-12-09 15:25:52 +01:00
|
|
|
framework.fw_desktop;
|
2016-03-01 21:45:31 +01:00
|
|
|
/pixelegg/js/slider.js;
|
2014-12-09 15:25:52 +01:00
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
import '../../api/js/framework/fw_desktop.js';
|
|
|
|
import './slider.js';
|
|
|
|
|
2014-12-09 15:25:52 +01:00
|
|
|
(function(window){
|
2016-03-01 21:45:31 +01:00
|
|
|
"use strict";
|
|
|
|
|
2014-12-09 15:25:52 +01:00
|
|
|
/**
|
2021-06-08 14:11:59 +02:00
|
|
|
* jdots framework object definition
|
2014-12-09 15:25:52 +01:00
|
|
|
* here we can add framework methods and also override fw_desktop methods if it is neccessary
|
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
window.fw_pixelegg = fw_desktop.extend(
|
2014-12-09 15:25:52 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Callback to calculate height of browser iframe or div
|
|
|
|
*
|
|
|
|
* @param {object} _iframe dom node of iframe or null for div
|
|
|
|
* @returns number in pixel
|
|
|
|
*/
|
|
|
|
getIFrameHeight: function(_iframe)
|
|
|
|
{
|
|
|
|
var height = this._super.apply(this, arguments);
|
|
|
|
|
2019-05-24 16:11:30 +02:00
|
|
|
return height;
|
2019-08-06 02:13:06 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if the tab header will overflow and want to wrap.
|
|
|
|
* Deal with it by setting some smaller widths on the tabs.
|
|
|
|
*/
|
|
|
|
checkTabOverflow: function()
|
|
|
|
{
|
|
|
|
var topmenuWidth = jQuery('#egw_fw_topmenu_info_items').outerWidth();
|
|
|
|
var width = 0;
|
|
|
|
var counter = 0;
|
|
|
|
var marginR = parseInt(jQuery("#egw_fw_main").css('margin-right'));
|
|
|
|
jQuery(this.tabsUi.contHeaderDiv).css('padding-right',topmenuWidth - marginR);
|
|
|
|
var outer_width = jQuery(this.tabsUi.contHeaderDiv).width();
|
|
|
|
var spans = jQuery(this.tabsUi.contHeaderDiv).children('span');
|
|
|
|
spans.css('max-width','');
|
|
|
|
spans.each(function() {
|
|
|
|
// Do not count and add up node if the width is not set (e.g. status app)
|
|
|
|
if (this.clientWidth > 0)
|
|
|
|
{
|
|
|
|
width += jQuery(this).outerWidth(true);
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(width > outer_width)
|
|
|
|
{
|
|
|
|
var max_width = Math.floor(outer_width / counter) - (spans.outerWidth(true) - spans.width());
|
|
|
|
spans.css('max-width', max_width + 'px');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs after et2 is loaded
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
et2_loadingFinished: function() {
|
|
|
|
this._super.apply(this, arguments);
|
2021-04-19 10:17:40 +02:00
|
|
|
framework.firstload_animation('', 100);
|
2019-12-02 14:09:45 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a notification message for topmenu info item
|
|
|
|
*
|
|
|
|
* @param {string} _id id of topmenu info item with its prefix
|
|
|
|
* @param {string} _message message that should be displayed
|
|
|
|
* @param {string} _tooltip hint text as tooltip
|
|
|
|
*/
|
|
|
|
topmenu_info_notify: function(_id, _switch, _message, _tooltip) {
|
|
|
|
var $items = jQuery('#egw_fw_topmenu_info_items').children();
|
|
|
|
var prefix = "topmenu_info_";
|
|
|
|
|
|
|
|
$items.each(function(i,item){
|
|
|
|
if (item.id == prefix+_id || item.id == _id)
|
|
|
|
{
|
|
|
|
var $notify = jQuery(item).find('.egw_fw_topmenu_info_notify');
|
|
|
|
if (_switch)
|
|
|
|
{
|
|
|
|
if ($notify.length == 0)
|
|
|
|
{
|
|
|
|
$notify = jQuery(document.createElement('div'))
|
|
|
|
.addClass('egw_fw_topmenu_info_notify')
|
|
|
|
.prop('title', _tooltip)
|
|
|
|
.appendTo(item);
|
|
|
|
}
|
2019-12-03 16:24:17 +01:00
|
|
|
$notify.prop('title', _tooltip).text(_message);
|
2019-12-02 14:09:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$notify.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-08-12 11:23:40 +02:00
|
|
|
}
|
2014-12-09 15:25:52 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise framework
|
|
|
|
*/
|
2021-06-05 20:39:39 +02:00
|
|
|
window.egw_ready.then(function() {
|
2014-12-09 15:25:52 +01:00
|
|
|
function egw_setSideboxSize(_size)
|
|
|
|
{
|
|
|
|
document.getElementById('egw_fw_main').style.marginLeft = _size + 'px';
|
|
|
|
document.getElementById('egw_fw_sidebar').style.width = _size + 'px';
|
|
|
|
}
|
|
|
|
|
2016-06-02 16:51:15 +02:00
|
|
|
jQuery(document).ready(function() {
|
2021-04-19 10:17:40 +02:00
|
|
|
//Stop the loading animation after 5sec if for whatever reason it didn't end
|
|
|
|
setTimeout(function(){jQuery('#egw_fw_firstload').remove();}, 5000);
|
2014-12-09 15:25:52 +01:00
|
|
|
window.framework = new fw_pixelegg("egw_fw_sidemenu", "egw_fw_tabs",
|
2015-11-20 11:07:58 +01:00
|
|
|
window.egw_webserverUrl, egw_setSideboxSize,"egw_fw_splitter", 255, 245); // should be identical to jdots_framework::(DEFAULT|MIN)_SIDEBAR_WIDTH
|
2014-12-09 15:25:52 +01:00
|
|
|
window.callManual = window.framework.callManual;
|
2021-02-18 19:04:22 +01:00
|
|
|
jQuery("#egw_fw_topmenu_info_items").on("contextmenu",function() {return false;});
|
2020-12-15 20:24:25 +01:00
|
|
|
jQuery('#topmenu_info_darkmode').click(function(){window.framework.toggle_darkmode(this);});
|
2019-05-24 16:11:30 +02:00
|
|
|
jQuery('#topmenu_info_user_avatar').click(function(){window.framework.toggle_avatar_menu();});
|
|
|
|
jQuery('#topmenu_info_print_title').click(function(){window.framework.print();});
|
|
|
|
jQuery('#topmenu_info_logout').click(function(){ window.framework.redirect(this.getAttribute('data-logout-url')); });
|
2020-01-10 10:56:59 +01:00
|
|
|
jQuery('form[name^="tz_selection"]').children()
|
|
|
|
.on('change', function() { framework.tzSelection(this.value); return false; })
|
|
|
|
.on('click', function(e) { e.stopPropagation(); });
|
2019-03-25 16:36:21 +01:00
|
|
|
window.egw.link_quick_add('topmenu_info_quick_add');
|
2014-12-09 15:25:52 +01:00
|
|
|
|
|
|
|
// allowing javascript urls in topmenu and sidebox only under CSP by binding click handlers to them
|
|
|
|
var href_regexp = /^javascript:([^\(]+)\((.*)?\);?$/;
|
|
|
|
jQuery('#egw_fw_topmenu_items,#egw_fw_topmenu_info_items,#egw_fw_sidemenu,#egw_fw_footer').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
|
|
|
|
var matches = this.href.match(href_regexp);
|
|
|
|
var args = [];
|
|
|
|
if (matches.length > 1 && matches[2] !== undefined)
|
|
|
|
{
|
|
|
|
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')+']');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
args.unshift(matches[1]);
|
2019-08-15 19:36:04 +02:00
|
|
|
if (matches[1] !== 'void') et2_call.apply(this, args);
|
2014-12-09 15:25:52 +01:00
|
|
|
return false; // IE11 seems to require this, ev.stopPropagation() does NOT stop link from being executed
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})(window);
|