forked from extern/egroupware
- MagicSuggest update
- Fix setting taglist value via js
This commit is contained in:
parent
f73f8fea89
commit
b77ce6a8dc
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/*egw:uses
|
/*egw:uses
|
||||||
et2_core_inputWidget;
|
et2_core_inputWidget;
|
||||||
/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.0.js;
|
/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.js;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +142,6 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
var options = jQuery.extend( {
|
var options = jQuery.extend( {
|
||||||
data: this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) ? this._options2data(this.options.select_options) : this.options.autocomplete_url,
|
data: this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) ? this._options2data(this.options.select_options) : this.options.autocomplete_url,
|
||||||
dataUrlParams: this.options.autocomplete_params,
|
dataUrlParams: this.options.autocomplete_params,
|
||||||
value: this.options.value,
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
displayField: "label",
|
displayField: "label",
|
||||||
invalidCls: 'invalid ui-state-error',
|
invalidCls: 'invalid ui-state-error',
|
||||||
@ -160,6 +159,8 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
}, this.lib_options);
|
}, this.lib_options);
|
||||||
this.taglist = this.taglist.magicSuggest(options);
|
this.taglist = this.taglist.magicSuggest(options);
|
||||||
|
|
||||||
|
this.set_value(this.options.value);
|
||||||
|
|
||||||
// Display / hide a loading icon while fetching
|
// Display / hide a loading icon while fetching
|
||||||
$j(this.taglist)
|
$j(this.taglist)
|
||||||
.on("beforeload", function() {this.container.prepend('<div class="ui-icon loading"/>');})
|
.on("beforeload", function() {this.container.prepend('<div class="ui-icon loading"/>');})
|
||||||
@ -281,24 +282,27 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
*/
|
*/
|
||||||
set_value: function(value)
|
set_value: function(value)
|
||||||
{
|
{
|
||||||
|
this.options.value = value;
|
||||||
|
if(this.taglist == null) return;
|
||||||
|
|
||||||
|
this.taglist.clear(true);
|
||||||
|
if(!value) return;
|
||||||
|
|
||||||
var values = jQuery.isArray(value) ? value : [value];
|
var values = jQuery.isArray(value) ? value : [value];
|
||||||
if (value && this.options.allowFreeEntries)
|
|
||||||
{
|
|
||||||
var need_setdata = false;
|
|
||||||
for(var i=0; i < values.length; ++i)
|
for(var i=0; i < values.length; ++i)
|
||||||
{
|
{
|
||||||
var v = values[i];
|
var v = values[i];
|
||||||
if (typeof this.options.select_options[v] == 'undefined')
|
if (typeof this.options.select_options[v] == 'undefined')
|
||||||
{
|
{
|
||||||
this.options.select_options[v] = v;
|
values[i] = {
|
||||||
need_setdata = true;
|
id: v,
|
||||||
|
label: v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.taglist && need_setdata) this.taglist.setData(this._options2data(this.options.select_options));
|
|
||||||
}
|
}
|
||||||
if(this.taglist == null) return;
|
|
||||||
this.taglist.clear(true);
|
|
||||||
this.taglist.setValue(values);
|
this.taglist.addToSelection(values);
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function()
|
getValue: function()
|
||||||
@ -335,13 +339,13 @@ var et2_taglist_email = et2_taglist.extend(
|
|||||||
minChars: 3
|
minChars: 3
|
||||||
},
|
},
|
||||||
|
|
||||||
// PREG for client-side validation copied from etemplate_widget_url
|
// PREG for validation comes from et2_url
|
||||||
EMAIL_PREG: new RegExp(/^[^\x00-\x20()<>@,;:\".\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}/),
|
//EMAIL_PREG: new RegExp(/^[^\x00-\x20()<>@,;:\".\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}/),
|
||||||
|
|
||||||
selectionRenderer: function(item)
|
selectionRenderer: function(item)
|
||||||
{
|
{
|
||||||
// We check free entries for valid email, and render as invalid if it's not.
|
// We check free entries for valid email, and render as invalid if it's not.
|
||||||
var valid = item.id != item.label || this.EMAIL_PREG.test(item.id || '');
|
var valid = item.id != item.label || et2_url.prototype.EMAIL_PREG.test(item.id || '');
|
||||||
|
|
||||||
var label = jQuery('<span>').text(item.label);
|
var label = jQuery('<span>').text(item.label);
|
||||||
if (typeof item.title != 'undefined') label.attr('title', item.title);
|
if (typeof item.title != 'undefined') label.attr('title', item.title);
|
||||||
@ -354,4 +358,4 @@ et2_register_widget(et2_taglist_email, ["taglist-email"]);
|
|||||||
|
|
||||||
// Require css
|
// Require css
|
||||||
// TODO: merge into etemplate2.css with all other widgets when done
|
// TODO: merge into etemplate2.css with all other widgets when done
|
||||||
if(typeof egw != 'undefined') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.0.css");
|
if(typeof egw != 'undefined') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.css");
|
||||||
|
@ -5,6 +5,15 @@ Check out full documentation and examples here: http://nicolasbize.github.com/ma
|
|||||||
|
|
||||||
Milestone change log:
|
Milestone change log:
|
||||||
|
|
||||||
|
v1.3.1 BugFixing again! (Minor Tagged Milestone - August 17th, 2013)
|
||||||
|
====================================================================
|
||||||
|
- (fix) enable after disable now works (credits to amanokerim - https://github.com/amanokerim)
|
||||||
|
- (fix) trigger icon now takes full height (credits to DioVayne - https://github.com/DioVayne)
|
||||||
|
- (fix) clear now compatible with isSilent (credits to Coywolf - https://github.com/Coywolf)
|
||||||
|
- (fix) groupBy was broken by 1.3.0
|
||||||
|
- (fea) compatibility with latest jQuery 1.10.2 (credits to RafaelMalgor - https://github.com/RafaelMalgor)
|
||||||
|
- (fea) resulted JSON objects can now have a custom result property resultsField (credits to RafaelMalgor - https://github.com/RafaelMalgor)
|
||||||
|
|
||||||
v1.3.0 Some more features and bugfixing (Minor Tagged Milestone - May 25th, 2013)
|
v1.3.0 Some more features and bugfixing (Minor Tagged Milestone - May 25th, 2013)
|
||||||
=================================================================================
|
=================================================================================
|
||||||
- (fea) combo component can now be fetched through the same div element (credits to meghuizen - https://github.com/meghuizen)
|
- (fea) combo component can now be fetched through the same div element (credits to meghuizen - https://github.com/meghuizen)
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css
vendored
Normal file
1
phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js
vendored
Normal file
1
phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -74,7 +74,9 @@
|
|||||||
.ms-ctn .ms-trigger{
|
.ms-ctn .ms-trigger{
|
||||||
float: right;
|
float: right;
|
||||||
width: 27px;
|
width: 27px;
|
||||||
height: 28px;
|
height:100%;
|
||||||
|
position:absolute;
|
||||||
|
right:0;
|
||||||
border-left: 1px solid #CCC;
|
border-left: 1px solid #CCC;
|
||||||
background: #EEE;
|
background: #EEE;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -162,6 +164,7 @@
|
|||||||
.ms-sel-ctn{
|
.ms-sel-ctn{
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
|
padding-right:27px;
|
||||||
}
|
}
|
||||||
.ms-sel-ctn .ms-sel-item{
|
.ms-sel-ctn .ms-sel-item{
|
||||||
background: #555;
|
background: #555;
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Author: Nicolas Bize
|
* Author: Nicolas Bize
|
||||||
* Date: Feb. 8th 2013
|
* Date: Feb. 8th 2013
|
||||||
* Version: 1.3.0
|
* Version: 1.3.1
|
||||||
* Licence: MagicSuggest is licenced under MIT licence (http://www.opensource.org/licenses/mit-license.php)
|
* Licence: MagicSuggest is licenced under MIT licence (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
(function($)
|
(function($)
|
||||||
@ -298,6 +298,13 @@
|
|||||||
*/
|
*/
|
||||||
resultAsString: false,
|
resultAsString: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @cfg {String} resultsField
|
||||||
|
* <p>Name of JSON object property that represents the list of suggested objets</p>
|
||||||
|
* Defaults to <code>results</code>
|
||||||
|
*/
|
||||||
|
resultsField: 'results',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @cfg {String} selectionCls
|
* @cfg {String} selectionCls
|
||||||
* <p>A custom CSS class to add to a selected item</p>
|
* <p>A custom CSS class to add to a selected item</p>
|
||||||
@ -469,7 +476,7 @@
|
|||||||
*/
|
*/
|
||||||
this.clear = function(isSilent)
|
this.clear = function(isSilent)
|
||||||
{
|
{
|
||||||
this.removeFromSelection(_selection.slice(0)); // clone array to avoid concurrency issues
|
this.removeFromSelection(_selection.slice(0), isSilent); // clone array to avoid concurrency issues
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -500,7 +507,6 @@
|
|||||||
this.empty = function(){
|
this.empty = function(){
|
||||||
this.input.removeClass(cfg.emptyTextCls);
|
this.input.removeClass(cfg.emptyTextCls);
|
||||||
this.input.val('');
|
this.input.val('');
|
||||||
ms.input.attr('disabled', false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,6 +516,7 @@
|
|||||||
{
|
{
|
||||||
this.container.removeClass('ms-ctn-disabled');
|
this.container.removeClass('ms-ctn-disabled');
|
||||||
cfg.disabled = false;
|
cfg.disabled = false;
|
||||||
|
ms.input.attr('disabled', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -825,7 +832,7 @@
|
|||||||
url: data,
|
url: data,
|
||||||
data: params,
|
data: params,
|
||||||
success: function(asyncData){
|
success: function(asyncData){
|
||||||
json = typeof(asyncData)==='string'?JSON.parse(asyncData):asyncData;
|
json = typeof(asyncData) === 'string' ? JSON.parse(asyncData) : asyncData;
|
||||||
self._processSuggestions(json);
|
self._processSuggestions(json);
|
||||||
$(ms).trigger('load', [ms, json]);
|
$(ms).trigger('load', [ms, json]);
|
||||||
},
|
},
|
||||||
@ -840,7 +847,7 @@
|
|||||||
if(data.length > 0 && typeof(data[0]) === 'string') { // results from array of strings
|
if(data.length > 0 && typeof(data[0]) === 'string') { // results from array of strings
|
||||||
_cbData = self._getEntriesFromStringArray(data);
|
_cbData = self._getEntriesFromStringArray(data);
|
||||||
} else { // regular json array or json object with results property
|
} else { // regular json array or json object with results property
|
||||||
_cbData = data.results || data;
|
_cbData = data[cfg.resultsField] || data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self._displaySuggestions(self._sortAndTrim(_cbData));
|
self._displaySuggestions(self._sortAndTrim(_cbData));
|
||||||
@ -979,7 +986,7 @@
|
|||||||
resultItemEl.mouseover($.proxy(handlers._onComboItemMouseOver, ref));
|
resultItemEl.mouseover($.proxy(handlers._onComboItemMouseOver, ref));
|
||||||
html += $('<div/>').append(resultItemEl).html();
|
html += $('<div/>').append(resultItemEl).html();
|
||||||
});
|
});
|
||||||
ms.combobox.html(html);
|
ms.combobox.append(html);
|
||||||
_comboItemHeight = ms.combobox.find('.ms-res-item:first').outerHeight();
|
_comboItemHeight = ms.combobox.find('.ms-res-item:first').outerHeight();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1017,7 +1024,7 @@
|
|||||||
// small cross img
|
// small cross img
|
||||||
delItemEl = $('<span/>', {
|
delItemEl = $('<span/>', {
|
||||||
'class': 'ms-close-btn'
|
'class': 'ms-close-btn'
|
||||||
}).data('json', value).prependTo(selectedItemEl);
|
}).data('json', value).appendTo(selectedItemEl);
|
||||||
|
|
||||||
delItemEl.click($.proxy(handlers._onTagTriggerClick, ref));
|
delItemEl.click($.proxy(handlers._onTagTriggerClick, ref));
|
||||||
}
|
}
|
||||||
@ -1037,7 +1044,7 @@
|
|||||||
if(cfg.selectionPosition === 'inner') {
|
if(cfg.selectionPosition === 'inner') {
|
||||||
ms.input.width(0);
|
ms.input.width(0);
|
||||||
inputOffset = ms.input.offset().left - ms.selectionContainer.offset().left;
|
inputOffset = ms.input.offset().left - ms.selectionContainer.offset().left;
|
||||||
w = ms.container.width() - inputOffset - (cfg.hideTrigger === true ? 16 : 42);
|
w = ms.container.width() - inputOffset - 42;
|
||||||
ms.input.width(w);
|
ms.input.width(w);
|
||||||
ms.container.height(ms.selectionContainer.height());
|
ms.container.height(ms.selectionContainer.height());
|
||||||
}
|
}
|
||||||
@ -1281,8 +1288,9 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 188: // comma
|
||||||
|
if(e.shiftKey) break; // Shift + , = < on some keyboards
|
||||||
case 9: // tab
|
case 9: // tab
|
||||||
case 188: // esc
|
|
||||||
case 13: // enter
|
case 13: // enter
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
break;
|
break;
|
||||||
@ -1337,7 +1345,8 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
break;
|
break;
|
||||||
case 13:case 9:case 188:// enter, tab, comma
|
case 13:case 9:case 188:// enter, tab, comma
|
||||||
if(e.keyCode !== 188 || cfg.useCommaKey === true) {
|
// Shift + comma = < on English keyboard
|
||||||
|
if(e.keyCode !== 188 || (cfg.useCommaKey === true && !e.shiftKey)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(cfg.expanded === true){ // if a selection is performed, select it and reset field
|
if(cfg.expanded === true){ // if a selection is performed, select it and reset field
|
||||||
selected = ms.combobox.find('.ms-res-item-active:first');
|
selected = ms.combobox.find('.ms-res-item-active:first');
|
||||||
@ -1471,4 +1480,6 @@
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// $.fn.magicSuggest.defaults = {};
|
||||||
})(jQuery);
|
})(jQuery);
|
Loading…
Reference in New Issue
Block a user