Integrated application specifig egw api into etemplate2 code

This commit is contained in:
Andreas Stöckel 2012-03-02 10:44:56 +00:00
parent bd273c1b45
commit 14e6ceecb6
13 changed files with 110 additions and 89 deletions

View File

@ -138,6 +138,10 @@ function et2_form_name(_cname,_name)
*/ */
function et2_js_pseudo_funcs(_val, _cname) function et2_js_pseudo_funcs(_val, _cname)
{ {
// TODO: Call et2 specific egw instance
// Move this function to the API!
if (_val.indexOf('egw::link(') != -1) if (_val.indexOf('egw::link(') != -1)
{ {
_val = _val.replace(/egw::link\(/g,'egw.link('); _val = _val.replace(/egw::link\(/g,'egw.link(');

View File

@ -551,7 +551,9 @@ var et2_widget = Class.extend({
{ {
if (this.attributes[key].translate === true || if (this.attributes[key].translate === true ||
(this.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) (this.attributes[key].translate === "!no_lang" && !_attrs["no_lang"]))
_attrs[key] = egw.lang(_attrs[key]); {
_attrs[key] = this.egw().lang(_attrs[key]);
}
} }
} }
}, },
@ -671,6 +673,35 @@ var et2_widget = Class.extend({
return true; return true;
}, },
/**
* The egw function returns the instance of the client side api belonging
* to this widget tree. The api instance can be set in the "container"
* widget using the setApiInstance function.
*/
egw: function() {
// The _egw property is not set
if (typeof this._egw === 'undefined')
{
if (this._parent != null)
{
return this._parent.egw();
}
// Return the global egw instance if none is given
return egw('phpgwapi');
}
return this._egw;
},
/**
* Sets the client side api instance. It can be retrieved by the widget tree
* by using the "egw()" function.
*/
setApiInstance: function(_egw) {
this._egw = _egw;
},
/** /**
* Sets all array manager objects - this function can be used to set the * Sets all array manager objects - this function can be used to set the
* root array managers of the container object. * root array managers of the container object.
@ -791,28 +822,6 @@ var et2_widget = Class.extend({
return null; return null;
}, },
/**
* Returns the application for the template the widget is in.
* If a sub-template is used, this may be different from the current app.
*/
getTemplateApp: function() {
if(this._template_application)
{
return this._template_application;
}
else if(this._type == 'template' && this.id)
{
var parts = this.id.split(".",2);
return parts[0];
} else if (this.getParent()) {
this._template_application = this.getParent().getTemplateApp();
return this._template_application;
}
var app = egw.getAppName() == 'egroupware' ? 'phpgwapi' : egw.getAppName();
//console.warn("Unable to find template application, using %s", app);
return app;
},
/** /**
* Returns the path into the data array. By default, array manager takes care of * Returns the path into the data array. By default, array manager takes care of
* this, but some extensions need to override this * this, but some extensions need to override this

View File

@ -103,7 +103,7 @@ var et2_customfields_list = et2_DOMWidget.extend([et2_IDetachedDOM], {
if(global_data.fields) this.options.fields = global_data.fields; if(global_data.fields) this.options.fields = global_data.fields;
// For checking app entries // For checking app entries
var apps = egw.link_app_list(); var apps = this.egw().link_app_list();
// Create the table rows // Create the table rows
for(var field_name in this.options.customfields) for(var field_name in this.options.customfields)

View File

@ -326,7 +326,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
var list = et2_csvSplit(this.options.settings.columnselection_pref, 2, "."); var list = et2_csvSplit(this.options.settings.columnselection_pref, 2, ".");
var app = list[0]; var app = list[0];
// 'nextmatch-' prefix is there in preference name, but not in setting, so add it in // 'nextmatch-' prefix is there in preference name, but not in setting, so add it in
var pref = egw.preference("nextmatch-"+this.options.settings.columnselection_pref, list[0]); var pref = this.egw().preference("nextmatch-"+this.options.settings.columnselection_pref, list[0]);
if(pref) if(pref)
{ {
negated = (pref[0] == "!"); negated = (pref[0] == "!");
@ -339,7 +339,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
var size = {}; var size = {};
if(this.options.settings.columnselection_pref && app) if(this.options.settings.columnselection_pref && app)
{ {
size = egw.preference("nextmatch-"+this.options.settings.columnselection_pref+"-size", app); size = this.egw().preference("nextmatch-"+this.options.settings.columnselection_pref+"-size", app);
} }
if(!size) size = {}; if(!size) size = {};
@ -387,7 +387,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}, },
/** /**
* Take current column display settings and store them in egw.preferences * Take current column display settings and store them in this.egw().preferences
* for next time * for next time
*/ */
_updateUserPreferences: function() { _updateUserPreferences: function() {
@ -426,10 +426,10 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
// Save visible columns // Save visible columns
// 'nextmatch-' prefix is there in preference name, but not in setting, so add it in // 'nextmatch-' prefix is there in preference name, but not in setting, so add it in
egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref, colDisplay.join(",")); this.egw().set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref, colDisplay.join(","));
// Save adjusted column sizes // Save adjusted column sizes
egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize); this.egw().set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize);
// Update query value, so data source can use visible columns to exclude expensive sub-queries // Update query value, so data source can use visible columns to exclude expensive sub-queries
var oldCols = this.activeFilters.selectcols ? this.activeFilters.selectcols : []; var oldCols = this.activeFilters.selectcols ? this.activeFilters.selectcols : [];
@ -564,10 +564,10 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
var defaultCheck = et2_createWidget("checkbox", {}, this); var defaultCheck = et2_createWidget("checkbox", {}, this);
defaultCheck.set_id('as_default'); defaultCheck.set_id('as_default');
defaultCheck.set_label(egw.lang("As default")); defaultCheck.set_label(this.egw().lang("As default"));
var okButton = et2_createWidget("buttononly", {}, this); var okButton = et2_createWidget("buttononly", {}, this);
okButton.set_label(egw.lang("ok")); okButton.set_label(this.egw().lang("ok"));
okButton.onclick = function() { okButton.onclick = function() {
// Update visibility // Update visibility
var visibility = {}; var visibility = {};
@ -621,21 +621,21 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}; };
var cancelButton = et2_createWidget("buttononly", {}, this); var cancelButton = et2_createWidget("buttononly", {}, this);
cancelButton.set_label(egw.lang("cancel")); cancelButton.set_label(this.egw().lang("cancel"));
cancelButton.onclick = function() { cancelButton.onclick = function() {
self.selectPopup.toggle(); self.selectPopup.toggle();
} }
this.selectPopup = jQuery(document.createElement("fieldset")) this.selectPopup = jQuery(document.createElement("fieldset"))
.addClass("colselection ui-dialog") .addClass("colselection ui-dialog")
.append("<legend>"+egw.lang("Select columns")+"</legend>") .append("<legend>"+this.egw().lang("Select columns")+"</legend>")
.append(select.getDOMNode()) .append(select.getDOMNode())
.append(okButton.getDOMNode()) .append(okButton.getDOMNode())
.append(cancelButton.getDOMNode()) .append(cancelButton.getDOMNode())
.appendTo(this.div); .appendTo(this.div);
// Add default checkbox for admins // Add default checkbox for admins
var apps = egw.user('apps'); var apps = this.egw().user('apps');
if(apps['admin']) if(apps['admin'])
{ {
this.selectPopup.append(defaultCheck.getSurroundings().getDOMNode(defaultCheck.getDOMNode())) this.selectPopup.append(defaultCheck.getSurroundings().getDOMNode(defaultCheck.getDOMNode()))
@ -856,14 +856,14 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
var definition = settings.csv_fields; var definition = settings.csv_fields;
if(settings.csv_fields === true) if(settings.csv_fields === true)
{ {
definition = egw.preference('nextmatch-export-definition', this.nextmatch.getTemplateApp()); definition = egw.preference('nextmatch-export-definition', this.nextmatch.egw().getAppName());
} }
var button = et2_createWidget("buttononly", {"label": "Export", image:"phpgwapi/filesave"}, this.nextmatch); var button = et2_createWidget("buttononly", {"label": "Export", image:"phpgwapi/filesave"}, this.nextmatch);
jQuery(button.getDOMNode()).appendTo(this.filters).css("float", "right") jQuery(button.getDOMNode()).appendTo(this.filters).css("float", "right")
.click(this.nextmatch, function(event) { .click(this.nextmatch, function(event) {
egw_openWindowCentered2( egw.link('/index.php', { egw_openWindowCentered2( egw.link('/index.php', {
'menuaction': 'importexport.importexport_export_ui.export_dialog', 'menuaction': 'importexport.importexport_export_ui.export_dialog',
'appname': event.data.getTemplateApp(), 'appname': event.data.egw().getAppName(),
'definition': definition 'definition': definition
}), '_blank', 850, 440, 'yes'); }), '_blank', 850, 440, 'yes');
}); });

View File

@ -66,7 +66,7 @@ var et2_date = et2_inputWidget.extend({
this.span.append(this.input_date).append(this.button); this.span.append(this.input_date).append(this.button);
// Icon could be done in CSS file // Icon could be done in CSS file
var button_image = egw.image('datepopup','phpgwapi'); var button_image = this.egw().image('datepopup','phpgwapi');
if(button_image) if(button_image)
{ {
this.button.css("background-image","url("+button_image+")"); this.button.css("background-image","url("+button_image+")");
@ -77,7 +77,7 @@ var et2_date = et2_inputWidget.extend({
node.addClass("et2_date"); node.addClass("et2_date");
var _this = this; var _this = this;
var dateformat = egw.preference("dateformat"); var dateformat = this.egw().preference("dateformat");
if (!dateformat) dateformat = "Y-m-d"; if (!dateformat) dateformat = "Y-m-d";
dateformat = dateformat.replace("Y","%Y").replace("d","%d").replace("m","%m").replace("M", "%b"); dateformat = dateformat.replace("Y","%Y").replace("d","%d").replace("m","%m").replace("M", "%b");
@ -87,7 +87,7 @@ var et2_date = et2_inputWidget.extend({
showsTime: false, showsTime: false,
onUpdate: function(_value) {_this.set_value(_value)}, onUpdate: function(_value) {_this.set_value(_value)},
daFormat: dateformat, daFormat: dateformat,
firstDay: egw.preference("weekdaystarts","calendar") firstDay: this.egw().preference("weekdaystarts","calendar")
}; };
window.setTimeout(function() { window.setTimeout(function() {
Calendar.setup(setup); Calendar.setup(setup);
@ -127,7 +127,7 @@ var et2_date = et2_inputWidget.extend({
}, },
_make_time_selects: function (node) { _make_time_selects: function (node) {
var timeformat = egw.preference("timeformat"); var timeformat = this.egw().preference("timeformat");
this.input_hours = $j(document.createElement("select")); this.input_hours = $j(document.createElement("select"));
for(var i = 0; i < 24; i++) for(var i = 0; i < 24; i++)
{ {
@ -250,7 +250,7 @@ var et2_date = et2_inputWidget.extend({
if(this.input_date) if(this.input_date)
{ {
this.input_date.val(date(egw.preference('dateformat'), this.date)); this.input_date.val(date(this.egw().preference('dateformat'), this.date));
} }
if(this.input_time) if(this.input_time)
{ {
@ -339,9 +339,9 @@ var et2_date_duration = et2_date.extend({
// Get translations // Get translations
this.time_formats = { this.time_formats = {
"d": this.options.short_labels ? egw.lang("m") : egw.lang("Days"), "d": this.options.short_labels ? this.egw().lang("m") : this.egw().lang("Days"),
"h": this.options.short_labels ? egw.lang("h") : egw.lang("Hours"), "h": this.options.short_labels ? this.egw().lang("h") : this.egw().lang("Hours"),
"m": this.options.short_labels ? egw.lang("m") : egw.lang("Minutes") "m": this.options.short_labels ? this.egw().lang("m") : this.egw().lang("Minutes")
}, },
this.createInputWidget(); this.createInputWidget();
}, },
@ -468,7 +468,7 @@ var et2_date_duration = et2_date.extend({
// use decimal separator from user prefs // use decimal separator from user prefs
var sep = '.'; var sep = '.';
var format = egw.preference('number_format'); var format = this.egw().preference('number_format');
if (format && (sep = format[0]) && sep != '.') if (format && (sep = format[0]) && sep != '.')
{ {
_value = _value.replace('.',sep); _value = _value.replace('.',sep);
@ -617,14 +617,14 @@ var et2_date_ro = et2_valueWidget.extend([et2_IDetachedDOM], {
switch(this._type) { switch(this._type) {
case "date": case "date":
display = date(egw.preference('dateformat'), this.date); display = date(this.egw().preference('dateformat'), this.date);
break; break;
case "date-timeonly": case "date-timeonly":
display = date(egw.preference('timeformat') == '24' ? 'H:i' : 'g:i a', this.date); display = date(this.egw().preference('timeformat') == '24' ? 'H:i' : 'g:i a', this.date);
break; break;
case "date-time": case "date-time":
display = date(egw.preference('dateformat') + " " + display = date(this.egw().preference('dateformat') + " " +
(egw.preference('timeformat') == '24' ? 'H:i' : 'g:i a'), this.date); (this.egw().preference('timeformat') == '24' ? 'H:i' : 'g:i a'), this.date);
break; break;
case "date-since": case "date-since":
var unit2label = { var unit2label = {
@ -652,7 +652,7 @@ var et2_date_ro = et2_valueWidget.extend([et2_IDetachedDOM], {
var unit_s = unit2s[unit]; var unit_s = unit2s[unit];
if (diff >= unit_s || unit == 's') if (diff >= unit_s || unit == 's')
{ {
display = Math.round(diff/unit_s,1)+' '+egw.lang(unit2label[unit]); display = Math.round(diff/unit_s,1)+' '+this.egw().lang(unit2label[unit]);
break; break;
} }
} }
@ -712,7 +712,7 @@ var et2_date_timeonly_ro = et2_date_ro.extend({
} }
}, },
set_value: function(_value) { set_value: function(_value) {
if(egw.preference("timeformat") == "12" && _value.indexOf(":") > 0) { if(this.egw().preference("timeformat") == "12" && _value.indexOf(":") > 0) {
var parts = _value.split(":"); var parts = _value.split(":");
if(parts[0] >= 12) { if(parts[0] >= 12) {
this.span.text((parts[0] == "12" ? "12" : parseInt(parts[0])-12)+":"+parts[1]+" pm"); this.span.text((parts[0] == "12" ? "12" : parseInt(parts[0])-12)+":"+parts[1]+" pm");

View File

@ -179,7 +179,7 @@ var et2_file = et2_inputWidget.extend({
if(this.input[0].files[index]) { if(this.input[0].files[index]) {
var file = this.input[0].files[index]; var file = this.input[0].files[index];
if(file.size > this.options.max_file_size) { if(file.size > this.options.max_file_size) {
error = egw.lang("File too large"); error = this.egw().lang("File too large");
} }
} }
if(this.progress) if(this.progress)

View File

@ -82,7 +82,7 @@ var et2_image = et2_baseWidget.extend([et2_IDetachedDOM], {
{ {
if(this.options.href) if(this.options.href)
{ {
egw.call_link(this.options.href, this.options.extra_link_target, this.options.extra_link_popup); this.egw().call_link(this.options.href, this.options.extra_link_target, this.options.extra_link_popup);
} }
}, },
@ -122,7 +122,7 @@ var et2_image = et2_baseWidget.extend([et2_IDetachedDOM], {
} }
this.options.src = _value; this.options.src = _value;
var app = this.getTemplateApp(); var app = this.egw().getAppName();
// Handle app/image // Handle app/image
if(_value.indexOf("/") > 0 && _value.indexOf("/") == _value.lastIndexOf("/")) { if(_value.indexOf("/") > 0 && _value.indexOf("/") == _value.lastIndexOf("/")) {
@ -131,7 +131,7 @@ var et2_image = et2_baseWidget.extend([et2_IDetachedDOM], {
_value = split[1]; _value = split[1];
} }
// Get application to use from template ID // Get application to use from template ID
var src = egw.image(_value, app); var src = this.egw().image(_value, app);
if(src) if(src)
{ {
this.image.attr("src", src).show(); this.image.attr("src", src).show();

View File

@ -108,7 +108,7 @@ var et2_link_to = et2_inputWidget.extend({
// One common link button // One common link button
this.link_button = $j(document.createElement("button")) this.link_button = $j(document.createElement("button"))
.text(egw.lang(this.options.link_label)) .text(this.egw().lang(this.options.link_label))
.appendTo(this.div).hide() .appendTo(this.div).hide()
.click(this, this.createLink); .click(this, this.createLink);
@ -123,7 +123,7 @@ var et2_link_to = et2_inputWidget.extend({
this.comment = $j(document.createElement("input")) this.comment = $j(document.createElement("input"))
.css("display", "block").css("width","89%") .css("display", "block").css("width","89%")
.appendTo(this.div).hide(); .appendTo(this.div).hide();
et2_link_entry.prototype.set_blur(egw.lang("Comment..."),this.comment); et2_link_entry.prototype.set_blur(this.egw().lang("Comment..."),this.comment);
// Need a div for file upload widget // Need a div for file upload widget
this.file_div = $j(document.createElement("div")).appendTo(this.div); this.file_div = $j(document.createElement("div")).appendTo(this.div);
@ -139,7 +139,7 @@ var et2_link_to = et2_inputWidget.extend({
// Link-to // Link-to
var link_entry_attrs = { var link_entry_attrs = {
id: this.id + '_link_entry', id: this.id + '_link_entry',
blur: this.options.search_label ? this.options.search_label : egw.lang('Search...'), blur: this.options.search_label ? this.options.search_label : this.egw().lang('Search...'),
query: function() { self.link_button.hide(); self.comment.hide(); return true;}, query: function() { self.link_button.hide(); self.comment.hide(); return true;},
select: function() {self.link_button.show(); self.comment.show(); return true;} select: function() {self.link_button.show(); self.comment.show(); return true;}
} }
@ -172,7 +172,7 @@ var et2_link_to = et2_inputWidget.extend({
this.file_upload.progress.children().each(function() { this.file_upload.progress.children().each(function() {
var comment = jQuery(document.createElement("input")) var comment = jQuery(document.createElement("input"))
.appendTo(this).hide(); .appendTo(this).hide();
self.link_entry.set_blur(egw.lang("Comment..."),comment); self.link_entry.set_blur(this.egw().lang("Comment..."),comment);
var comment_icon = jQuery(document.createElement("span")) var comment_icon = jQuery(document.createElement("span"))
.appendTo(this) .appendTo(this)
@ -273,9 +273,9 @@ var et2_link_apps = et2_selectbox.extend({
// Limit to one app // Limit to one app
if(this.options.application) { if(this.options.application) {
select_options[_attrs.application] = egw.lang(_attrs.application); select_options[_attrs.application] = this.egw().lang(_attrs.application);
} else { } else {
select_options = egw.link_app_list('query'); select_options = this.egw().link_app_list('query');
// Check whether the options entry was found, if not read it from the // Check whether the options entry was found, if not read it from the
// content array. // content array.
@ -383,7 +383,7 @@ var et2_link_entry = et2_valueWidget.extend({
.focus(function(){if(!self.options.application) {self.app_select.show();}}) .focus(function(){if(!self.options.application) {self.app_select.show();}})
.appendTo(this.div); .appendTo(this.div);
this.set_blur(this.options.blur ? this.options.blur : egw.lang("search"), this.search); this.set_blur(this.options.blur ? this.options.blur : this.egw().lang("search"), this.search);
// Autocomplete // Autocomplete
this.search.autocomplete({ this.search.autocomplete({
@ -415,12 +415,12 @@ var et2_link_entry = et2_valueWidget.extend({
var apps = et2_csvSplit(_attrs["application"], null, ","); var apps = et2_csvSplit(_attrs["application"], null, ",");
for(var i = 0; i < apps.length; i++) for(var i = 0; i < apps.length; i++)
{ {
_attrs["select_options"][apps[i]] = egw.lang(apps[i]); _attrs["select_options"][apps[i]] = this.egw().lang(apps[i]);
} }
} }
else else
{ {
_attrs["select_options"] = egw.link_app_list('query'); _attrs["select_options"] = this.egw().link_app_list('query');
} }
// Check whether the options entry was found, if not read it from the // Check whether the options entry was found, if not read it from the
@ -475,14 +475,14 @@ var et2_link_entry = et2_valueWidget.extend({
return; return;
} }
if(!_value.title) { if(!_value.title) {
var title = egw.link_title(_value.app, _value.id); var title = this.egw().link_title(_value.app, _value.id);
if(title != null) { if(title != null) {
_value.title = title; _value.title = title;
} }
else else
{ {
// Title will be fetched from server and then set // Title will be fetched from server and then set
var title = egw.link_title(_value.app, _value.id, function(title) {this.val(title+"");}, this.search); var title = this.egw().link_title(_value.app, _value.id, function(title) {this.val(title+"");}, this.search);
} }
} }
this.value = _value; this.value = _value;
@ -664,7 +664,7 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], {
} }
if(!_value.title) { if(!_value.title) {
var self = this; var self = this;
var title = egw.link_title(_value.app, _value.id, function(title) {self.set_title(self.link[0], title);}, this); var title = this.egw().link_title(_value.app, _value.id, function(title) {self.set_title(self.link[0], title);}, this);
if(title != null) { if(title != null) {
_value.title = title; _value.title = title;
} }
@ -676,7 +676,7 @@ var et2_link = et2_valueWidget.extend([et2_IDetachedDOM], {
} }
this.set_title(this.link, _value.title); this.set_title(this.link, _value.title);
this.link.unbind() this.link.unbind()
.click( function(){egw.open(_value.id, _value.app, "edit", _value.extra);}); .click( function(){this.egw().open(_value.id, _value.app, "edit", _value.extra);});
}, },
/** /**
@ -802,26 +802,26 @@ var et2_link_string = et2_valueWidget.extend([et2_IDetachedDOM], {
{ {
_value.only_app = this.options.only_app; _value.only_app = this.options.only_app;
} }
egw.jsonq('etemplate.etemplate_widget_link.ajax_link_list', [_value], this.set_value, this); this.egw().jsonq('etemplate.etemplate_widget_link.ajax_link_list', [_value], this.set_value, this);
return; return;
}, },
_add_link: function(_link_data) { _add_link: function(_link_data) {
if(!_link_data.title) { if(!_link_data.title) {
// No callback yet, need something to do with it // No callback yet, need something to do with it
var title = egw.link_title(_link_data.app, _link_data.id); var title = this.egw().link_title(_link_data.app, _link_data.id);
// Need to set it to something, or call to text() will return current value // Need to set it to something, or call to text() will return current value
if(title == null || title == false) _link_data.title = ""; if(title == null || title == false) _link_data.title = "";
} }
var link = $j(document.createElement("li")) var link = $j(document.createElement("li"))
.appendTo(this.list) .appendTo(this.list)
.addClass("et2_link") .addClass("et2_link")
.click( function(){egw.open(_link_data.id, _link_data.app, "edit", _link_data.extra);}); .click( function(){this.egw().open(_link_data.id, _link_data.app, "edit", _link_data.extra);});
if(_link_data.title) link.text(_link_data.title); if(_link_data.title) link.text(_link_data.title);
// Now that link is created, get title from server & update // Now that link is created, get title from server & update
if(!_link_data.title) { if(!_link_data.title) {
egw.link_title(_link_data.app, _link_data.id, function(title) {this.text(title);}, link); this.egw().link_title(_link_data.app, _link_data.id, function(title) {this.text(title);}, link);
} }
}, },
@ -901,7 +901,7 @@ var et2_link_list = et2_link_string.extend({
$j(document.createElement("td")) $j(document.createElement("td"))
.appendTo(row) .appendTo(row)
.addClass(columns[i]) .addClass(columns[i])
.click( function(){egw.open(_link_data.id, _link_data.app, "edit", _link_data.extra);}) .click( function(){this.egw().open(_link_data.id, _link_data.app, "edit", _link_data.extra);})
.text(_link_data[columns[i]]); .text(_link_data[columns[i]]);
} }
@ -947,18 +947,18 @@ var et2_link_add = et2_inputWidget.extend({
init: function() { init: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.div = jQuery(document.createElement("div")).text(egw.lang("Add new")); this.div = jQuery(document.createElement("div")).text(this.egw().lang("Add new"));
this.setDOMNode(this.div[0]); this.setDOMNode(this.div[0]);
}, },
doLoadingFinished: function() { doLoadingFinished: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.app_select = et2_createWidget("link-apps", this.options ,this); this.app_select = et2_createWidget("link-apps", this.options ,this);
this.div.append(this.app_select.getDOMNode()); this.div.append(this.app_select.getDOMNode());
this.button = et2_createWidget("button", {label: egw.lang("add")}, this); this.button = et2_createWidget("button", {label: this.egw().lang("add")}, this);
this.button.set_label(egw.lang("add")); this.button.set_label(this.egw().lang("add"));
var self = this; var self = this;
this.button.click = function() { this.button.click = function() {
egw.open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add'); this.egw().open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add');
}; };
this.div.append(this.button.getDOMNode()); this.div.append(this.button.getDOMNode());
} }

View File

@ -81,7 +81,7 @@ var et2_progress = et2_valueWidget.extend(et2_IDetachedDOM,
if(this.options.href) if(this.options.href)
{ {
egw.call_link(this.options.href, this.options.extra_link_target, this.options.extra_link_popup); this.egw().call_link(this.options.href, this.options.extra_link_target, this.options.extra_link_popup);
} }
}, },

View File

@ -92,7 +92,7 @@ var et2_tabbox = et2_DOMWidget.extend({
} }
} }
tabData.push({ tabData.push({
"label": egw.lang(et2_readAttrWithDefault(node, "label", "Tab")), "label": this.egw().lang(et2_readAttrWithDefault(node, "label", "Tab")),
"widget": null, "widget": null,
"contentDiv": null, "contentDiv": null,
"flagDiv": null, "flagDiv": null,

View File

@ -67,6 +67,11 @@ var et2_template = et2_DOMWidget.extend({
if (this.id != "") if (this.id != "")
{ {
// Set the api instance to the first part of the name of the
// template
var splitted = this.id.split('.');
this.setApiInstance(egw(splitted[0]));
this.createProxy(); this.createProxy();
} }
}, },
@ -90,13 +95,13 @@ var et2_template = et2_DOMWidget.extend({
// template (done by passing "this" to the clone function) // template (done by passing "this" to the clone function)
this.proxiedTemplate = tmpl.clone(this); this.proxiedTemplate = tmpl.clone(this);
// Reset the "ignore" flag and manually copy the id // Reset the id and manually copy the id to the proxied template
tmpl.options.id = this.id; tmpl.options.id = this.id;
this.proxiedTemplate.id = tmpl.id; this.proxiedTemplate.id = tmpl.id;
this.proxiedTemplate.isProxy = true; this.proxiedTemplate.isProxy = true;
// Disallow adding any new node to this template // Disallow adding any new node to this template
//this.supportedWidgetClasses = []; this.supportedWidgetClasses = [];
} }
}, },

View File

@ -136,14 +136,14 @@ var et2_url = et2_textbox.extend({
{ {
value = "tel:"+value; value = "tel:"+value;
} }
else if (egw.config("call_link")) else if (this.egw().config("call_link"))
{ {
var link = egw.config("call_link").replace("%1", value). var link = this.egw().config("call_link").replace("%1", value).
replace("%u",egw.user('account_id')).replace("%t",egw.user('account_phone')); replace("%u",this.egw().user('account_id')).replace("%t",this.egw().user('account_phone'));
if(egw.config("call_popup")) if(this.egw().config("call_popup"))
{ {
var size = egw.config("call_popup").split("x"); var size = this.egw().config("call_popup").split("x");
value = function() { egw_openWindowCentered(link, false,size[0],size[1]); }; value = function() { egw_openWindowCentered(link, false,size[0],size[1]); };
} }
else // no popup else // no popup
@ -157,9 +157,9 @@ var et2_url = et2_textbox.extend({
} }
break; break;
case "url-email": case "url-email":
if(egw.link_registry && egw.link_registry.felamimail) if(this.egw().link_registry && this.egw().link_registry.felamimail)
{ {
return function() {egw.open("","felamimail","add","send_to="+jQuery.base64Encode(value));}; return function() {this.egw().open("","felamimail","add","send_to="+jQuery.base64Encode(value));};
} }
else if(value.indexOf("mailto:") == -1) else if(value.indexOf("mailto:") == -1)
{ {
@ -185,7 +185,7 @@ var et2_url = et2_textbox.extend({
case "url": case "url":
if(value.indexOf("://") == -1) { if(value.indexOf("://") == -1) {
e.data.set_value("http://"+value); e.data.set_value("http://"+value);
e.data.showMessage(egw.lang("Protocol is required"), "hint", true); e.data.showMessage(this.egw().lang("Protocol is required"), "hint", true);
} }
break; break;
} }

View File

@ -42,6 +42,9 @@
et2_core_xml; et2_core_xml;
et2_core_arrayMgr; et2_core_arrayMgr;
et2_core_interfaces; et2_core_interfaces;
// Include the client side api core
egw_core;
*/ */
/** /**