Author: nathangray
New Revision: 54954
URL: http://svn.stylite.de/viewvc/egroupware?rev=54954&view=rev
Log:
Ajax fetching for chosen taglist style selectboxes - set tags & source attributes
Modified:
trunk/etemplate/js/et2_widget_selectAccount.js
trunk/etemplate/js/et2_widget_selectbox.js
— trunk/etemplate/js/et2_widget_selectAccount.js (original)
+++ trunk/etemplate/js/et2_widget_selectAccount.js Tue Feb 9 01:38:09 2016
@@ -126,7 +126,7 @@
this._super.apply(this, arguments);
// Add search button
@@ -165,7 +165,7 @@
this.options.select_options = this._get_accounts();
— trunk/etemplate/js/et2_widget_selectbox.js (original)
+++ trunk/etemplate/js/et2_widget_selectbox.js Tue Feb 9 01:38:09 2016
@@ -80,6 +80,12 @@
“default”: false,
“description”: “For multi-selects, displays selected as a list of tags instead of a big list”
},
-
"source": {
-
"name": "AJAX data source",
-
"type": "any",
-
"default": et2_no_init,
-
"description": "Fetch options as needed from the server"
-
},
// Value can be string or integer
"value": {
@@ -408,6 +414,10 @@
this.set_tags(this.options.tags, this.options.width);
@@ -740,6 +750,85 @@
// Sometimes value gets set before options
if(this.value || this.options.empty_label) this.set_value(this.value);
-
},
-
-
/**
-
- Set a ajax source for options. Works best with search or tags options
-
-
*/
-
set_source: function(_url) {
-
-
if(!this.input) return false;
-
-
// Can't actually do this until attached, loadingFinished should call again
-
if(!this.isAttached()) return;
-
-
-
var widget = this;
-
var search = this.input.next()
-
.find('.search-field > input, .chzn-search > input');
-
var timeout = null;
-
-
if(!_url || !search || search && search.autocomplete('instance'))
-
{
-
search.autocomplete('destroy');
-
return;
-
}
-
-
this.options.source = _url;
-
-
search.on('keyup', function(e) {
-
var term = search.val().trim() || '';
-
if(term.length < 2)
-
{
-
return false;
-
}
-
if(timeout)
-
{
-
window.clearTimeout(timeout);
-
}
-
timeout = window.setTimeout(function()
-
{
-
timeout = null;
-
search.parent().addClass('loading');
-
widget.egw().json(widget.options.source,term, widget._ajax_fetch,widget, false,widget).sendRequest();
-
},200);
-
});
-
-
},
-
-
/*
-
- Fetch options via AJAX for use in tag lists
-
-
-
*/
-
_ajax_fetch: function _ajax_fetch(data) {
-
var found = false;
-
var search = this.input.next()
-
.find('.search-field > input, .chzn-search > input');
-
-
for(var i = 0; i < data.length; i++)
-
{
-
if(data[i] && typeof data[i].value === 'string' && typeof data[i].label === 'string')
-
{
-
var option = data[i];
-
if(jQuery("option[value='"+option.value+"']", this.input).length === 0)
-
{
-
found = true;
-
this._appendOptionElement(option.value, option.label,option.title);
-
}
-
}
-
}
-
search.parent()
-
.removeClass('loading');
-
if(found)
-
{
-
var term = search.val();
-
this.input.trigger('liszt:close');
-
this.input.trigger("liszt:updated");
-
// Updating clears the search term, restore it
-
search.val(term);
-
}
},
getValue: function() {
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs