Implement set window title for each application with a default title field or define an app specific custom get title

This commit is contained in:
Hadi Nategh 2015-01-05 14:28:35 +00:00
parent 8fb1418b3b
commit 39cc660c0d
5 changed files with 84 additions and 0 deletions

View File

@ -804,5 +804,15 @@ app.classes.addressbook = AppJS.extend(
}, this).sendRequest();
break;
}
},
/**
* Get title in order to set it as document title
* @returns {string}
*/
getWindowTitle: function()
{
var widget = this.et2.getWidgetById('n_fn');
if(widget) return widget.options.value;
}
});

View File

@ -510,5 +510,15 @@ app.classes.infolog = AppJS.extend(
action_id: typeof action_id.join != "undefined" ? action_id.join(',') : action_id
};
egw.open('','infolog','add',extras);
},
/**
* Get title in order to set it as document title
* @returns {string}
*/
getWindowTitle: function()
{
var widget = this.et2.getWidgetById('info_subject');
if(widget) return widget.options.value;
}
});

View File

@ -4195,5 +4195,26 @@ app.classes.mail = AppJS.extend(
clearInterval(this.W_INTERVALS[i]);
delete this.W_INTERVALS[i];
}
},
/**
* Window title getter function in order to set the window title
*
* @returns {string} window title
*/
getWindowTitle: function ()
{
var widget = {};
switch(this.et2._inst.name)
{
case 'mail.display':
widget = this.et2.getWidgetById('mail_displaysubject');
if (widget) return widget.options.value;
break;
case 'mail.compose':
widget = this.et2.getWidgetById('subject');
if (widget) return widget.get_value();
break;
}
}
});

View File

@ -141,6 +141,7 @@ var AppJS = Class.extend(
}
this.et2 = et2.widgetContainer;
this._fix_iFrameScrolling();
if (this.egw.is_popup()) this._set_Window_title();
},
/**
@ -729,5 +730,37 @@ var AppJS = Class.extend(
}
});
}
},
/**
* Set document title, uses getWindowTitle to get the correct title,
* otherwise set it with uniqueID as default title
*/
_set_Window_title: function ()
{
var title = this.getWindowTitle();
if (title)
{
document.title = this.et2._inst.uniqueId + ": " + title;
}
},
/**
* Window title getter function in order to set the window title
* this can be overridden on each application app.js file to customize the title value
*
* @returns {string} window title
*/
getWindowTitle: function ()
{
var titleWidget = this.et2.getWidgetById('title');
if (titleWidget)
{
return titleWidget.get_value();
}
else
{
return this.et2._inst.uniqueId;
}
}
});

View File

@ -117,5 +117,15 @@ app.classes.timesheet = AppJS.extend(
{
ts_project.set_blur(_widget.getValue() ? _widget.search.val() : '');
}
},
/**
* Get title in order to set it as document title
* @returns {string}
*/
getWindowTitle: function()
{
var widget = this.et2.getWidgetById('ts_title');
if(widget) return widget.options.value;
}
});