mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
- MagicSuggest update
- Fix setting taglist value via js
This commit is contained in:
parent
f73f8fea89
commit
b77ce6a8dc
@ -14,7 +14,7 @@
|
||||
|
||||
/*egw:uses
|
||||
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( {
|
||||
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,
|
||||
value: this.options.value,
|
||||
method: 'GET',
|
||||
displayField: "label",
|
||||
invalidCls: 'invalid ui-state-error',
|
||||
@ -160,6 +159,8 @@ var et2_taglist = et2_selectbox.extend(
|
||||
}, this.lib_options);
|
||||
this.taglist = this.taglist.magicSuggest(options);
|
||||
|
||||
this.set_value(this.options.value);
|
||||
|
||||
// Display / hide a loading icon while fetching
|
||||
$j(this.taglist)
|
||||
.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)
|
||||
{
|
||||
this.options.value = value;
|
||||
if(this.taglist == null) return;
|
||||
|
||||
this.taglist.clear(true);
|
||||
if(!value) return;
|
||||
|
||||
var values = jQuery.isArray(value) ? value : [value];
|
||||
if (value && this.options.allowFreeEntries)
|
||||
{
|
||||
var need_setdata = false;
|
||||
for(var i=0; i < values.length; ++i)
|
||||
{
|
||||
var v = values[i];
|
||||
if (typeof this.options.select_options[v] == 'undefined')
|
||||
{
|
||||
this.options.select_options[v] = v;
|
||||
need_setdata = true;
|
||||
values[i] = {
|
||||
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()
|
||||
@ -335,13 +339,13 @@ var et2_taglist_email = et2_taglist.extend(
|
||||
minChars: 3
|
||||
},
|
||||
|
||||
// PREG for client-side validation copied from etemplate_widget_url
|
||||
EMAIL_PREG: new RegExp(/^[^\x00-\x20()<>@,;:\".\[\]]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,6}/),
|
||||
// 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}/),
|
||||
|
||||
selectionRenderer: function(item)
|
||||
{
|
||||
// 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);
|
||||
if (typeof item.title != 'undefined') label.attr('title', item.title);
|
||||
@ -354,4 +358,4 @@ et2_register_widget(et2_taglist_email, ["taglist-email"]);
|
||||
|
||||
// Require css
|
||||
// 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:
|
||||
|
||||
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)
|
||||
=================================================================================
|
||||
- (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{
|
||||
float: right;
|
||||
width: 27px;
|
||||
height: 28px;
|
||||
height:100%;
|
||||
position:absolute;
|
||||
right:0;
|
||||
border-left: 1px solid #CCC;
|
||||
background: #EEE;
|
||||
cursor: pointer;
|
||||
@ -162,6 +164,7 @@
|
||||
.ms-sel-ctn{
|
||||
overflow: auto;
|
||||
line-height: 22px;
|
||||
padding-right:27px;
|
||||
}
|
||||
.ms-sel-ctn .ms-sel-item{
|
||||
background: #555;
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Author: Nicolas Bize
|
||||
* 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)
|
||||
*/
|
||||
(function($)
|
||||
@ -298,6 +298,13 @@
|
||||
*/
|
||||
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
|
||||
* <p>A custom CSS class to add to a selected item</p>
|
||||
@ -469,7 +476,7 @@
|
||||
*/
|
||||
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.input.removeClass(cfg.emptyTextCls);
|
||||
this.input.val('');
|
||||
ms.input.attr('disabled', false);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -510,6 +516,7 @@
|
||||
{
|
||||
this.container.removeClass('ms-ctn-disabled');
|
||||
cfg.disabled = false;
|
||||
ms.input.attr('disabled', false);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -825,7 +832,7 @@
|
||||
url: data,
|
||||
data: params,
|
||||
success: function(asyncData){
|
||||
json = typeof(asyncData)==='string'?JSON.parse(asyncData):asyncData;
|
||||
json = typeof(asyncData) === 'string' ? JSON.parse(asyncData) : asyncData;
|
||||
self._processSuggestions(json);
|
||||
$(ms).trigger('load', [ms, json]);
|
||||
},
|
||||
@ -840,7 +847,7 @@
|
||||
if(data.length > 0 && typeof(data[0]) === 'string') { // results from array of strings
|
||||
_cbData = self._getEntriesFromStringArray(data);
|
||||
} else { // regular json array or json object with results property
|
||||
_cbData = data.results || data;
|
||||
_cbData = data[cfg.resultsField] || data;
|
||||
}
|
||||
}
|
||||
self._displaySuggestions(self._sortAndTrim(_cbData));
|
||||
@ -979,7 +986,7 @@
|
||||
resultItemEl.mouseover($.proxy(handlers._onComboItemMouseOver, ref));
|
||||
html += $('<div/>').append(resultItemEl).html();
|
||||
});
|
||||
ms.combobox.html(html);
|
||||
ms.combobox.append(html);
|
||||
_comboItemHeight = ms.combobox.find('.ms-res-item:first').outerHeight();
|
||||
},
|
||||
|
||||
@ -1017,7 +1024,7 @@
|
||||
// small cross img
|
||||
delItemEl = $('<span/>', {
|
||||
'class': 'ms-close-btn'
|
||||
}).data('json', value).prependTo(selectedItemEl);
|
||||
}).data('json', value).appendTo(selectedItemEl);
|
||||
|
||||
delItemEl.click($.proxy(handlers._onTagTriggerClick, ref));
|
||||
}
|
||||
@ -1037,7 +1044,7 @@
|
||||
if(cfg.selectionPosition === 'inner') {
|
||||
ms.input.width(0);
|
||||
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.container.height(ms.selectionContainer.height());
|
||||
}
|
||||
@ -1281,8 +1288,9 @@
|
||||
e.preventDefault();
|
||||
}
|
||||
break;
|
||||
case 188: // comma
|
||||
if(e.shiftKey) break; // Shift + , = < on some keyboards
|
||||
case 9: // tab
|
||||
case 188: // esc
|
||||
case 13: // enter
|
||||
e.preventDefault();
|
||||
break;
|
||||
@ -1337,7 +1345,8 @@
|
||||
e.preventDefault();
|
||||
break;
|
||||
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();
|
||||
if(cfg.expanded === true){ // if a selection is performed, select it and reset field
|
||||
selected = ms.combobox.find('.ms-res-item-active:first');
|
||||
@ -1471,4 +1480,6 @@
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
// $.fn.magicSuggest.defaults = {};
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user