From f9dd84adb5c39c81d99f62a624fcf3538367a3e4 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 28 Oct 2014 22:09:12 +0000 Subject: [PATCH 1/3] fix sql error on update --- calendar/setup/tables_update.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index ed3b17c47e..579ef3fcaa 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -2310,8 +2310,8 @@ function calendar_upgrade14_1() { $GLOBALS['egw_setup']->db->query( "UPDATE egw_cal -SET cal_reference=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time(). -"WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__); +SET cal_reference=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time()." +WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__); foreach($GLOBALS['egw_setup']->db->query( "SELECT DISTINCT master.cal_id,egw_cal_user.cal_user_type,egw_cal_user.cal_user_id,'E' AS cal_status From 00136ae83b6e8ac3b2c435174f81f4f704c4a223 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 29 Oct 2014 11:00:22 +0000 Subject: [PATCH 2/3] Not used plugin, but included --- phpgwapi/js/egw_action/egw_action_dragdrop.js | 1 - 1 file changed, 1 deletion(-) diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index ea9797a56c..a4b2d5961a 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -15,7 +15,6 @@ egw_action_popup; jquery.jquery; jquery.jquery-ui; - /phpgwapi/js/jquery/jquery-ui-touch-punch/touch.js; */ /** From c555d52e0dce501cfab0bef6fe88f606efb90747 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 29 Oct 2014 11:02:08 +0000 Subject: [PATCH 3/3] Update magicsuggest plugin --- phpgwapi/js/jquery/magicsuggest/README_1.md | 109 +++ .../bin/magicsuggest-1.3.1-min.css | 1 - .../bin/magicsuggest-1.3.1-min.js | 1 - phpgwapi/js/jquery/magicsuggest/bower.json | 9 + phpgwapi/js/jquery/magicsuggest/composer.json | 22 + .../jquery/magicsuggest/magicsuggest-min.css | 1 + .../jquery/magicsuggest/magicsuggest-min.js | 1 + ...agicsuggest-1.3.1.css => magicsuggest.css} | 196 ++-- .../magicsuggest/magicsuggest.jquery.json | 36 + .../magicsuggest-1.3.1.js => magicsuggest.js} | 869 ++++++++++-------- 10 files changed, 768 insertions(+), 477 deletions(-) create mode 100644 phpgwapi/js/jquery/magicsuggest/README_1.md delete mode 100644 phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css delete mode 100644 phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js create mode 100644 phpgwapi/js/jquery/magicsuggest/bower.json create mode 100644 phpgwapi/js/jquery/magicsuggest/composer.json create mode 100644 phpgwapi/js/jquery/magicsuggest/magicsuggest-min.css create mode 100644 phpgwapi/js/jquery/magicsuggest/magicsuggest-min.js rename phpgwapi/js/jquery/magicsuggest/{src/magicsuggest-1.3.1.css => magicsuggest.css} (73%) create mode 100644 phpgwapi/js/jquery/magicsuggest/magicsuggest.jquery.json rename phpgwapi/js/jquery/magicsuggest/{src/magicsuggest-1.3.1.js => magicsuggest.js} (64%) diff --git a/phpgwapi/js/jquery/magicsuggest/README_1.md b/phpgwapi/js/jquery/magicsuggest/README_1.md new file mode 100644 index 0000000000..4deb74ca3c --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/README_1.md @@ -0,0 +1,109 @@ +MagicSuggest v2.0.0 +-------------------------- +MagicSuggest has a new home here: http://nicolasbize.com/magicsuggest/ +It includes a great new API documentation, examples, tutorials and more! + +Milestone change log: + +MagicSuggest v.2.0.0 +==================== +- New home at http://nicolasbize.com/magicsuggest/ to run dynamic examples that gh-pages couldn't handle +- Now runs with Bootstrap 3 (required) +- Responsive design +- No more intrusive loading + +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) +- (fix) CSS bug with 1.2.7+ with triggerHidden (credits to ScullWM - https://github.com/ScullWM) +- (fix) container would always render with 1 row even though a bunch of data was loaded (credits to travishaagen - https://github.com/travishaagen) +- (fea) added minimum jQuery version to work in docs (credits to rajeshmeniya - https://github.com/rajeshmeniya) +- (fix) input was not correctly enabled / disabled (credits to zerekw - https://github.com/zerekw) +- (fea) added getName and setName to easily fetch/set form name of component (credits to jbmoens - https://github.com/jbmoens) +- (fix) when a value is specified in the DOM original element, it is passed correctly to MS. (credits to jbmoens - https://github.com/jbmoens) +- (fix) input space now always uses the remaining space as this leads to less issues. +- (fea) combo has now more logic when used for a single selection combo box. +- (fix) space taken for single selection on a small combo remains on one line. (credits to ScullWM - https://github.com/ScullWM) +- (fea) multiple items can now be selected through the Ctrl key (credits to meghuizen - https://github.com/meghuizen) +- (fea) trigger icon now uses pure CSS (credits to meghuizen - https://github.com/meghuizen) +- (fea) cfg(data) can now take a function as parameter (credits to meghuizen - https://github.com/meghuizen) +- (fea) cfg(data) can take a json object whose data items are within the results property +- (fix) CSS has been fixed so it behaves correctly within a bootstrap modal (credits to daenuprobst - https://github.com/daenuprobst) +- (fea) suggestion rendering optimized by reducing draw calls to one. (credits to meghuizen - https://github.com/meghuizen) +- (fix) tags can now longer be removed when the combo is disabled (credits to grena - https://github.com/grena) +- (fix) setting data was only going through visible set of suggestions (credits to grena - https://github.com/grena) +- (fix) missing semi-colons, went through full jslint (credits to grena - https://github.com/grena) +- (fix) suggestions were not appearing when maxSuggestions was set to 10. (credits to zerekw - https://github.com/zerekw and plasmaxy - https://github.com/plasmaxy) +- (fix) the clear function was broken (credits to travishaagen - https://github.com/travishaagen) +- (fea) the component's config can now be setup entirely from the DOM container element. +- (fea) added a silent mode to selection changing methods in order to know if it was user-triggered or not. (credits to travishaagen - https://github.com/travishaagen) +- (fea) added a setData(object) method to fill the combo after it has been rendered (credits to travishaagen - https://github.com/travishaagen) +- (fix) ajax query was sent twice when the user was typing faster than the typeDelay (credits to arvenom - https://github.com/arvenom) +- (fix) highlighting the search results was also highlighting html tags when using custom rendering (credits to pstuart2 - https://github.com/pstuart2) +- (fea) added cfg(strictSuggest) so that user can choose how the suggestions will be made +- (fea) added cfg(toggleOnClick) so that the user can expand/close the combo by clicking on it (credits to psulek - https://github.com/psulek) +- (fix) empty suggestion text was wrongly triggered when performing initial ajax call (credits to curtgrimes - https://github.com/curtgrimes) +- (fea) added cfg(selectionRenderer) (credits to pstuart2 - https://github.com/pstuart2) +- (fix) empty text class was not triggered properly (credits to jods4 - https://github.com/jods4) +- (fix) IE8 compatibility (credits to Airborn22 - https://github.com/Airborn22) +- (fea) MagicSuggest can now be rendered from a select dom component. (credits to Yogu - https://github.com/Yogu) +- (fea) on blur now automatically adds the typed text to the selection if free entries are allowed (credits to Airborn22 - https://github.com/Airborn22) +- (fea) new public method empty() which will clear the user text. +- (fix) make sure combo is filled prior to triggering load event +- (fea) renamed some events for better readability + +v1.2.0 Standardization on jQuery plugins (Minor Tagged Milestone - Mar. 4th 2013) +================================================================================= +- (fix) fixed disabled behaviour when one could still edit the emptyText +- (fix) collapse method would throw an error +- (cfg) typeDelay: Amount (in ms) between keyboard registers (credits to jayesbee - https://github.com/jayesbee) +- (fea) standardized on jQuery plugin (credits to jayesbee - https://github.com/jayesbee) +- (fea) added documentation examples +- (cfg) name: name used for magicsuggest as a form element (credits to iambibhas - https://github.com/iambibhas) +- (fix) start up rendering when value rendered as text +- (cfg) dataParams: additional parameters for ajax request (credits to jayesbee - https://github.com/jayesbee) +- (fix) other rendering issues with inner text + +v1.1.0 Various enhancements and bug fixing (Minor Tagged Milestone - Feb. 19th 2013) +==================================================================================== +- (fea) close cross style now blends in a bit more +- (fea) escape now collapses the combo (without loosing focus) +- (fix) can't enter entries made out of space +- (cfg) noSuggestionText: text displayed when there are no suggestions from given data +- (cfg) minCharsRenderer: allows to customize message when not enough characters are entered to trigger a search +- (cfg) maxEntryRenderer: allows to customize message when too many characters have been entered +- (cfg) maxEntryLength: amount of characters to limit user input +- (cfg) style: custom style applied to the main container +- (cfg) infoMsgCls: custom class to apply to the helper +- (fea) new helper message on upper right to inform on the component status +- (cfg) id: allows to give the component a custom ID +- (cfg) inputCfg : allows additional parameters passed out to the INPUT tag. Enables usage of AngularJS's custom tags for ex. +- (cfg) renderer : allows custom rendering within the combo. +- (cfg) groupBy : allows grouping within the combo box listing. +- (fix) blur event now registers correctly when selecting an element from the combo +- (fix) flicker in IE when hovering trigger +- (cfg) strictSuggest : set how suggestions will be proposed +- (fix) maxResults is now correctly interpreted +- (fix) maxSelection is now correctly interpreted +- (cfg) method : set the ajax method, default to 'POST' +- (fea) ajax request can now interpret multiple results from server base. +- (fix) bug where the blur event would be triggered when clicking upon the page +- (cfg) required : triggers invalid / valid events when not filled +- (fea) validation through isValid() method + +v1.0. initial component release +=============================== +- choose to allow free entries or not +- keyboard management +- theme ability +- static and dynamic data processing +- positionning \ No newline at end of file diff --git a/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css b/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css deleted file mode 100644 index 7ff8ef0f7b..0000000000 --- a/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.css +++ /dev/null @@ -1 +0,0 @@ -.ms-ctn{position:relative;height:28px;padding:0;margin-bottom:0;font-size:14px;line-height:20px;color:#555;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s;cursor:default;display:block}.ms-ctn-invalid{border:1px solid #c00}.ms-ctn-readonly{cursor:pointer}.ms-ctn-disabled{cursor:not-allowed;background-color:#eee}.ms-ctn-bootstrap-focus,.ms-ctn-bootstrap-focus .ms-res-ctn{border-color:rgba(82,168,236,0.8)!important;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;border-bottom-left-radius:0;border-bottom-right-radius:0}.ms-ctn input{border:0;box-shadow:none;-webkit-transition:none;outline:0;display:block;padding:4px 6px;line-height:normal;overflow:hidden;height:auto;border-radius:0;float:left;margin:2px 0 2px 2px}.ms-ctn-disabled input{cursor:not-allowed;background-color:#eee}.ms-ctn .ms-input-readonly{cursor:pointer}.ms-ctn .ms-empty-text{color:#DDD}.ms-ctn input:focus{border:0;box-shadow:none;-webkit-transition:none;background:#FFF}.ms-ctn .ms-trigger{float:right;width:27px;height:100%;position:absolute;right:0;border-left:1px solid #CCC;background:#EEE;cursor:pointer}.ms-ctn .ms-trigger .ms-trigger-ico{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid gray;border-right:4px solid transparent;border-left:4px solid transparent;content:"";margin-left:9px;margin-top:13px}.ms-ctn .ms-trigger:hover{background:-moz-linear-gradient(100% 100% 90deg,#e3e3e3,#f1f1f1);background:-webkit-gradient(linear,0% 0,0% 100%,from(#f1f1f1),to(#e3e3e3))}.ms-ctn .ms-trigger:hover .ms-trigger-ico{background-position:0 -4px}.ms-ctn-disabled .ms-trigger{cursor:not-allowed;background-color:#eee}.ms-ctn-bootstrap-focus{border-bottom:1px solid #CCC}.ms-res-ctn{position:relative;background:#FFF;overflow-y:auto;z-index:9999;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;border:1px solid #CCC;left:-1px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s;border-top:0;border-top-left-radius:0;border-top-right-radius:0}.ms-res-ctn .ms-res-group{line-height:23px;text-align:left;padding:2px 5px;font-weight:bold;border-bottom:1px dotted #CCC;border-top:1px solid #CCC;background:#f3edff;color:#333}.ms-res-ctn .ms-res-item{line-height:25px;text-align:left;padding:2px 5px;color:#666;cursor:pointer}.ms-res-ctn .ms-res-item-grouped{padding-left:15px}.ms-res-ctn .ms-res-odd{background:#f3f3f3}.ms-res-ctn .ms-res-item-active{background-color:#3875d7;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3875D7',endColorstr='#2A62BC',GradientType=0);background-image:-webkit-gradient(linear,0 0,0 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(top,#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(top,#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(top,#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.ms-sel-ctn{overflow:auto;line-height:22px;padding-right:27px}.ms-sel-ctn .ms-sel-item{background:#555;color:#EEE;float:left;font-size:12px;padding:0 5px;border-radius:3px;margin-left:5px;margin-top:4px}.ms-sel-ctn .ms-sel-text{background:#FFF;color:#666;padding-right:0;margin-left:0;font-size:14px;font-weight:normal}.ms-res-ctn .ms-res-item em{font-style:normal;background:#565656;color:#FFF}.ms-sel-ctn .ms-sel-item:hover{background:#565656}.ms-sel-ctn .ms-sel-text:hover{background:#FFF}.ms-sel-ctn .ms-sel-item-active{border:1px solid red;background:#757575}.ms-ctn .ms-sel-ctn .ms-sel-item{margin-top:3px}.ms-stacked .ms-sel-item{float:inherit}.ms-sel-ctn .ms-sel-item .ms-close-btn{width:7px;cursor:pointer;height:7px;float:right;margin:8px 2px 0 10px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAOCAYAAADjXQYbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZ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JjTmYWOU1L4tdck9GE17dnALGAS+kAR/u2AAAAAElFTkSuQmCC)}.ms-sel-ctn .ms-sel-item .ms-close-btn:hover{background-position:0 -7px}.ms-helper{color:#AAA;font-size:10px;position:absolute;top:-17px;right:0} \ No newline at end of file diff --git a/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js b/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js deleted file mode 100644 index 9b6499a510..0000000000 --- a/phpgwapi/js/jquery/magicsuggest/bin/magicsuggest-1.3.1-min.js +++ /dev/null @@ -1 +0,0 @@ -(function($){"use strict";var MagicSuggest=function(element,options){var ms=this;var defaults={allowFreeEntries:true,cls:"",data:null,dataUrlParams:{},disabled:false,displayField:"name",editable:true,emptyText:function(){return cfg.editable?"Type or click here":"Click here"},emptyTextCls:"ms-empty-text",expanded:false,expandOnFocus:function(){return cfg.editable?false:true},groupBy:null,hideTrigger:false,highlight:true,id:function(){return"ms-ctn-"+$('div[id^="ms-ctn"]').length},infoMsgCls:"",inputCfg:{},invalidCls:"ms-ctn-invalid",matchCase:false,maxDropHeight:290,maxEntryLength:null,maxEntryRenderer:function(v){return"Please reduce your entry by "+v+" character"+(v>1?"s":"")},maxSuggestions:null,maxSelection:10,maxSelectionRenderer:function(v){return"You cannot choose more than "+v+" item"+(v>1?"s":"")},method:"POST",minChars:0,minCharsRenderer:function(v){return"Please type "+v+" more character"+(v>1?"s":"")},name:null,noSuggestionText:"No suggestions",preselectSingleSuggestion:true,renderer:null,required:false,resultAsString:false,resultsField:"results",selectionCls:"",selectionPosition:"inner",selectionRenderer:null,selectionStacked:false,sortDir:"asc",sortOrder:null,strictSuggest:false,style:"",toggleOnClick:false,typeDelay:400,useTabKey:false,useCommaKey:true,useZebraStyle:true,value:null,valueField:"id",width:function(){return $(this).width()}};var conf=$.extend({},options);var cfg=$.extend(true,{},defaults,conf);if($.isFunction(cfg.emptyText)){cfg.emptyText=cfg.emptyText.call(this)}if($.isFunction(cfg.expandOnFocus)){cfg.expandOnFocus=cfg.expandOnFocus.call(this)}if($.isFunction(cfg.id)){cfg.id=cfg.id.call(this)}this.addToSelection=function(items,isSilent){if(!cfg.maxSelection||_selection.length=cfg.minChars||this.combobox.children().size()>0)){this.combobox.appendTo(this.container);self._processSuggestions();cfg.expanded=true;$(this).trigger("expand",[this])}};this.isDisabled=function(){return cfg.disabled};this.isValid=function(){return cfg.required===false||_selection.length>0};this.getDataUrlParams=function(){return cfg.dataUrlParams};this.getName=function(){return cfg.name};this.getSelectedItems=function(){return _selection};this.getRawValue=function(){return ms.input.val()!==cfg.emptyText?ms.input.val():""};this.getValue=function(){return $.map(_selection,function(o){return o[cfg.valueField]})};this.removeFromSelection=function(items,isSilent){if(!$.isArray(items)){items=[items]}var valuechanged=false;$.each(items,function(index,json){var i=$.inArray(json[cfg.valueField],ms.getValue());if(i>-1){_selection.splice(i,1);valuechanged=true}});if(valuechanged===true){self._renderSelection();if(isSilent!==true){$(this).trigger("selectionchange",[this,this.getSelectedItems()])}if(cfg.expandOnFocus){ms.expand()}if(cfg.expanded){self._processSuggestions()}}};this.setData=function(data){cfg.data=data;self._processSuggestions()};this.setName=function(name){cfg.name=name;if(ms._valueContainer){ms._valueContainer.name=name}};this.setValue=function(data){var values=data,items=[];if(!$.isArray(data)){if(typeof data==="string"){if(data.indexOf("[")>-1){values=eval(data)}else if(data.indexOf(",")>-1){values=data.split(",")}}else{values=[data]}}$.each(_cbData,function(index,obj){if($.inArray(obj[cfg.valueField],values)>-1){items.push(obj)}});if(items.length>0){this.addToSelection(items)}};this.setDataUrlParams=function(params){cfg.dataUrlParams=$.extend({},params)};var _selection=[],_comboItemHeight=0,_timer,_hasFocus=false,_groups=null,_cbData=[],_ctrlDown=false;var self={_displaySuggestions:function(data){ms.combobox.empty();var resHeight=0,nbGroups=0;if(_groups===null){self._renderComboItems(data);resHeight=_comboItemHeight*data.length}else{for(var grpName in _groups){nbGroups+=1;$("
",{"class":"ms-res-group",html:grpName}).appendTo(ms.combobox);self._renderComboItems(_groups[grpName].items,true)}resHeight=_comboItemHeight*(data.length+nbGroups)}if(resHeight=ms.combobox.height()&&resHeight>cfg.maxDropHeight){ms.combobox.height(cfg.maxDropHeight)}if(data.length===1&&cfg.preselectSingleSuggestion===true){ms.combobox.children().filter(":last").addClass("ms-res-item-active")}if(data.length===0&&ms.getRawValue()!==""){self._updateHelper(cfg.noSuggestionText);ms.collapse()}},_getEntriesFromStringArray:function(data){var json=[];$.each(data,function(index,s){var entry={};entry[cfg.displayField]=entry[cfg.valueField]=$.trim(s);json.push(entry)});return json},_highlightSuggestion:function(html){var q=ms.input.val()!==cfg.emptyText?ms.input.val():"";if(q.length===0){return html}if(cfg.matchCase===true){html=html.replace(new RegExp("("+q+")(?!([^<]+)?>)","g"),"$1")}else{html=html.replace(new RegExp("("+q+")(?!([^<]+)?>)","gi"),"$1")}return html},_moveSelectedRow:function(dir){if(!cfg.expanded){ms.expand()}var list,start,active,scrollPos;list=ms.combobox.find(".ms-res-item");if(dir==="down"){start=list.eq(0)}else{start=list.filter(":last")}active=ms.combobox.find(".ms-res-item-active:first");if(active.length>0){if(dir==="down"){start=active.nextAll(".ms-res-item").first();if(start.length===0){start=list.eq(0)}scrollPos=ms.combobox.scrollTop();ms.combobox.scrollTop(0);if(start[0].offsetTop+start.outerHeight()>ms.combobox.height()){ms.combobox.scrollTop(scrollPos+_comboItemHeight)}}else{start=active.prevAll(".ms-res-item").first();if(start.length===0){start=list.filter(":last");ms.combobox.scrollTop(_comboItemHeight*list.length)}if(start[0].offsetTop-1){_cbData=self._getEntriesFromStringArray(data.split(","))}else{if(data.length>0&&typeof data[0]==="string"){_cbData=self._getEntriesFromStringArray(data)}else{_cbData=data[cfg.resultsField]||data}}self._displaySuggestions(self._sortAndTrim(_cbData))}},_render:function(el){$(ms).trigger("beforerender",[ms]);var w=$.isFunction(cfg.width)?cfg.width.call(el):cfg.width;ms.container=$("
",{id:cfg.id,"class":"ms-ctn "+cfg.cls+(cfg.disabled===true?" ms-ctn-disabled":"")+(cfg.editable===true?"":" ms-ctn-readonly"),style:cfg.style}).width(w);ms.container.focus($.proxy(handlers._onFocus,this));ms.container.blur($.proxy(handlers._onBlur,this));ms.container.keydown($.proxy(handlers._onKeyDown,this));ms.container.keyup($.proxy(handlers._onKeyUp,this));ms.input=$("",$.extend({id:"ms-input-"+$('input[id^="ms-input"]').length,type:"text","class":cfg.emptyTextCls+(cfg.editable===true?"":" ms-input-readonly"),value:cfg.emptyText,readonly:!cfg.editable,disabled:cfg.disabled},cfg.inputCfg)).width(w-(cfg.hideTrigger?16:42));ms.input.focus($.proxy(handlers._onInputFocus,this));ms.input.click($.proxy(handlers._onInputClick,this));if(cfg.hideTrigger===false){ms.trigger=$("
",{id:"ms-trigger-"+$('div[id^="ms-trigger"]').length,"class":"ms-trigger",html:'
'});ms.trigger.click($.proxy(handlers._onTriggerClick,this));ms.container.append(ms.trigger)}ms.combobox=$("
",{id:"ms-res-ctn-"+$('div[id^="ms-res-ctn"]').length,"class":"ms-res-ctn "}).width(w).height(cfg.maxDropHeight);ms.combobox.on("click","div.ms-res-item",$.proxy(handlers._onComboItemSelected,this));ms.combobox.on("mouseover","div.ms-res-item",$.proxy(handlers._onComboItemMouseOver,this));ms.selectionContainer=$("
",{id:"ms-sel-ctn-"+$('div[id^="ms-sel-ctn"]').length,"class":"ms-sel-ctn"});ms.selectionContainer.click($.proxy(handlers._onFocus,this));if(cfg.selectionPosition==="inner"){ms.selectionContainer.append(ms.input)}else{ms.container.append(ms.input)}ms.helper=$("
",{"class":"ms-helper "+cfg.infoMsgCls});self._updateHelper();ms.container.append(ms.helper);$(el).replaceWith(ms.container);switch(cfg.selectionPosition){case"bottom":ms.selectionContainer.insertAfter(ms.container);if(cfg.selectionStacked===true){ms.selectionContainer.width(ms.container.width());ms.selectionContainer.addClass("ms-stacked")}break;case"right":ms.selectionContainer.insertAfter(ms.container);ms.container.css("float","left");break;default:ms.container.append(ms.selectionContainer);break}self._processSuggestions();if(cfg.value!==null){ms.setValue(cfg.value);self._renderSelection()}$(ms).trigger("afterrender",[ms]);$("body").click(function(e){if(ms.container.hasClass("ms-ctn-bootstrap-focus")&&ms.container.has(e.target).length===0&&e.target.className.indexOf("ms-res-item")<0&&e.target.className.indexOf("ms-close-btn")<0&&ms.container[0]!==e.target){handlers._onBlur()}});if(cfg.expanded===true){cfg.expanded=false;ms.expand()}},_renderComboItems:function(items,isGrouped){var ref=this,html="";$.each(items,function(index,value){var displayed=cfg.renderer!==null?cfg.renderer.call(ref,value):value[cfg.displayField];var resultItemEl=$("
",{"class":"ms-res-item "+(isGrouped?"ms-res-item-grouped ":"")+(index%2===1&&cfg.useZebraStyle===true?"ms-res-odd":""),html:cfg.highlight===true?self._highlightSuggestion(displayed):displayed,"data-json":JSON.stringify(value)});resultItemEl.click($.proxy(handlers._onComboItemSelected,ref));resultItemEl.mouseover($.proxy(handlers._onComboItemMouseOver,ref));html+=$("
").append(resultItemEl).html()});ms.combobox.append(html);_comboItemHeight=ms.combobox.find(".ms-res-item:first").outerHeight()},_renderSelection:function(){var ref=this,w=0,inputOffset=0,items=[],asText=cfg.resultAsString===true&&!_hasFocus;ms.selectionContainer.find(".ms-sel-item").remove();if(ms._valueContainer!==undefined){ms._valueContainer.remove()}$.each(_selection,function(index,value){var selectedItemEl,delItemEl,selectedItemHtml=cfg.selectionRenderer!==null?cfg.selectionRenderer.call(ref,value):value[cfg.displayField];if(asText===true){selectedItemEl=$("
",{"class":"ms-sel-item ms-sel-text "+cfg.selectionCls,html:selectedItemHtml+(index===_selection.length-1?"":",")}).data("json",value)}else{selectedItemEl=$("
",{"class":"ms-sel-item "+cfg.selectionCls,html:selectedItemHtml}).data("json",value);if(cfg.disabled===false){delItemEl=$("",{"class":"ms-close-btn"}).data("json",value).appendTo(selectedItemEl);delItemEl.click($.proxy(handlers._onTagTriggerClick,ref))}}items.push(selectedItemEl)});ms.selectionContainer.prepend(items);ms._valueContainer=$("",{type:"hidden",name:cfg.name,value:JSON.stringify(ms.getValue())});ms._valueContainer.appendTo(ms.selectionContainer);if(cfg.selectionPosition==="inner"){ms.input.width(0);inputOffset=ms.input.offset().left-ms.selectionContainer.offset().left;w=ms.container.width()-inputOffset-42;ms.input.width(w);ms.container.height(ms.selectionContainer.height())}if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else{ms.helper.hide()}},_selectItem:function(item){if(cfg.maxSelection===1){_selection=[]}ms.addToSelection(item.data("json"));item.removeClass("ms-res-item-active");if(cfg.expandOnFocus===false||_selection.length===cfg.maxSelection){ms.collapse()}if(!_hasFocus){ms.input.focus()}else if(_hasFocus&&(cfg.expandOnFocus||_ctrlDown)){self._processSuggestions();if(_ctrlDown){ms.expand()}}},_sortAndTrim:function(data){var q=ms.getRawValue(),filtered=[],newSuggestions=[],selectedValues=ms.getValue();if(q.length>0){$.each(data,function(index,obj){var name=obj[cfg.displayField];if(cfg.matchCase===true&&name.indexOf(q)>-1||cfg.matchCase===false&&name.toLowerCase().indexOf(q.toLowerCase())>-1){if(cfg.strictSuggest===false||name.toLowerCase().indexOf(q.toLowerCase())===0){filtered.push(obj)}}})}else{filtered=data}$.each(filtered,function(index,obj){if($.inArray(obj[cfg.valueField],selectedValues)===-1){newSuggestions.push(obj)}});if(cfg.sortOrder!==null){newSuggestions.sort(function(a,b){if(a[cfg.sortOrder]b[cfg.sortOrder]){return cfg.sortDir==="asc"?1:-1}return 0})}if(cfg.maxSuggestions&&cfg.maxSuggestions>0){newSuggestions=newSuggestions.slice(0,cfg.maxSuggestions)}if(cfg.groupBy!==null){_groups={};$.each(newSuggestions,function(index,value){if(_groups[value[cfg.groupBy]]===undefined){_groups[value[cfg.groupBy]]={title:value[cfg.groupBy],items:[value]}}else{_groups[value[cfg.groupBy]].items.push(value)}})}return newSuggestions},_updateHelper:function(html){ms.helper.html(html);if(!ms.helper.is(":visible")){ms.helper.fadeIn()}}};var handlers={_onBlur:function(){ms.container.removeClass("ms-ctn-bootstrap-focus");ms.collapse();_hasFocus=false;if(ms.getRawValue()!==""&&cfg.allowFreeEntries===true){var obj={};obj[cfg.displayField]=obj[cfg.valueField]=ms.getRawValue();ms.addToSelection(obj)}self._renderSelection();if(ms.isValid()===false){ms.container.addClass("ms-ctn-invalid")}if(ms.input.val()===""&&_selection.length===0){ms.input.addClass(cfg.emptyTextCls);ms.input.val(cfg.emptyText)}else if(ms.input.val()!==""&&cfg.allowFreeEntries===false){ms.empty();self._updateHelper("")}if(ms.input.is(":focus")){$(ms).trigger("blur",[ms])}},_onComboItemMouseOver:function(e){ms.combobox.children().removeClass("ms-res-item-active");$(e.currentTarget).addClass("ms-res-item-active")},_onComboItemSelected:function(e){self._selectItem($(e.currentTarget))},_onFocus:function(){ms.input.focus()},_onInputClick:function(){if(ms.isDisabled()===false&&_hasFocus){if(cfg.toggleOnClick===true){if(cfg.expanded){ms.collapse()}else{ms.expand()}}}},_onInputFocus:function(){if(ms.isDisabled()===false&&!_hasFocus){_hasFocus=true;ms.container.addClass("ms-ctn-bootstrap-focus");ms.container.removeClass(cfg.invalidCls);if(ms.input.val()===cfg.emptyText){ms.empty()}var curLength=ms.getRawValue().length;if(cfg.expandOnFocus===true){ms.expand()}if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else if(curLength0&&cfg.selectionPosition==="inner"){_selection.pop();self._renderSelection();$(ms).trigger("selectionchange",[ms,ms.getSelectedItems()]);ms.input.focus();e.preventDefault()}break;case 9:case 188:case 13:e.preventDefault();break;case 17:_ctrlDown=true;break;case 40:e.preventDefault();self._moveSelectedRow("down");break;case 38:e.preventDefault();self._moveSelectedRow("up");break;default:if(_selection.length===cfg.maxSelection){e.preventDefault()}break}},_onKeyUp:function(e){var freeInput=ms.getRawValue(),inputValid=$.trim(ms.input.val()).length>0&&ms.input.val()!==cfg.emptyText&&(!cfg.maxEntryLength||$.trim(ms.input.val()).length<=cfg.maxEntryLength),selected,obj={};$(ms).trigger("keyup",[ms,e]);clearTimeout(_timer);if(e.keyCode===27&&cfg.expanded){ms.combobox.height(0)}if(e.keyCode===9&&cfg.useTabKey===false||e.keyCode>13&&e.keyCode<32){if(e.keyCode===17){_ctrlDown=false}return}switch(e.keyCode){case 40:case 38:e.preventDefault();break;case 13:case 9:case 188:if(e.keyCode!==188||cfg.useCommaKey===true){e.preventDefault();if(cfg.expanded===true){selected=ms.combobox.find(".ms-res-item-active:first");if(selected.length>0){self._selectItem(selected);return}}if(inputValid===true&&cfg.allowFreeEntries===true){obj[cfg.displayField]=obj[cfg.valueField]=freeInput;ms.addToSelection(obj);ms.collapse();ms.input.focus()}break}default:if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else{if(freeInput.lengthcfg.maxEntryLength){self._updateHelper(cfg.maxEntryRenderer.call(this,freeInput.length-cfg.maxEntryLength));if(cfg.expanded===true){ms.collapse()}}else{ms.helper.hide();if(cfg.minChars<=freeInput.length){_timer=setTimeout(function(){if(cfg.expanded===true){self._processSuggestions()}else{ms.expand()}},cfg.typeDelay)}}}break}},_onTagTriggerClick:function(e){ms.removeFromSelection($(e.currentTarget).data("json"))},_onTriggerClick:function(){if(ms.isDisabled()===false&&!(cfg.expandOnFocus===true&&_selection.length===cfg.maxSelection)){$(ms).trigger("triggerclick",[ms]);if(cfg.expanded===true){ms.collapse()}else{var curLength=ms.getRawValue().length;if(curLength>=cfg.minChars){ms.input.focus();ms.expand()}else{self._updateHelper(cfg.minCharsRenderer.call(this,cfg.minChars-curLength))}}}}};if(element!==null){self._render(element)}};$.fn.magicSuggest=function(options){var obj=$(this);if(obj.size()===1&&obj.data("magicSuggest")){return obj.data("magicSuggest")}obj.each(function(i){var cntr=$(this);if(cntr.data("magicSuggest")){return}if(this.nodeName.toLowerCase()==="select"){options.data=[];options.value=[];$.each(this.children,function(index,child){if(child.nodeName&&child.nodeName.toLowerCase()==="option"){options.data.push({id:child.value,name:child.text});if(child.selected){options.value.push(child.value)}}})}var def={};$.each(this.attributes,function(i,att){def[att.name]=att.value});var field=new MagicSuggest(this,$.extend(options,def));cntr.data("magicSuggest",field);field.container.data("magicSuggest",field)});if(obj.size()===1){return obj.data("magicSuggest")}return obj}})(jQuery); \ No newline at end of file diff --git a/phpgwapi/js/jquery/magicsuggest/bower.json b/phpgwapi/js/jquery/magicsuggest/bower.json new file mode 100644 index 0000000000..1955cade59 --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/bower.json @@ -0,0 +1,9 @@ +{ + "name": "magicsuggest", + "version": "2.1.4", + "main": ["magicsuggest.js", "magicsuggest.css"], + "dependencies": { + "bootstrap": "~3", + "jquery": ">= 1.8.3" + } +} diff --git a/phpgwapi/js/jquery/magicsuggest/composer.json b/phpgwapi/js/jquery/magicsuggest/composer.json new file mode 100644 index 0000000000..ae0fd8a0c3 --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/composer.json @@ -0,0 +1,22 @@ +{ + "name": "nicolasbize/magicsuggest", + "description": "MagicSuggest is a multiple selection auto suggest combo box for Bootstrap 3.", + "version": "2.1.4", + "type": "component", + "homepage": "http://nicolasbize.com/magicsuggest", + "license": "MIT", + "require": { + "components/bootstrap": ">=3.0.0", + "components/jquery": ">=1.8.3" + }, + "extra": { + "component": { + "scripts": [ + "magicsuggest.js" + ], + "files": [ + "magicsuggest.css" + ] + } + } +} diff --git a/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.css b/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.css new file mode 100644 index 0000000000..4639434a96 --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.css @@ -0,0 +1 @@ +.ms-ctn{position:relative;padding:5px 12px;height:auto}.ms-inv{border:1px solid #c00}.ms-ctn-readonly{cursor:pointer}.ms-ctn-disabled{cursor:not-allowed;background-color:#eee}.ms-ctn-bootstrap-focus,.ms-ctn-bootstrap-focus .ms-res-ctn{border-color:rgba(82,168,236,0.8)!important;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)!important;border-bottom-left-radius:0;border-bottom-right-radius:0}.ms-ctn-focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.ms-ctn input{border:0;box-shadow:none;-webkit-transition:none;outline:0;display:block;padding:0;line-height:1.42857143;margin:1px 0;width:100%}.ms-ctn .ms-sel-ctn input{float:left}.ms-ctn-disabled input{cursor:not-allowed;background-color:#eee}.ms-ctn .ms-input-readonly{cursor:pointer}.ms-ctn .ms-empty-text{color:#DDD}.ms-ctn input:focus{border:0;box-shadow:none;-webkit-transition:none;background:#FFF}.ms-ctn input::-ms-clear{width:0;height:0}.ms-ctn .ms-trigger{top:0;width:25px;height:100%;position:absolute;right:0;background:transparent;border-left:1px solid #CCC;cursor:pointer}.ms-ctn .ms-trigger .ms-trigger-ico{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #333;border-right:4px solid transparent;border-left:4px solid transparent;content:"";margin-left:8px;margin-top:15px}.ms-ctn .ms-trigger:hover{background-color:#e6e6e6}.ms-ctn .ms-trigger:hover .ms-trigger-ico{background-position:0 -4px}.ms-ctn-disabled .ms-trigger{cursor:not-allowed;background-color:#eee}.ms-ctn-bootstrap-focus{border-bottom:1px solid #CCC}.ms-res-ctn{width:100%;display:block;overflow-y:auto}.ms-res-ctn .ms-res-group{line-height:23px;text-align:left;padding:2px 5px;font-weight:bold;border-bottom:1px dotted #CCC;border-top:1px solid #CCC;background:#f3edff;color:#333}.ms-res-ctn .ms-res-item{line-height:25px;text-align:left;padding:2px 5px;color:#666;cursor:pointer}.ms-res-ctn .ms-res-item-grouped{padding-left:15px}.ms-res-ctn .ms-res-odd{background:#fafafa}.ms-res-ctn .ms-res-item-active{background-color:#f5f5f5}.ms-res-ctn .ms-res-item-disabled{color:#CCC;cursor:default}.ms-sel-ctn{overflow:auto;line-height:18px;padding-right:25px}.ms-no-trigger .ms-sel-ctn{padding-right:0}.ms-sel-ctn .ms-sel-item{background:#f3f3f3;color:#999;float:left;font-size:12px;padding:3px 5px;border-radius:3px;border:1px solid #DDD;margin:3px 0 1px 0}.ms-sel-ctn .ms-sel-invalid{border-color:#f8a5a5!important;background:#fdf2f2!important}.ms-sel-ctn .ms-sel-item:hover{border:1px solid #BBB}.ms-ctn .ms-sel-item{background:#f3f3f3;color:#999;float:left;font-size:12px;padding:0 5px;border-radius:3px;border:1px solid #DDD;margin:1px 5px 1px 0}.ms-ctn .ms-sel-item:hover{border:1px solid transparent}.ms-ctn-focus .ms-sel-item:hover{border:1px solid #BBB}.ms-sel-ctn .ms-sel-text{background:#FFF;color:#666;padding-right:0;margin-left:0;font-size:14px;font-weight:normal}.ms-as-string .ms-sel-text{border-color:transparent}.ms-res-ctn .ms-res-item em{font-style:normal;background:#565656;color:#FFF}.ms-sel-ctn .ms-sel-text:hover{background:#FFF}.ms-sel-ctn .ms-sel-item-active{border:1px solid red;background:#757575}.ms-stacked .ms-sel-item{float:inherit}.ms-sel-ctn .ms-sel-item .ms-close-btn{width:7px;cursor:pointer;height:7px;float:right;margin:6px 2px 0 10px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAOCAYAAADjXQYbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJ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6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAEZ0FNQQAAsY58+1GTAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAABSSURBVHjahI7BCQAwCAOTzpThHMHh3Kl9CVos9XckFwQAuPtGuWTWwMwaczKzyHsqg6+5JqMJr28BABHRwmTWQFJjTmYWOU1L4tdck9GE17dnALGAS+kAR/u2AAAAAElFTkSuQmCC);background-position:0 -7px}.ms-sel-ctn .ms-sel-item .ms-close-btn:hover{background-position:0 0}.ms-stacked .ms-sel-item .ms-close-btn{margin-left:0}.ms-helper{color:#AAA;font-size:10px;position:absolute;top:-17px;right:0}.ms-ctn.input-lg .ms-trigger .ms-trigger-ico{margin-top:17px}.ms-ctn.input-sm .ms-trigger .ms-trigger-ico{margin-top:13px}.ms-ctn.input-lg .ms-sel-ctn .ms-sel-item{padding-top:2px;padding-bottom:3px}.ms-ctn.input-sm .ms-sel-ctn{line-height:15px}.ms-ctn.input-sm .ms-sel-ctn .ms-sel-item{padding-top:1px;padding-bottom:1px;margin-top:0;margin-bottom:0}.ms-ctn.input-sm .ms-sel-ctn .ms-sel-item .ms-close-btn{margin-top:4px}.ms-ctn .ms-sel-ctn{margin-left:-7px}.ms-ctn .ms-trigger:hover{width:24px;right:1px;border-radius:0 3px 3px 0} \ No newline at end of file diff --git a/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.js b/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.js new file mode 100644 index 0000000000..ef69768652 --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/magicsuggest-min.js @@ -0,0 +1 @@ +(function($){"use strict";var MagicSuggest=function(element,options){var ms=this;var defaults={allowFreeEntries:true,allowDuplicates:false,ajaxConfig:{},autoSelect:true,selectFirst:false,queryParam:"query",beforeSend:function(){},cls:"",data:null,dataUrlParams:{},disabled:false,disabledField:null,displayField:"name",editable:true,expanded:false,expandOnFocus:false,groupBy:null,hideTrigger:false,highlight:true,id:null,infoMsgCls:"",inputCfg:{},invalidCls:"ms-inv",matchCase:false,maxDropHeight:290,maxEntryLength:null,maxEntryRenderer:function(v){return"Please reduce your entry by "+v+" character"+(v>1?"s":"")},maxSuggestions:null,maxSelection:10,maxSelectionRenderer:function(v){return"You cannot choose more than "+v+" item"+(v>1?"s":"")},method:"POST",minChars:0,minCharsRenderer:function(v){return"Please type "+v+" more character"+(v>1?"s":"")},mode:"local",name:null,noSuggestionText:"No suggestions",placeholder:"Type or click here",renderer:null,required:false,resultAsString:false,resultAsStringDelimiter:",",resultsField:"results",selectionCls:"",selectionContainer:null,selectionPosition:"inner",selectionRenderer:null,selectionStacked:false,sortDir:"asc",sortOrder:null,strictSuggest:false,style:"",toggleOnClick:false,typeDelay:400,useTabKey:false,useCommaKey:true,useZebraStyle:false,value:null,valueField:"id",vregex:null,vtype:null};var conf=$.extend({},options);var cfg=$.extend(true,{},defaults,conf);this.addToSelection=function(items,isSilent){if(!cfg.maxSelection||_selection.length0?"":cfg.placeholder)};this.clear=function(isSilent){this.removeFromSelection(_selection.slice(0),isSilent)};this.collapse=function(){if(cfg.expanded===true){this.combobox.detach();cfg.expanded=false;$(this).trigger("collapse",[this])}};this.disable=function(){this.container.addClass("ms-ctn-disabled");cfg.disabled=true;ms.input.attr("disabled",true)};this.empty=function(){this.input.val("")};this.enable=function(){this.container.removeClass("ms-ctn-disabled");cfg.disabled=false;ms.input.attr("disabled",false)};this.expand=function(){if(!cfg.expanded&&(this.input.val().length>=cfg.minChars||this.combobox.children().size()>0)){this.combobox.appendTo(this.container);self._processSuggestions();cfg.expanded=true;$(this).trigger("expand",[this])}};this.isDisabled=function(){return cfg.disabled};this.isValid=function(){var valid=cfg.required===false||_selection.length>0;if(cfg.vtype||cfg.vregex){$.each(_selection,function(index,item){valid=valid&&self._validateSingleItem(item[cfg.valueField])})}return valid};this.getDataUrlParams=function(){return cfg.dataUrlParams};this.getName=function(){return cfg.name};this.getSelection=function(){return _selection};this.getRawValue=function(){return ms.input.val()};this.getValue=function(){return $.map(_selection,function(o){return o[cfg.valueField]})};this.removeFromSelection=function(items,isSilent){if(!$.isArray(items)){items=[items]}var valuechanged=false;$.each(items,function(index,json){var i=$.inArray(json[cfg.valueField],ms.getValue());if(i>-1){_selection.splice(i,1);valuechanged=true}});if(valuechanged===true){self._renderSelection();if(isSilent!==true){$(this).trigger("selectionchange",[this,this.getSelection()])}if(cfg.expandOnFocus){ms.expand()}if(cfg.expanded){self._processSuggestions()}}this.input.attr("placeholder",cfg.selectionPosition==="inner"&&this.getValue().length>0?"":cfg.placeholder)};this.getData=function(){return _cbData};this.setData=function(data){cfg.data=data;self._processSuggestions()};this.setName=function(name){cfg.name=name;if(name){cfg.name+=name.indexOf("[]")>0?"":"[]"}if(ms._valueContainer){$.each(ms._valueContainer.children(),function(i,el){el.name=cfg.name})}};this.setSelection=function(items){this.clear();this.addToSelection(items)};this.setValue=function(values){var items=[];$.each(values,function(index,value){var found=false;$.each(_cbData,function(i,item){if(item[cfg.valueField]==value){items.push(item);found=true;return false}});if(!found){if(typeof value==="object"){items.push(value)}else{var json={};json[cfg.valueField]=value;json[cfg.displayField]=value;items.push(json)}}});if(items.length>0){this.addToSelection(items)}};this.setDataUrlParams=function(params){cfg.dataUrlParams=$.extend({},params)};var _selection=[],_comboItemHeight=0,_timer,_hasFocus=false,_groups=null,_cbData=[],_ctrlDown=false,KEYCODES={BACKSPACE:8,TAB:9,ENTER:13,CTRL:17,ESC:27,SPACE:32,UPARROW:38,DOWNARROW:40,COMMA:188};var self={_displaySuggestions:function(data){ms.combobox.show();ms.combobox.empty();var resHeight=0,nbGroups=0;if(_groups===null){self._renderComboItems(data);resHeight=_comboItemHeight*data.length}else{for(var grpName in _groups){nbGroups+=1;$("
",{"class":"ms-res-group",html:grpName}).appendTo(ms.combobox);self._renderComboItems(_groups[grpName].items,true)}var _groupItemHeight=ms.combobox.find(".ms-res-group").outerHeight();if(_groupItemHeight!==null){var tmpResHeight=nbGroups*_groupItemHeight;resHeight=_comboItemHeight*data.length+tmpResHeight}else{resHeight=_comboItemHeight*(data.length+nbGroups)}}if(resHeight=ms.combobox.height()&&resHeight>cfg.maxDropHeight){ms.combobox.height(cfg.maxDropHeight)}if(data.length===1&&cfg.autoSelect===true){ms.combobox.children().filter(":not(.ms-res-item-disabled):last").addClass("ms-res-item-active")}if(cfg.selectFirst===true){ms.combobox.children().filter(":not(.ms-res-item-disabled):first").addClass("ms-res-item-active")}if(data.length===0&&ms.getRawValue()!==""){var noSuggestionText=cfg.noSuggestionText.replace(/\{\{.*\}\}/,ms.input.val());self._updateHelper(noSuggestionText);ms.collapse()}if(cfg.allowFreeEntries===false){if(data.length===0){$(ms.input).addClass(cfg.invalidCls);ms.combobox.hide()}else{$(ms.input).removeClass(cfg.invalidCls)}}},_getEntriesFromStringArray:function(data){var json=[];$.each(data,function(index,s){var entry={};entry[cfg.displayField]=entry[cfg.valueField]=$.trim(s);json.push(entry)});return json},_highlightSuggestion:function(html){var q=ms.input.val();var specialCharacters=["^","$","*","+","?",".","(",")",":","!","|","{","}","[","]"];$.each(specialCharacters,function(index,value){q=q.replace(value,"\\"+value)});if(q.length===0){return html}var glob=cfg.matchCase===true?"g":"gi";return html.replace(new RegExp("("+q+")(?!([^<]+)?>)",glob),"$1")},_moveSelectedRow:function(dir){if(!cfg.expanded){ms.expand()}var list,start,active,scrollPos;list=ms.combobox.find(".ms-res-item:not(.ms-res-item-disabled)");if(dir==="down"){start=list.eq(0)}else{start=list.filter(":last")}active=ms.combobox.find(".ms-res-item-active:not(.ms-res-item-disabled):first");if(active.length>0){if(dir==="down"){start=active.nextAll(".ms-res-item:not(.ms-res-item-disabled)").first();if(start.length===0){start=list.eq(0)}scrollPos=ms.combobox.scrollTop();ms.combobox.scrollTop(0);if(start[0].offsetTop+start.outerHeight()>ms.combobox.height()){ms.combobox.scrollTop(scrollPos+_comboItemHeight)}}else{start=active.prevAll(".ms-res-item:not(.ms-res-item-disabled)").first();if(start.length===0){start=list.filter(":last");ms.combobox.scrollTop(_comboItemHeight*list.length)}if(start[0].offsetTop0&&typeof data[0]==="string"){_cbData=self._getEntriesFromStringArray(data)}else{_cbData=data[cfg.resultsField]||data}}var sortedData=cfg.mode==="remote"?_cbData:self._sortAndTrim(_cbData);self._displaySuggestions(self._group(sortedData))}},_render:function(el){ms.setName(cfg.name);ms.container=$("
",{"class":"ms-ctn form-control "+(cfg.resultAsString?"ms-as-string ":"")+cfg.cls+($(el).hasClass("input-lg")?" input-lg":"")+($(el).hasClass("input-sm")?" input-sm":"")+(cfg.disabled===true?" ms-ctn-disabled":"")+(cfg.editable===true?"":" ms-ctn-readonly")+(cfg.hideTrigger===false?"":" ms-no-trigger"),style:cfg.style,id:cfg.id});ms.container.focus($.proxy(handlers._onFocus,this));ms.container.blur($.proxy(handlers._onBlur,this));ms.container.keydown($.proxy(handlers._onKeyDown,this));ms.container.keyup($.proxy(handlers._onKeyUp,this));ms.input=$("",$.extend({type:"text","class":cfg.editable===true?"":" ms-input-readonly",readonly:!cfg.editable,placeholder:cfg.placeholder,disabled:cfg.disabled},cfg.inputCfg));ms.input.focus($.proxy(handlers._onInputFocus,this));ms.input.click($.proxy(handlers._onInputClick,this));ms.combobox=$("
",{"class":"ms-res-ctn dropdown-menu"}).height(cfg.maxDropHeight);ms.combobox.on("click","div.ms-res-item",$.proxy(handlers._onComboItemSelected,this));ms.combobox.on("mouseover","div.ms-res-item",$.proxy(handlers._onComboItemMouseOver,this));if(cfg.selectionContainer){ms.selectionContainer=cfg.selectionContainer;$(ms.selectionContainer).addClass("ms-sel-ctn")}else{ms.selectionContainer=$("
",{"class":"ms-sel-ctn"})}ms.selectionContainer.click($.proxy(handlers._onFocus,this));if(cfg.selectionPosition==="inner"&&!cfg.selectionContainer){ms.selectionContainer.append(ms.input)}else{ms.container.append(ms.input)}ms.helper=$("",{"class":"ms-helper "+cfg.infoMsgCls});self._updateHelper();ms.container.append(ms.helper);$(el).replaceWith(ms.container);if(!cfg.selectionContainer){switch(cfg.selectionPosition){case"bottom":ms.selectionContainer.insertAfter(ms.container);if(cfg.selectionStacked===true){ms.selectionContainer.width(ms.container.width());ms.selectionContainer.addClass("ms-stacked")}break;case"right":ms.selectionContainer.insertAfter(ms.container);ms.container.css("float","left");break;default:ms.container.append(ms.selectionContainer);break}}if(cfg.hideTrigger===false){ms.trigger=$("
",{"class":"ms-trigger",html:'
'});ms.trigger.click($.proxy(handlers._onTriggerClick,this));ms.container.append(ms.trigger)}$(window).resize($.proxy(handlers._onWindowResized,this));if(cfg.value!==null||cfg.data!==null){if(typeof cfg.data==="string"){self._asyncValues=cfg.value;self._processSuggestions()}else{self._processSuggestions();if(cfg.value!==null){ms.setValue(cfg.value);self._renderSelection()}}}$("body").click(function(e){if(ms.container.hasClass("ms-ctn-focus")&&ms.container.has(e.target).length===0&&e.target.className.indexOf("ms-res-item")<0&&e.target.className.indexOf("ms-close-btn")<0&&ms.container[0]!==e.target){handlers._onBlur()}});if(cfg.expanded===true){cfg.expanded=false;ms.expand()}},_renderComboItems:function(items,isGrouped){var ref=this,html="";$.each(items,function(index,value){var displayed=cfg.renderer!==null?cfg.renderer.call(ref,value):value[cfg.displayField];var disabled=cfg.disabledField!==null&&value[cfg.disabledField]===true;var resultItemEl=$("
",{"class":"ms-res-item "+(isGrouped?"ms-res-item-grouped ":"")+(disabled?"ms-res-item-disabled ":"")+(index%2===1&&cfg.useZebraStyle===true?"ms-res-odd":""),html:cfg.highlight===true?self._highlightSuggestion(displayed):displayed,"data-json":JSON.stringify(value)});html+=$("
").append(resultItemEl).html()});ms.combobox.append(html);_comboItemHeight=ms.combobox.find(".ms-res-item:first").outerHeight()},_renderSelection:function(){var ref=this,w=0,inputOffset=0,items=[],asText=cfg.resultAsString===true&&!_hasFocus;ms.selectionContainer.find(".ms-sel-item").remove();if(ms._valueContainer!==undefined){ms._valueContainer.remove()}$.each(_selection,function(index,value){var selectedItemEl,delItemEl,selectedItemHtml=cfg.selectionRenderer!==null?cfg.selectionRenderer.call(ref,value):value[cfg.displayField];var validCls=self._validateSingleItem(value[cfg.displayField])?"":" ms-sel-invalid";if(asText===true){selectedItemEl=$("
",{"class":"ms-sel-item ms-sel-text "+cfg.selectionCls+validCls,html:selectedItemHtml+(index===_selection.length-1?"":cfg.resultAsStringDelimiter)}).data("json",value)}else{selectedItemEl=$("
",{"class":"ms-sel-item "+cfg.selectionCls+validCls,html:selectedItemHtml}).data("json",value);if(cfg.disabled===false){delItemEl=$("",{"class":"ms-close-btn"}).data("json",value).appendTo(selectedItemEl);delItemEl.click($.proxy(handlers._onTagTriggerClick,ref))}}items.push(selectedItemEl)});ms.selectionContainer.prepend(items);ms._valueContainer=$("
",{style:"display: none;"});$.each(ms.getValue(),function(i,val){var el=$("",{type:"hidden",name:cfg.name,value:val});el.appendTo(ms._valueContainer)});ms._valueContainer.appendTo(ms.selectionContainer);if(cfg.selectionPosition==="inner"&&!cfg.selectionContainer){ms.input.width(0);inputOffset=ms.input.offset().left-ms.selectionContainer.offset().left;w=ms.container.width()-inputOffset-42;ms.input.width(w)}if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else{ms.helper.hide()}},_selectItem:function(item){if(cfg.maxSelection===1){_selection=[]}ms.addToSelection(item.data("json"));item.removeClass("ms-res-item-active");if(cfg.expandOnFocus===false||_selection.length===cfg.maxSelection){ms.collapse()}if(!_hasFocus){ms.input.focus()}else if(_hasFocus&&(cfg.expandOnFocus||_ctrlDown)){self._processSuggestions();if(_ctrlDown){ms.expand()}}},_sortAndTrim:function(data){var q=ms.getRawValue(),filtered=[],newSuggestions=[],selectedValues=ms.getValue();if(q.length>0){$.each(data,function(index,obj){var name=obj[cfg.displayField];if(cfg.matchCase===true&&name.indexOf(q)>-1||cfg.matchCase===false&&name.toLowerCase().indexOf(q.toLowerCase())>-1){if(cfg.strictSuggest===false||name.toLowerCase().indexOf(q.toLowerCase())===0){filtered.push(obj)}}})}else{filtered=data}$.each(filtered,function(index,obj){if(cfg.allowDuplicates||$.inArray(obj[cfg.valueField],selectedValues)===-1){newSuggestions.push(obj)}});if(cfg.sortOrder!==null){newSuggestions.sort(function(a,b){if(a[cfg.sortOrder]b[cfg.sortOrder]){return cfg.sortDir==="asc"?1:-1}return 0})}if(cfg.maxSuggestions&&cfg.maxSuggestions>0){newSuggestions=newSuggestions.slice(0,cfg.maxSuggestions)}return newSuggestions},_group:function(data){if(cfg.groupBy!==null){_groups={};$.each(data,function(index,value){var props=cfg.groupBy.indexOf(".")>-1?cfg.groupBy.split("."):cfg.groupBy;var prop=value[cfg.groupBy];if(typeof props!="string"){prop=value;while(props.length>0){prop=prop[props.shift()]}}if(_groups[prop]===undefined){_groups[prop]={title:prop,items:[value]}}else{_groups[prop].items.push(value)}})}return data},_updateHelper:function(html){ms.helper.html(html);if(!ms.helper.is(":visible")){ms.helper.fadeIn()}},_validateSingleItem:function(value){if(cfg.vregex!==null&&cfg.vregex instanceof RegExp){return cfg.vregex.test(value)}else if(cfg.vtype!==null){switch(cfg.vtype){case"alpha":return/^[a-zA-Z_]+$/.test(value);case"alphanum":return/^[a-zA-Z0-9_]+$/.test(value);case"email":return/^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/.test(value);case"url":return/(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i.test(value);case"ipaddress":return/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(value)}}return true}};var handlers={_onBlur:function(){ms.container.removeClass("ms-ctn-focus");ms.collapse();_hasFocus=false;if(ms.getRawValue()!==""&&cfg.allowFreeEntries===true){var obj={};obj[cfg.displayField]=obj[cfg.valueField]=ms.getRawValue().trim();ms.addToSelection(obj)}self._renderSelection();if(ms.isValid()===false){ms.container.addClass(cfg.invalidCls)}else if(ms.input.val()!==""&&cfg.allowFreeEntries===false){ms.empty();self._updateHelper("")}$(ms).trigger("blur",[ms])},_onComboItemMouseOver:function(e){var target=$(e.currentTarget);if(!target.hasClass("ms-res-item-disabled")){ms.combobox.children().removeClass("ms-res-item-active");target.addClass("ms-res-item-active")}},_onComboItemSelected:function(e){var target=$(e.currentTarget);if(!target.hasClass("ms-res-item-disabled")){self._selectItem($(e.currentTarget))}},_onFocus:function(){ms.input.focus()},_onInputClick:function(){if(ms.isDisabled()===false&&_hasFocus){if(cfg.toggleOnClick===true){if(cfg.expanded){ms.collapse()}else{ms.expand()}}}},_onInputFocus:function(){if(ms.isDisabled()===false&&!_hasFocus){_hasFocus=true;ms.container.addClass("ms-ctn-focus");ms.container.removeClass(cfg.invalidCls);var curLength=ms.getRawValue().length;if(cfg.expandOnFocus===true){ms.expand()}if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else if(curLength0&&cfg.selectionPosition==="inner"){_selection.pop();self._renderSelection();$(ms).trigger("selectionchange",[ms,ms.getSelection()]);ms.input.attr("placeholder",cfg.selectionPosition==="inner"&&ms.getValue().length>0?"":cfg.placeholder);ms.input.focus();e.preventDefault()}break;case KEYCODES.TAB:case KEYCODES.ESC:e.preventDefault();break;case KEYCODES.ENTER:if(freeInput!==""||cfg.expanded){e.preventDefault()}break;case KEYCODES.COMMA:if(cfg.useCommaKey===true){e.preventDefault()}break;case KEYCODES.CTRL:_ctrlDown=true;break;case KEYCODES.DOWNARROW:e.preventDefault();self._moveSelectedRow("down");break;case KEYCODES.UPARROW:e.preventDefault();self._moveSelectedRow("up");break;default:if(_selection.length===cfg.maxSelection){e.preventDefault()}break}},_onKeyUp:function(e){var freeInput=ms.getRawValue(),inputValid=$.trim(ms.input.val()).length>0&&(!cfg.maxEntryLength||$.trim(ms.input.val()).length<=cfg.maxEntryLength),selected,obj={};$(ms).trigger("keyup",[ms,e]);clearTimeout(_timer);if(e.keyCode===KEYCODES.ESC&&cfg.expanded){ms.combobox.hide()}if(e.keyCode===KEYCODES.TAB&&cfg.useTabKey===false||e.keyCode>KEYCODES.ENTER&&e.keyCode0){self._selectItem(selected);return}}if(inputValid===true&&cfg.allowFreeEntries===true){obj[cfg.displayField]=obj[cfg.valueField]=freeInput.trim();ms.addToSelection(obj);ms.collapse();ms.input.focus()}break}default:if(_selection.length===cfg.maxSelection){self._updateHelper(cfg.maxSelectionRenderer.call(this,_selection.length))}else{if(freeInput.lengthcfg.maxEntryLength){self._updateHelper(cfg.maxEntryRenderer.call(this,freeInput.length-cfg.maxEntryLength));if(cfg.expanded===true){ms.collapse()}}else{ms.helper.hide();if(cfg.minChars<=freeInput.length){_timer=setTimeout(function(){if(cfg.expanded===true){self._processSuggestions()}else{ms.expand()}},cfg.typeDelay)}}}break}},_onTagTriggerClick:function(e){ms.removeFromSelection($(e.currentTarget).data("json"))},_onTriggerClick:function(){if(ms.isDisabled()===false&&!(cfg.expandOnFocus===true&&_selection.length===cfg.maxSelection)){$(ms).trigger("triggerclick",[ms]);if(cfg.expanded===true){ms.collapse()}else{var curLength=ms.getRawValue().length;if(curLength>=cfg.minChars){ms.input.focus();ms.expand()}else{self._updateHelper(cfg.minCharsRenderer.call(this,cfg.minChars-curLength))}}}},_onWindowResized:function(){self._renderSelection()}};if(element!==null){self._render(element)}};$.fn.magicSuggest=function(options){var obj=$(this);if(obj.size()===1&&obj.data("magicSuggest")){return obj.data("magicSuggest")}obj.each(function(i){var cntr=$(this);if(cntr.data("magicSuggest")){return}if(this.nodeName.toLowerCase()==="select"){options.data=[];options.value=[];$.each(this.children,function(index,child){if(child.nodeName&&child.nodeName.toLowerCase()==="option"){options.data.push({id:child.value,name:child.text});if($(child).attr("selected")){options.value.push(child.value)}}})}var def={};$.each(this.attributes,function(i,att){def[att.name]=att.name==="value"&&att.value!==""?JSON.parse(att.value):att.value});var field=new MagicSuggest(this,$.extend([],$.fn.magicSuggest.defaults,options,def));cntr.data("magicSuggest",field);field.container.data("magicSuggest",field)});if(obj.size()===1){return obj.data("magicSuggest")}return obj};$.fn.magicSuggest.defaults={}})(jQuery); \ No newline at end of file diff --git a/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.css b/phpgwapi/js/jquery/magicsuggest/magicsuggest.css similarity index 73% rename from phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.css rename to phpgwapi/js/jquery/magicsuggest/magicsuggest.css index 071816ee48..03ecac3814 100644 --- a/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.css +++ b/phpgwapi/js/jquery/magicsuggest/magicsuggest.css @@ -1,27 +1,19 @@ +/** + * Multiple Selection Component for Bootstrap + * Check nicolasbize.github.io/magicsuggest/ for latest updates. + * + * Author: Nicolas Bize + * Created: Feb 8th 2013 + * Last Updated: Oct 16th 2014 + * Version: 2.1.4 + * Licence: MagicSuggest is licenced under MIT licence (http://opensource.org/licenses/MIT) + */ .ms-ctn{ position: relative; - height: 28px; - padding: 0; - margin-bottom: 0px; - font-size: 14px; - line-height: 20px; - color: #555555; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - background-color: #ffffff; - border: 1px solid #cccccc; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; - -moz-transition: border linear 0.2s, box-shadow linear 0.2s; - -o-transition: border linear 0.2s, box-shadow linear 0.2s; - transition: border linear 0.2s, box-shadow linear 0.2s; - cursor: default; - display: block; + padding: 5px 12px; + height: auto; } -.ms-ctn-invalid{ +.ms-inv{ border: 1px solid #CC0000; } .ms-ctn-readonly{ @@ -41,19 +33,25 @@ border-bottom-left-radius: 0; border-bottom-right-radius: 0; } +.ms-ctn-focus{ + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6); +} .ms-ctn input{ border: 0; box-shadow: none; -webkit-transition: none; outline: none; display: block; - padding: 4px 6px; - line-height: normal; - overflow: hidden; - height: auto; - border-radius: 0; + padding: 0; + line-height: 1.42857143; + margin: 1px 0; + width: 100%; +} +.ms-ctn .ms-sel-ctn input{ float: left; - margin: 2px 0 2px 2px; } .ms-ctn-disabled input{ cursor: not-allowed; @@ -71,14 +69,18 @@ -webkit-transition: none; background: #FFF; } +.ms-ctn input::-ms-clear { + width: 0; + height: 0; +} .ms-ctn .ms-trigger{ - float: right; - width: 27px; + top: 0; + width: 25px; height:100%; position:absolute; right:0; + background: transparent; border-left: 1px solid #CCC; - background: #EEE; cursor: pointer; } .ms-ctn .ms-trigger .ms-trigger-ico { @@ -86,16 +88,15 @@ width: 0; height: 0; vertical-align: top; - border-top: 4px solid gray; + border-top: 4px solid #333; border-right: 4px solid transparent; border-left: 4px solid transparent; content: ""; - margin-left: 9px; - margin-top: 13px; + margin-left: 8px; + margin-top: 15px; } .ms-ctn .ms-trigger:hover{ - background: -moz-linear-gradient(100% 100% 90deg, #e3e3e3, #f1f1f1); - background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1f1f1), to(#e3e3e3)); + background-color: #e6e6e6; } .ms-ctn .ms-trigger:hover .ms-trigger-ico{ background-position: 0 -4px; @@ -108,25 +109,9 @@ border-bottom: 1px solid #CCC; } .ms-res-ctn{ - position: relative; - background: #FFF; + width: 100%; + display: block; overflow-y: auto; - z-index: 9999; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - border: 1px solid #CCC; - left: -1px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; - -moz-transition: border linear 0.2s, box-shadow linear 0.2s; - -o-transition: border linear 0.2s, box-shadow linear 0.2s; - transition: border linear 0.2s, box-shadow linear 0.2s; - border-top: 0; - border-top-left-radius: 0; - border-top-right-radius: 0; } .ms-res-ctn .ms-res-group{ line-height: 23px; @@ -149,32 +134,57 @@ padding-left: 15px; } .ms-res-ctn .ms-res-odd{ - background: #F3F3F3; + background: #FAFAFA; } .ms-res-ctn .ms-res-item-active{ - background-color: #3875D7; - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875D7', endColorstr='#2A62BC', GradientType=0 ); - background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #3875D7), color-stop(90%, #2A62BC)); - background-image: -webkit-linear-gradient(top, #3875D7 20%, #2A62BC 90%); - background-image: -moz-linear-gradient(top, #3875D7 20%, #2A62BC 90%); - background-image: -o-linear-gradient(top, #3875D7 20%, #2A62BC 90%); - background-image: linear-gradient(#3875D7 20%, #2A62BC 90%); - color: #fff; + background-color: #F5F5F5; +} +.ms-res-ctn .ms-res-item-disabled{ + color: #CCC; + cursor: default; } .ms-sel-ctn{ overflow: auto; - line-height: 22px; - padding-right:27px; + line-height: 18px; + padding-right: 25px; } +.ms-no-trigger .ms-sel-ctn{ + padding-right: 0; +} +/** Outer and global tags **/ .ms-sel-ctn .ms-sel-item{ - background: #555; - color: #EEE; + background: #F3F3F3; + color: #999; + float: left; + font-size: 12px; + padding: 3px 5px; + border-radius: 3px; + border: 1px solid #DDD; + margin: 3px 0px 1px 0; +} +.ms-sel-ctn .ms-sel-invalid{ + border-color: rgb(248, 165, 165) !important; + background: #FDF2F2 !important; +} +.ms-sel-ctn .ms-sel-item:hover{ + border: 1px solid #BBB; +} +/** For inner tags **/ +.ms-ctn .ms-sel-item{ + background: #F3F3F3; + color: #999; float: left; font-size: 12px; padding: 0 5px; border-radius: 3px; - margin-left: 5px; - margin-top: 4px; + border: 1px solid #DDD; + margin: 1px 5px 1px 0; +} +.ms-ctn .ms-sel-item:hover{ + border: 1px solid transparent; +} +.ms-ctn-focus .ms-sel-item:hover{ + border: 1px solid #BBB; } .ms-sel-ctn .ms-sel-text{ background: #FFF; @@ -184,14 +194,14 @@ font-size: 14px; font-weight: normal; } +.ms-as-string .ms-sel-text{ + border-color: transparent; +} .ms-res-ctn .ms-res-item em{ font-style: normal; background: #565656; color: #FFF; } -.ms-sel-ctn .ms-sel-item:hover{ - background: #565656; -} .ms-sel-ctn .ms-sel-text:hover{ background: #FFF; } @@ -199,9 +209,6 @@ border: 1px solid red; background: #757575; } -.ms-ctn .ms-sel-ctn .ms-sel-item{ - margin-top: 3px; -} .ms-stacked .ms-sel-item{ float: inherit; } @@ -210,12 +217,15 @@ cursor: pointer; height: 7px; float: right; - margin: 8px 2px 0 10px; + margin: 6px 2px 0 10px; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAOCAYAAADjXQYbAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wA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tdck9GE17dnALGAS+kAR/u2AAAAAElFTkSuQmCC); - + background-position: 0 -7px; } .ms-sel-ctn .ms-sel-item .ms-close-btn:hover{ - background-position: 0 -7px; + background-position: 0 0; +} +.ms-stacked .ms-sel-item .ms-close-btn { + margin-left: 0px; } .ms-helper{ color: #AAA; @@ -223,4 +233,34 @@ position: absolute; top: -17px; right: 0; -} \ No newline at end of file +} +.ms-ctn.input-lg .ms-trigger .ms-trigger-ico { + margin-top: 17px +} +.ms-ctn.input-sm .ms-trigger .ms-trigger-ico { + margin-top: 13px +} +.ms-ctn.input-lg .ms-sel-ctn .ms-sel-item { + padding-top: 2px; + padding-bottom: 3px; +} +.ms-ctn.input-sm .ms-sel-ctn { + line-height: 15px; +} +.ms-ctn.input-sm .ms-sel-ctn .ms-sel-item { + padding-top: 1px; + padding-bottom: 1px; + margin-top:0; + margin-bottom: 0; +} +.ms-ctn.input-sm .ms-sel-ctn .ms-sel-item .ms-close-btn { + margin-top: 4px; +} +.ms-ctn .ms-sel-ctn { + margin-left: -7px; +} +.ms-ctn .ms-trigger:hover { + width:24px; + right: 1px; + border-radius: 0 3px 3px 0; +} diff --git a/phpgwapi/js/jquery/magicsuggest/magicsuggest.jquery.json b/phpgwapi/js/jquery/magicsuggest/magicsuggest.jquery.json new file mode 100644 index 0000000000..cf15454a16 --- /dev/null +++ b/phpgwapi/js/jquery/magicsuggest/magicsuggest.jquery.json @@ -0,0 +1,36 @@ +{ + "name": "magicsuggest", + "title": "MagicSuggest", + "description": "MagicSuggest is a multiple selection auto suggest combo box for Bootstrap 3.", + "keywords": [ + "select", + "suggest", + "autocomplete", + "typeahead", + "dropdown", + "multiselect", + "tag", + "tagging", + "bootstrap", + "combobox" + ], + "version": "2.1.4", + "author": { + "name": "Nicolas Bize", + "url": "https://github.com/nicolasbize" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://nicolasbize.com/magicsuggest/licence.html" + } + ], + "bugs": "https://github.com/nicolasbize/magicsuggest/issues", + "homepage": "http://nicolasbize.com/magicsuggest/", + "docs": "http://nicolasbize.com/magicsuggest/doc.html", + "download": "https://github.com/nicolasbize/magicsuggest/releases", + "dependencies": { + "jquery": ">=1.8.3", + "bootstrap": ">=3.0.0" + } +} diff --git a/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.js b/phpgwapi/js/jquery/magicsuggest/magicsuggest.js similarity index 64% rename from phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.js rename to phpgwapi/js/jquery/magicsuggest/magicsuggest.js index 2bd590aba7..3ff463df70 100644 --- a/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.js +++ b/phpgwapi/js/jquery/magicsuggest/magicsuggest.js @@ -1,13 +1,12 @@ /** - * All auto suggestion boxes are fucked up or badly written. - * This is an attempt to create something that doesn't suck... + * Multiple Selection Component for Bootstrap + * Check nicolasbize.github.io/magicsuggest/ for latest updates. * - * Requires: jQuery - * - * Author: Nicolas Bize - * Date: Feb. 8th 2013 - * Version: 1.3.1 - * Licence: MagicSuggest is licenced under MIT licence (http://www.opensource.org/licenses/mit-license.php) + * Author: Nicolas Bize + * Created: Feb 8th 2013 + * Last Updated: Oct 16th 2014 + * Version: 2.1.4 + * Licence: MagicSuggest is licenced under MIT licence (http://opensource.org/licenses/MIT) */ (function($) { @@ -18,429 +17,352 @@ /** * Initializes the MagicSuggest component - * @param defaults - see config below */ var defaults = { /********** CONFIGURATION PROPERTIES ************/ /** - * @cfg {Boolean} allowFreeEntries - *

Restricts or allows the user to validate typed entries.

- * Defaults to true. + * Restricts or allows the user to validate typed entries. + * Defaults to true. */ allowFreeEntries: true, /** - * @cfg {String} cls - *

A custom CSS class to apply to the field's underlying element.

- * Defaults to ''. + * Restricts or allows the user to add the same entry more than once + * Defaults to false. + */ + allowDuplicates: false, + + /** + * Additional config object passed to each $.ajax call + */ + ajaxConfig: {}, + + /** + * If a single suggestion comes out, it is preselected. + */ + autoSelect: true, + + /** + * Auto select the first matching item with multiple items shown + */ + selectFirst: false, + + /** + * Allow customization of query parameter + */ + queryParam: 'query', + + /** + * A function triggered just before the ajax request is sent, similar to jQuery + */ + beforeSend: function(){ }, + + /** + * A custom CSS class to apply to the field's underlying element. */ cls: '', /** - * @cfg {Array / String / Function} data - * JSON Data source used to populate the combo box. 3 options are available here:
- *

No Data Source (default)
+ * JSON Data source used to populate the combo box. 3 options are available here: + * No Data Source (default) * When left null, the combo box will not suggest anything. It can still enable the user to enter - * multiple entries if allowFreeEntries is * set to true (default).

- *

Static Source
+ * multiple entries if allowFreeEntries is * set to true (default). + * Static Source * You can pass an array of JSON objects, an array of strings or even a single CSV string as the - * data source.
For ex. data: [* {id:0,name:"Paris"}, {id: 1, name: "New York"}]
- * You can also pass any json object with the results property containing the json array.

- *

Url
- * You can pass the url from which the component will fetch its JSON data.
Data will be fetched + * data source.For ex. data: [* {id:0,name:"Paris"}, {id: 1, name: "New York"}] + * You can also pass any json object with the results property containing the json array. + * Url + * You can pass the url from which the component will fetch its JSON data.Data will be fetched * using a POST ajax request that will * include the entered text as 'query' parameter. The results - * fetched from the server can be:
- * - an array of JSON objects (ex: [{id:...,name:...},{...}])
- * - a string containing an array of JSON objects ready to be parsed (ex: "[{id:...,name:...},{...}]")
+ * fetched from the server can be: + * - an array of JSON objects (ex: [{id:...,name:...},{...}]) + * - a string containing an array of JSON objects ready to be parsed (ex: "[{id:...,name:...},{...}]") * - a JSON object whose data will be contained in the results property - * (ex: {results: [{id:...,name:...},{...}]

- *

Function
- * You can pass a function which returns an array of JSON objects (ex: [{id:...,name:...},{...}])
- * The function can return the JSON data or it can use the first argument as function to handle the data.
- * Only one (callback function or return value) is needed for the function to succeed.
- * See the following example:
- * function (response) { var myjson = [{name: 'test', id: 1}]; response(myjson); return myjson; }

- * Defaults to null + * (ex: {results: [{id:...,name:...},{...}] + * Function + * You can pass a function which returns an array of JSON objects (ex: [{id:...,name:...},{...}]) + * The function can return the JSON data or it can use the first argument as function to handle the data. + * Only one (callback function or return value) is needed for the function to succeed. + * See the following example: + * function (response) { var myjson = [{name: 'test', id: 1}]; response(myjson); return myjson; } */ data: null, /** - * @cfg {Object} dataParams - *

Additional parameters to the ajax call

- * Defaults to {} + * Additional parameters to the ajax call */ dataUrlParams: {}, /** - * @cfg {Boolean} disabled - *

Start the component in a disabled state.

- * Defaults to false. + * Start the component in a disabled state. */ disabled: false, /** - * @cfg {String} displayField - *

name of JSON object property displayed in the combo list

- * Defaults to name. + * Name of JSON object property that defines the disabled behaviour + */ + disabledField: null, + + /** + * Name of JSON object property displayed in the combo list */ displayField: 'name', /** - * @cfg {Boolean} editable - *

Set to false if you only want mouse interaction. In that case the combo will - * automatically expand on focus.

- * Defaults to true. + * Set to false if you only want mouse interaction. In that case the combo will + * automatically expand on focus. */ editable: true, /** - * @cfg {String} emptyText - *

The default placeholder text when nothing has been entered

- * Defaults to 'Type or click here' or just 'Click here' if not editable. - */ - emptyText: function() { - return cfg.editable ? 'Type or click here' : 'Click here'; - }, - - /** - * @cfg {String} emptyTextCls - *

A custom CSS class to style the empty text

- * Defaults to 'ms-empty-text'. - */ - emptyTextCls: 'ms-empty-text', - - /** - * @cfg {Boolean} expanded - *

Set starting state for combo.

- * Defaults to false. + * Set starting state for combo. */ expanded: false, /** - * @cfg {Boolean} expandOnFocus - *

Automatically expands combo on focus.

- * Defaults to false. + * Automatically expands combo on focus. */ - expandOnFocus: function() { - return cfg.editable ? false : true; - }, + expandOnFocus: false, /** - * @cfg {String} groupBy - *

JSON property by which the list should be grouped

- * Defaults to null + * JSON property by which the list should be grouped */ groupBy: null, /** - * @cfg {Boolean} hideTrigger - *

Set to true to hide the trigger on the right

- * Defaults to false. + * Set to true to hide the trigger on the right */ hideTrigger: false, /** - * @cfg {Boolean} highlight - *

Set to true to highlight search input within displayed suggestions

- * Defaults to true. + * Set to true to highlight search input within displayed suggestions */ highlight: true, /** - * @cfg {String} id - *

A custom ID for this component

- * Defaults to 'ms-ctn-{n}' with n positive integer + * A custom ID for this component */ - id: function() { - return 'ms-ctn-' + $('div[id^="ms-ctn"]').length; - }, + id: null, /** - * @cfg {String} infoMsgCls - *

A class that is added to the info message appearing on the top-right part of the component

- * Defaults to '' + * A class that is added to the info message appearing on the top-right part of the component */ infoMsgCls: '', /** - * @cfg {Object} inputCfg - *

Additional parameters passed out to the INPUT tag. Enables usage of AngularJS's custom tags for ex.

- * Defaults to {} + * Additional parameters passed out to the INPUT tag. Enables usage of AngularJS's custom tags for ex. */ inputCfg: {}, /** - * @cfg {String} invalidCls - *

The class that is applied to show that the field is invalid

- * Defaults to ms-ctn-invalid + * The class that is applied to show that the field is invalid */ - invalidCls: 'ms-ctn-invalid', + invalidCls: 'ms-inv', /** - * @cfg {Boolean} matchCase - *

Set to true to filter data results according to case. Useless if the data is fetched remotely

- * Defaults to false. + * Set to true to filter data results according to case. Useless if the data is fetched remotely */ matchCase: false, /** - * @cfg {Integer} maxDropHeight (in px) - *

Once expanded, the combo's height will take as much room as the # of available results. - * In case there are too many results displayed, this will fix the drop down height.

- * Defaults to 290 px. + * Once expanded, the combo's height will take as much room as the # of available results. + * In case there are too many results displayed, this will fix the drop down height. */ maxDropHeight: 290, /** - * @cfg {Integer} maxEntryLength - *

Defines how long the user free entry can be. Set to null for no limit.

- * Defaults to null. + * Defines how long the user free entry can be. Set to null for no limit. */ maxEntryLength: null, /** - * @cfg {String} maxEntryRenderer - *

A function that defines the helper text when the max entry length has been surpassed.

- * Defaults to function(v){return 'Please reduce your entry by ' + v + ' character' + (v > 1 ? 's':'');} + * A function that defines the helper text when the max entry length has been surpassed. */ maxEntryRenderer: function(v) { return 'Please reduce your entry by ' + v + ' character' + (v > 1 ? 's':''); }, /** - * @cfg {Integer} maxSuggestions - *

The maximum number of results displayed in the combo drop down at once.

- * Defaults to null. + * The maximum number of results displayed in the combo drop down at once. */ maxSuggestions: null, /** - * @cfg {Integer} maxSelection - *

The maximum number of items the user can select if multiple selection is allowed. - * Set to null to remove the limit.

- * Defaults to 10. + * The maximum number of items the user can select if multiple selection is allowed. + * Set to null to remove the limit. */ maxSelection: 10, /** - * @cfg {Function} maxSelectionRenderer - *

A function that defines the helper text when the max selection amount has been reached. The function has a single - * parameter which is the number of selected elements.

- * Defaults to function(v){return 'You cannot choose more than ' + v + ' item' + (v > 1 ? 's':'');} + * A function that defines the helper text when the max selection amount has been reached. The function has a single + * parameter which is the number of selected elements. */ maxSelectionRenderer: function(v) { return 'You cannot choose more than ' + v + ' item' + (v > 1 ? 's':''); }, /** - * @cfg {String} method - *

The method used by the ajax request.

- * Defaults to 'POST' + * The method used by the ajax request. */ method: 'POST', /** - * @cfg {Integer} minChars - *

The minimum number of characters the user must type before the combo expands and offers suggestions. - * Defaults to 0. + * The minimum number of characters the user must type before the combo expands and offers suggestions. */ minChars: 0, /** - * @cfg {Function} minCharsRenderer - *

A function that defines the helper text when not enough letters are set. The function has a single - * parameter which is the difference between the required amount of letters and the current one.

- * Defaults to function(v){return 'Please type ' + v + ' more character' + (v > 1 ? 's':'');} + * A function that defines the helper text when not enough letters are set. The function has a single + * parameter which is the difference between the required amount of letters and the current one. */ minCharsRenderer: function(v) { return 'Please type ' + v + ' more character' + (v > 1 ? 's':''); }, /** - * @cfg {String} name - *

The name used as a form element.

- * Defaults to 'null' + * Whether or not sorting / filtering should be done remotely or locally. + * Use either 'local' or 'remote' + */ + mode: 'local', + + /** + * The name used as a form element. */ name: null, /** - * @cfg {String} noSuggestionText - *

The text displayed when there are no suggestions.

- * Defaults to 'No suggestions" + * The text displayed when there are no suggestions. */ noSuggestionText: 'No suggestions', /** - * @cfg {Boolean} preselectSingleSuggestion - *

If a single suggestion comes out, it is preselected.

- * Defaults to true. + * The default placeholder text when nothing has been entered */ - preselectSingleSuggestion: true, + placeholder: 'Type or click here', /** - * @cfg (function) renderer - *

A function used to define how the items will be presented in the combo

- * Defaults to null. + * A function used to define how the items will be presented in the combo */ renderer: null, /** - * @cfg {Boolean} required - *

Whether or not this field should be required

- * Defaults to false + * Whether or not this field should be required */ required: false, /** - * @cfg {Boolean} resultAsString - *

Set to true to render selection as comma separated string

- * Defaults to false. + * Set to true to render selection as a delimited string */ resultAsString: false, /** - * @cfg {String} resultsField - *

Name of JSON object property that represents the list of suggested objets

- * Defaults to results + * Text delimiter to use in a delimited string. + */ + resultAsStringDelimiter: ',', + + /** + * Name of JSON object property that represents the list of suggested objects */ resultsField: 'results', /** - * @cfg {String} selectionCls - *

A custom CSS class to add to a selected item

- * Defaults to ''. + * A custom CSS class to add to a selected item */ selectionCls: '', /** - * @cfg {String} selectionPosition - *

Where the selected items will be displayed. Only 'right', 'bottom' and 'inner' are valid values

- * Defaults to 'inner', meaning the selected items will appear within the input box itself. + * An optional element replacement in which the selection is rendered + */ + selectionContainer: null, + + /** + * Where the selected items will be displayed. Only 'right', 'bottom' and 'inner' are valid values */ selectionPosition: 'inner', /** - * @cfg (function) selectionRenderer - *

A function used to define how the items will be presented in the tag list

- * Defaults to null. + * A function used to define how the items will be presented in the tag list */ selectionRenderer: null, /** - * @cfg {Boolean} selectionStacked - *

Set to true to stack the selectioned items when positioned on the bottom - * Requires the selectionPosition to be set to 'bottom'

- * Defaults to false. + * Set to true to stack the selectioned items when positioned on the bottom + * Requires the selectionPosition to be set to 'bottom' */ selectionStacked: false, /** - * @cfg {String} sortDir - *

Direction used for sorting. Only 'asc' and 'desc' are valid values

- * Defaults to 'asc'. + * Direction used for sorting. Only 'asc' and 'desc' are valid values */ sortDir: 'asc', /** - * @cfg {String} sortOrder - *

name of JSON object property for local result sorting. - * Leave null if you do not wish the results to be ordered or if they are already ordered remotely.

- * - * Defaults to null. + * name of JSON object property for local result sorting. + * Leave null if you do not wish the results to be ordered or if they are already ordered remotely. */ sortOrder: null, /** - * @cfg {Boolean} strictSuggest - *

If set to true, suggestions will have to start by user input (and not simply contain it as a substring)

- * Defaults to false. + * If set to true, suggestions will have to start by user input (and not simply contain it as a substring) */ strictSuggest: false, /** - * @cfg {String} style - *

Custom style added to the component container.

- * - * Defaults to ''. + * Custom style added to the component container. */ style: '', /** - * @cfg {Boolean} toggleOnClick - *

If set to true, the combo will expand / collapse when clicked upon

- * Defaults to false. + * If set to true, the combo will expand / collapse when clicked upon */ toggleOnClick: false, /** - * @cfg {Integer} typeDelay - *

Amount (in ms) between keyboard registers.

- * - * Defaults to 400 + * Amount (in ms) between keyboard registers. */ typeDelay: 400, /** - * @cfg {Boolean} useTabKey - *

If set to true, tab won't blur the component but will be registered as the ENTER key

- * Defaults to false. + * If set to true, tab won't blur the component but will be registered as the ENTER key */ useTabKey: false, /** - * @cfg {Boolean} useCommaKey - *

If set to true, using comma will validate the user's choice

- * Defaults to true. + * If set to true, using comma will validate the user's choice */ useCommaKey: true, /** - * @cfg {Boolean} useZebraStyle - *

Determines whether or not the results will be displayed with a zebra table style

- * Defaults to true. + * Determines whether or not the results will be displayed with a zebra table style */ - useZebraStyle: true, + useZebraStyle: false, /** - * @cfg {String/Object/Array} value - *

initial value for the field

- * Defaults to null. + * initial value for the field */ value: null, /** - * @cfg {String} valueField - *

name of JSON object property that represents its underlying value

- * Defaults to id. + * name of JSON object property that represents its underlying value */ valueField: 'id', /** - * @cfg {Integer} width (in px) - *

Width of the component

- * Defaults to underlying element width. + * regular expression to validate the values against */ - width: function() { - return $(this).width(); - } + vregex: null, + + /** + * type to validate against + */ + vtype: null }; var conf = $.extend({},options); var cfg = $.extend(true, {}, defaults, conf); - // some init stuff - if ($.isFunction(cfg.emptyText)) { - cfg.emptyText = cfg.emptyText.call(this); - } - if ($.isFunction(cfg.expandOnFocus)) { - cfg.expandOnFocus = cfg.expandOnFocus.call(this); - } - if ($.isFunction(cfg.id)) { - cfg.id = cfg.id.call(this); - } - /********** PUBLIC METHODS ************/ /** * Add one or multiple json items to the current selection @@ -455,7 +377,7 @@ } var valuechanged = false; $.each(items, function(index, json) { - if ($.inArray(json[cfg.valueField], ms.getValue()) === -1) { + if (cfg.allowDuplicates || $.inArray(json[cfg.valueField], ms.getValue()) === -1) { _selection.push(json); valuechanged = true; } @@ -464,10 +386,11 @@ self._renderSelection(); this.empty(); if (isSilent !== true) { - $(this).trigger('selectionchange', [this, this.getSelectedItems()]); + $(this).trigger('selectionchange', [this, this.getSelection()]); } } } + this.input.attr('placeholder', (cfg.selectionPosition === 'inner' && this.getValue().length > 0) ? '' : cfg.placeholder); }; /** @@ -505,7 +428,6 @@ * Empties out the combo user text */ this.empty = function(){ - this.input.removeClass(cfg.emptyTextCls); this.input.val(''); }; @@ -546,7 +468,13 @@ */ this.isValid = function() { - return cfg.required === false || _selection.length > 0; + var valid = cfg.required === false || _selection.length > 0; + if(cfg.vtype || cfg.vregex){ + $.each(_selection, function(index, item){ + valid = valid && self._validateSingleItem(item[cfg.valueField]); + }); + } + return valid; }; /** @@ -569,7 +497,7 @@ * Retrieve an array of selected json objects * @return {Array} */ - this.getSelectedItems = function() + this.getSelection = function() { return _selection; }; @@ -578,7 +506,7 @@ * Retrieve the current text entered by the user */ this.getRawValue = function(){ - return ms.input.val() !== cfg.emptyText ? ms.input.val() : ''; + return ms.input.val(); }; /** @@ -612,7 +540,7 @@ if (valuechanged === true) { self._renderSelection(); if(isSilent !== true){ - $(this).trigger('selectionchange', [this, this.getSelectedItems()]); + $(this).trigger('selectionchange', [this, this.getSelection()]); } if(cfg.expandOnFocus){ ms.expand(); @@ -621,6 +549,14 @@ self._processSuggestions(); } } + this.input.attr('placeholder', (cfg.selectionPosition === 'inner' && this.getValue().length > 0) ? '' : cfg.placeholder); + }; + + /** + * Get current data + */ + this.getData = function(){ + return _cbData; }; /** @@ -638,33 +574,52 @@ */ this.setName = function(name){ cfg.name = name; + if(name){ + cfg.name += name.indexOf('[]') > 0 ? '' : '[]'; + } if(ms._valueContainer){ - ms._valueContainer.name = name; + $.each(ms._valueContainer.children(), function(i, el){ + el.name = cfg.name; + }); } }; /** - * Sets a value for the combo box. Value must be a value or an array of value with data type matching valueField one. + * Sets the current selection with the JSON items provided + * @param items + */ + this.setSelection = function(items){ + this.clear(); + this.addToSelection(items); + }; + + /** + * Sets a value for the combo box. Value must be an array of values with data type matching valueField one. * @param data */ - this.setValue = function(data) + this.setValue = function(values) { - var values = data, items = []; - if(!$.isArray(data)){ - if(typeof(data) === 'string'){ - if(data.indexOf('[') > -1){ - values = eval(data); - } else if(data.indexOf(',') > -1){ - values = data.split(','); - } - } else { - values = [data]; - } - } + var items = []; - $.each(_cbData, function(index, obj) { - if($.inArray(obj[cfg.valueField], values) > -1) { - items.push(obj); + $.each(values, function(index, value) { + // first try to see if we have the full objects from our data set + var found = false; + $.each(_cbData, function(i,item){ + if(item[cfg.valueField] == value){ + items.push(item); + found = true; + return false; + } + }); + if(!found){ + if(typeof(value) === 'object'){ + items.push(value); + } else { + var json = {}; + json[cfg.valueField] = value; + json[cfg.displayField] = value; + items.push(json); + } } }); if(items.length > 0) { @@ -688,7 +643,18 @@ _hasFocus = false, _groups = null, _cbData = [], - _ctrlDown = false; + _ctrlDown = false, + KEYCODES = { + BACKSPACE: 8, + TAB: 9, + ENTER: 13, + CTRL: 17, + ESC: 27, + SPACE: 32, + UPARROW: 38, + DOWNARROW: 40, + COMMA: 188 + }; var self = { @@ -697,6 +663,7 @@ * @private */ _displaySuggestions: function(data) { + ms.combobox.show(); ms.combobox.empty(); var resHeight = 0, // total height taken by displayed results. @@ -715,7 +682,13 @@ }).appendTo(ms.combobox); self._renderComboItems(_groups[grpName].items, true); } - resHeight = _comboItemHeight * (data.length + nbGroups); + var _groupItemHeight = ms.combobox.find('.ms-res-group').outerHeight(); + if(_groupItemHeight !== null) { + var tmpResHeight = nbGroups * _groupItemHeight; + resHeight = (_comboItemHeight * data.length) + tmpResHeight; + } else { + resHeight = _comboItemHeight * (data.length + nbGroups); + } } if(resHeight < ms.combobox.height() || resHeight <= cfg.maxDropHeight) { @@ -725,14 +698,29 @@ ms.combobox.height(cfg.maxDropHeight); } - if(data.length === 1 && cfg.preselectSingleSuggestion === true) { - ms.combobox.children().filter(':last').addClass('ms-res-item-active'); + if(data.length === 1 && cfg.autoSelect === true) { + ms.combobox.children().filter(':not(.ms-res-item-disabled):last').addClass('ms-res-item-active'); + } + + if (cfg.selectFirst === true) { + ms.combobox.children().filter(':not(.ms-res-item-disabled):first').addClass('ms-res-item-active'); } if(data.length === 0 && ms.getRawValue() !== "") { - self._updateHelper(cfg.noSuggestionText); + var noSuggestionText = cfg.noSuggestionText.replace(/\{\{.*\}\}/, ms.input.val()); + self._updateHelper(noSuggestionText); ms.collapse(); } + + // When free entry is off, add invalid class to input if no data matches + if(cfg.allowFreeEntries === false) { + if(data.length === 0) { + $(ms.input).addClass(cfg.invalidCls); + ms.combobox.hide(); + } else { + $(ms.input).removeClass(cfg.invalidCls); + } + } }, /** @@ -755,18 +743,21 @@ * @private */ _highlightSuggestion: function(html) { - var q = ms.input.val() !== cfg.emptyText ? ms.input.val() : ''; + var q = ms.input.val(); + + //escape special regex characters + var specialCharacters = ['^', '$', '*', '+', '?', '.', '(', ')', ':', '!', '|', '{', '}', '[', ']']; + + $.each(specialCharacters, function (index, value) { + q = q.replace(value, "\\" + value); + }) + if(q.length === 0) { return html; // nothing entered as input } - if(cfg.matchCase === true) { - html = html.replace(new RegExp('(' + q + ')(?!([^<]+)?>)','g'), '$1'); - } - else { - html = html.replace(new RegExp('(' + q + ')(?!([^<]+)?>)','gi'), '$1'); - } - return html; + var glob = cfg.matchCase === true ? 'g' : 'gi'; + return html.replace(new RegExp('(' + q + ')(?!([^<]+)?>)', glob), '$1'); }, /** @@ -779,17 +770,17 @@ ms.expand(); } var list, start, active, scrollPos; - list = ms.combobox.find(".ms-res-item"); + list = ms.combobox.find(".ms-res-item:not(.ms-res-item-disabled)"); if(dir === 'down') { start = list.eq(0); } else { start = list.filter(':last'); } - active = ms.combobox.find('.ms-res-item-active:first'); + active = ms.combobox.find('.ms-res-item-active:not(.ms-res-item-disabled):first'); if(active.length > 0) { if(dir === 'down') { - start = active.nextAll('.ms-res-item').first(); + start = active.nextAll('.ms-res-item:not(.ms-res-item-disabled)').first(); if(start.length === 0) { start = list.eq(0); } @@ -800,7 +791,7 @@ } } else { - start = active.prevAll('.ms-res-item').first(); + start = active.prevAll('.ms-res-item:not(.ms-res-item-disabled)').first(); if(start.length === 0) { start = list.filter(':last'); ms.combobox.scrollTop(_comboItemHeight * list.length); @@ -822,27 +813,33 @@ var json = null, data = source || cfg.data; if(data !== null) { if(typeof(data) === 'function'){ - data = data.call(ms); + data = data.call(ms, ms.getRawValue()); } - if(typeof(data) === 'string' && data.indexOf(',') < 0) { // get results from ajax + if(typeof(data) === 'string') { // get results from ajax $(ms).trigger('beforeload', [ms]); - var params = $.extend({query: ms.input.val()}, cfg.dataUrlParams); - $.ajax({ + var queryParams = {} + queryParams[cfg.queryParam] = ms.input.val(); + var params = $.extend(queryParams, cfg.dataUrlParams); + $.ajax($.extend({ type: cfg.method, url: data, data: params, + beforeSend: cfg.beforeSend, success: function(asyncData){ json = typeof(asyncData) === 'string' ? JSON.parse(asyncData) : asyncData; self._processSuggestions(json); $(ms).trigger('load', [ms, json]); + if(self._asyncValues){ + ms.setValue(typeof(self._asyncValues) === 'string' ? JSON.parse(self._asyncValues) : self._asyncValues); + self._renderSelection(); + delete(self._asyncValues); + } }, error: function(){ throw("Could not reach server"); } - }); + }, cfg.ajaxConfig)); return; - } else if(typeof(data) === 'string' && data.indexOf(',') > -1) { // results from csv string - _cbData = self._getEntriesFromStringArray(data.split(',')); } else { // results from local array if(data.length > 0 && typeof(data[0]) === 'string') { // results from array of strings _cbData = self._getEntriesFromStringArray(data); @@ -850,7 +847,8 @@ _cbData = data[cfg.resultsField] || data; } } - self._displaySuggestions(self._sortAndTrim(_cbData)); + var sortedData = cfg.mode === 'remote' ? _cbData : self._sortAndTrim(_cbData); + self._displaySuggestions(self._group(sortedData)); } }, @@ -860,16 +858,18 @@ * @private */ _render: function(el) { - $(ms).trigger('beforerender', [ms]); - var w = $.isFunction(cfg.width) ? cfg.width.call(el) : cfg.width; + ms.setName(cfg.name); // make sure the form name is correct // holds the main div, will relay the focus events to the contained input element. ms.container = $('
', { - id: cfg.id, - 'class': 'ms-ctn ' + cfg.cls + + 'class': 'ms-ctn form-control ' + (cfg.resultAsString ? 'ms-as-string ' : '') + cfg.cls + + ($(el).hasClass('input-lg') ? ' input-lg' : '') + + ($(el).hasClass('input-sm') ? ' input-sm' : '') + (cfg.disabled === true ? ' ms-ctn-disabled' : '') + - (cfg.editable === true ? '' : ' ms-ctn-readonly'), - style: cfg.style - }).width(w); + (cfg.editable === true ? '' : ' ms-ctn-readonly') + + (cfg.hideTrigger === false ? '' : ' ms-no-trigger'), + style: cfg.style, + id: cfg.id + }); ms.container.focus($.proxy(handlers._onFocus, this)); ms.container.blur($.proxy(handlers._onBlur, this)); ms.container.keydown($.proxy(handlers._onKeyDown, this)); @@ -877,53 +877,43 @@ // holds the input field ms.input = $('', $.extend({ - id: 'ms-input-' + $('input[id^="ms-input"]').length, type: 'text', - 'class': cfg.emptyTextCls + (cfg.editable === true ? '' : ' ms-input-readonly'), - value: cfg.emptyText, + 'class': cfg.editable === true ? '' : ' ms-input-readonly', readonly: !cfg.editable, + placeholder: cfg.placeholder, disabled: cfg.disabled - }, cfg.inputCfg)).width(w - (cfg.hideTrigger ? 16 : 42)); + }, cfg.inputCfg)); ms.input.focus($.proxy(handlers._onInputFocus, this)); - ms.input.click($.proxy(handlers._onInputClick, this)); - // holds the trigger on the right side - if(cfg.hideTrigger === false) { - ms.trigger = $('
', { - id: 'ms-trigger-' + $('div[id^="ms-trigger"]').length, - 'class': 'ms-trigger', - html: '
' - }); - ms.trigger.click($.proxy(handlers._onTriggerClick, this)); - ms.container.append(ms.trigger); - } - // holds the suggestions. will always be placed on focus ms.combobox = $('
', { - id: 'ms-res-ctn-' + $('div[id^="ms-res-ctn"]').length, - 'class': 'ms-res-ctn ' - }).width(w).height(cfg.maxDropHeight); + 'class': 'ms-res-ctn dropdown-menu' + }).height(cfg.maxDropHeight); // bind the onclick and mouseover using delegated events (needs jQuery >= 1.7) ms.combobox.on('click', 'div.ms-res-item', $.proxy(handlers._onComboItemSelected, this)); ms.combobox.on('mouseover', 'div.ms-res-item', $.proxy(handlers._onComboItemMouseOver, this)); - ms.selectionContainer = $('
', { - id: 'ms-sel-ctn-' + $('div[id^="ms-sel-ctn"]').length, - 'class': 'ms-sel-ctn' - }); + if(cfg.selectionContainer){ + ms.selectionContainer = cfg.selectionContainer; + $(ms.selectionContainer).addClass('ms-sel-ctn'); + } else { + ms.selectionContainer = $('
', { + 'class': 'ms-sel-ctn' + }); + } ms.selectionContainer.click($.proxy(handlers._onFocus, this)); - if(cfg.selectionPosition === 'inner') { + if(cfg.selectionPosition === 'inner' && !cfg.selectionContainer) { ms.selectionContainer.append(ms.input); } else { ms.container.append(ms.input); } - ms.helper = $('
', { + ms.helper = $('', { 'class': 'ms-helper ' + cfg.infoMsgCls }); self._updateHelper(); @@ -933,31 +923,55 @@ // Render the whole thing $(el).replaceWith(ms.container); - switch(cfg.selectionPosition) { - case 'bottom': - ms.selectionContainer.insertAfter(ms.container); - if(cfg.selectionStacked === true) { - ms.selectionContainer.width(ms.container.width()); - ms.selectionContainer.addClass('ms-stacked'); + if(!cfg.selectionContainer){ + switch(cfg.selectionPosition) { + case 'bottom': + ms.selectionContainer.insertAfter(ms.container); + if(cfg.selectionStacked === true) { + ms.selectionContainer.width(ms.container.width()); + ms.selectionContainer.addClass('ms-stacked'); + } + break; + case 'right': + ms.selectionContainer.insertAfter(ms.container); + ms.container.css('float', 'left'); + break; + default: + ms.container.append(ms.selectionContainer); + break; + } + } + + + // holds the trigger on the right side + if(cfg.hideTrigger === false) { + ms.trigger = $('
', { + 'class': 'ms-trigger', + html: '
' + }); + ms.trigger.click($.proxy(handlers._onTriggerClick, this)); + ms.container.append(ms.trigger); + } + + $(window).resize($.proxy(handlers._onWindowResized, this)); + + // do not perform an initial call if we are using ajax unless we have initial values + if(cfg.value !== null || cfg.data !== null){ + if(typeof(cfg.data) === 'string'){ + self._asyncValues = cfg.value; + self._processSuggestions(); + } else { + self._processSuggestions(); + if(cfg.value !== null){ + ms.setValue(cfg.value); + self._renderSelection(); } - break; - case 'right': - ms.selectionContainer.insertAfter(ms.container); - ms.container.css('float', 'left'); - break; - default: - ms.container.append(ms.selectionContainer); - break; + } + } - if(cfg.value !== null) { - ms.setValue(cfg.value); - self._renderSelection(); - } - - $(ms).trigger('afterrender', [ms]); $("body").click(function(e) { - if(ms.container.hasClass('ms-ctn-bootstrap-focus') && + if(ms.container.hasClass('ms-ctn-focus') && ms.container.has(e.target).length === 0 && e.target.className.indexOf('ms-res-item') < 0 && e.target.className.indexOf('ms-close-btn') < 0 && @@ -972,18 +986,22 @@ } }, + /** + * Renders each element within the combo box + * @private + */ _renderComboItems: function(items, isGrouped) { var ref = this, html = ''; $.each(items, function(index, value) { var displayed = cfg.renderer !== null ? cfg.renderer.call(ref, value) : value[cfg.displayField]; + var disabled = cfg.disabledField !== null && value[cfg.disabledField] === true; var resultItemEl = $('
', { 'class': 'ms-res-item ' + (isGrouped ? 'ms-res-item-grouped ':'') + + (disabled ? 'ms-res-item-disabled ':'') + (index % 2 === 1 && cfg.useZebraStyle === true ? 'ms-res-odd' : ''), html: cfg.highlight === true ? self._highlightSuggestion(displayed) : displayed, 'data-json': JSON.stringify(value) }); - resultItemEl.click($.proxy(handlers._onComboItemSelected, ref)); - resultItemEl.mouseover($.proxy(handlers._onComboItemMouseOver, ref)); html += $('
').append(resultItemEl).html(); }); ms.combobox.append(html); @@ -1007,16 +1025,19 @@ var selectedItemEl, delItemEl, selectedItemHtml = cfg.selectionRenderer !== null ? cfg.selectionRenderer.call(ref, value) : value[cfg.displayField]; + + var validCls = self._validateSingleItem(value[cfg.displayField]) ? '' : ' ms-sel-invalid'; + // tag representing selected value if(asText === true) { selectedItemEl = $('
', { - 'class': 'ms-sel-item ms-sel-text ' + cfg.selectionCls, - html: selectedItemHtml + (index === (_selection.length - 1) ? '' : ',') + 'class': 'ms-sel-item ms-sel-text ' + cfg.selectionCls + validCls, + html: selectedItemHtml + (index === (_selection.length - 1) ? '' : cfg.resultAsStringDelimiter) }).data('json', value); } else { selectedItemEl = $('
', { - 'class': 'ms-sel-item ' + cfg.selectionCls, + 'class': 'ms-sel-item ' + cfg.selectionCls + validCls, html: selectedItemHtml }).data('json', value); @@ -1032,21 +1053,27 @@ items.push(selectedItemEl); }); - ms.selectionContainer.prepend(items); - ms._valueContainer = $('', { - type: 'hidden', - name: cfg.name, - value: JSON.stringify(ms.getValue()) + + // store the values, behaviour of multiple select + ms._valueContainer = $('
', { + style: 'display: none;' + }); + $.each(ms.getValue(), function(i, val){ + var el = $('', { + type: 'hidden', + name: cfg.name, + value: val + }); + el.appendTo(ms._valueContainer); }); ms._valueContainer.appendTo(ms.selectionContainer); - if(cfg.selectionPosition === 'inner') { + if(cfg.selectionPosition === 'inner' && !cfg.selectionContainer) { ms.input.width(0); inputOffset = ms.input.offset().left - ms.selectionContainer.offset().left; w = ms.container.width() - inputOffset - 42; ms.input.width(w); - ms.container.height(ms.selectionContainer.height()); } if(_selection.length === cfg.maxSelection){ @@ -1089,14 +1116,12 @@ filtered = [], newSuggestions = [], selectedValues = ms.getValue(); - var server_search = typeof cfg.data == 'string' && cfg.data.indexOf(',') < 0 // filter the data according to given input if(q.length > 0) { $.each(data, function(index, obj) { var name = obj[cfg.displayField]; if((cfg.matchCase === true && name.indexOf(q) > -1) || - (cfg.matchCase === false && name.toLowerCase().indexOf(q.toLowerCase()) > -1) || - cfg.strictSuggest === false && server_search) { + (cfg.matchCase === false && name.toLowerCase().indexOf(q.toLowerCase()) > -1)) { if(cfg.strictSuggest === false || name.toLowerCase().indexOf(q.toLowerCase()) === 0) { filtered.push(obj); } @@ -1108,7 +1133,7 @@ } // take out the ones that have already been selected $.each(filtered, function(index, obj) { - if($.inArray(obj[cfg.valueField], selectedValues) === -1) { + if (cfg.allowDuplicates || $.inArray(obj[cfg.valueField], selectedValues) === -1) { newSuggestions.push(obj); } }); @@ -1128,19 +1153,33 @@ if(cfg.maxSuggestions && cfg.maxSuggestions > 0) { newSuggestions = newSuggestions.slice(0, cfg.maxSuggestions); } + return newSuggestions; + + }, + + _group: function(data){ // build groups if(cfg.groupBy !== null) { _groups = {}; - $.each(newSuggestions, function(index, value) { - if(_groups[value[cfg.groupBy]] === undefined) { - _groups[value[cfg.groupBy]] = {title: value[cfg.groupBy], items: [value]}; + + $.each(data, function(index, value) { + var props = cfg.groupBy.indexOf('.') > -1 ? cfg.groupBy.split('.') : cfg.groupBy; + var prop = value[cfg.groupBy]; + if(typeof(props) != 'string'){ + prop = value; + while(props.length > 0){ + prop = prop[props.shift()]; + } + } + if(_groups[prop] === undefined) { + _groups[prop] = {title: prop, items: [value]}; } else { - _groups[value[cfg.groupBy]].items.push(value); + _groups[prop].items.push(value); } }); } - return newSuggestions; + return data; }, /** @@ -1152,6 +1191,30 @@ if(!ms.helper.is(":visible")) { ms.helper.fadeIn(); } + }, + + /** + * Validate an item against vtype or vregex + * @private + */ + _validateSingleItem: function(value){ + if(cfg.vregex !== null && cfg.vregex instanceof RegExp){ + return cfg.vregex.test(value); + } else if(cfg.vtype !== null) { + switch(cfg.vtype){ + case 'alpha': + return (/^[a-zA-Z_]+$/).test(value); + case 'alphanum': + return (/^[a-zA-Z0-9_]+$/).test(value); + case 'email': + return (/^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/).test(value); + case 'url': + return (/(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i).test(value); + case 'ipaddress': + return (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/).test(value); + } + } + return true; } }; @@ -1161,32 +1224,26 @@ * @private */ _onBlur: function() { - ms.container.removeClass('ms-ctn-bootstrap-focus'); + ms.container.removeClass('ms-ctn-focus'); ms.collapse(); _hasFocus = false; if(ms.getRawValue() !== '' && cfg.allowFreeEntries === true){ var obj = {}; - obj[cfg.displayField] = obj[cfg.valueField] = ms.getRawValue(); + obj[cfg.displayField] = obj[cfg.valueField] = ms.getRawValue().trim(); ms.addToSelection(obj); } self._renderSelection(); if(ms.isValid() === false) { - ms.container.addClass('ms-ctn-invalid'); + ms.container.addClass(cfg.invalidCls); } - if(ms.input.val() === '' && _selection.length === 0) { - ms.input.addClass(cfg.emptyTextCls); - ms.input.val(cfg.emptyText); - } else if(ms.input.val() !== '' && cfg.allowFreeEntries === false) { ms.empty(); self._updateHelper(''); } - if(ms.input.is(":focus")) { - $(ms).trigger('blur', [ms]); - } + $(ms).trigger('blur', [ms]); }, /** @@ -1195,8 +1252,11 @@ * @private */ _onComboItemMouseOver: function(e) { - ms.combobox.children().removeClass('ms-res-item-active'); - $(e.currentTarget).addClass('ms-res-item-active'); + var target = $(e.currentTarget); + if(!target.hasClass('ms-res-item-disabled')){ + ms.combobox.children().removeClass('ms-res-item-active'); + target.addClass('ms-res-item-active'); + } }, /** @@ -1205,7 +1265,10 @@ * @private */ _onComboItemSelected: function(e) { - self._selectItem($(e.currentTarget)); + var target = $(e.currentTarget); + if(!target.hasClass('ms-res-item-disabled')){ + self._selectItem($(e.currentTarget)); + } }, /** @@ -1239,13 +1302,9 @@ _onInputFocus: function() { if(ms.isDisabled() === false && !_hasFocus) { _hasFocus = true; - ms.container.addClass('ms-ctn-bootstrap-focus'); + ms.container.addClass('ms-ctn-focus'); ms.container.removeClass(cfg.invalidCls); - if(ms.input.val() === cfg.emptyText) { - ms.empty(); - } - var curLength = ms.getRawValue().length; if(cfg.expandOnFocus === true){ ms.expand(); @@ -1271,41 +1330,48 @@ */ _onKeyDown: function(e) { // check how tab should be handled - var active = ms.combobox.find('.ms-res-item-active:first'), - freeInput = ms.input.val() !== cfg.emptyText ? ms.input.val() : ''; + var active = ms.combobox.find('.ms-res-item-active:not(.ms-res-item-disabled):first'), + freeInput = ms.input.val(); $(ms).trigger('keydown', [ms, e]); - if(e.keyCode === 9 && (cfg.useTabKey === false || + if(e.keyCode === KEYCODES.TAB && (cfg.useTabKey === false || (cfg.useTabKey === true && active.length === 0 && ms.input.val().length === 0))) { handlers._onBlur(); return; } switch(e.keyCode) { - case 8: //backspace - if(freeInput.length === 0 && ms.getSelectedItems().length > 0 && cfg.selectionPosition === 'inner') { + case KEYCODES.BACKSPACE: + if(freeInput.length === 0 && ms.getSelection().length > 0 && cfg.selectionPosition === 'inner') { _selection.pop(); self._renderSelection(); - $(ms).trigger('selectionchange', [ms, ms.getSelectedItems()]); + $(ms).trigger('selectionchange', [ms, ms.getSelection()]); + ms.input.attr('placeholder', (cfg.selectionPosition === 'inner' && ms.getValue().length > 0) ? '' : cfg.placeholder); ms.input.focus(); e.preventDefault(); } break; - case 188: // comma - if(!cfg.useCommaKey) break; - if(e.shiftKey) break; // Shift + , = < on some keyboards - if(e.originalEvent && e.originalEvent.keyIdentifier && e.originalEvent.keyIdentifier != "U+002C") break; - case 9: // tab - case 13: // enter + case KEYCODES.TAB: + case KEYCODES.ESC: e.preventDefault(); break; - case 17: // ctrl + case KEYCODES.ENTER: + if(freeInput !== '' || cfg.expanded){ + e.preventDefault(); + } + break; + case KEYCODES.COMMA: + if(cfg.useCommaKey === true){ + e.preventDefault(); + } + break; + case KEYCODES.CTRL: _ctrlDown = true; break; - case 40: // down + case KEYCODES.DOWNARROW: e.preventDefault(); self._moveSelectedRow("down"); break; - case 38: // up + case KEYCODES.UPARROW: e.preventDefault(); self._moveSelectedRow("up"); break; @@ -1324,7 +1390,7 @@ */ _onKeyUp: function(e) { var freeInput = ms.getRawValue(), - inputValid = $.trim(ms.input.val()).length > 0 && ms.input.val() !== cfg.emptyText && + inputValid = $.trim(ms.input.val()).length > 0 && (!cfg.maxEntryLength || $.trim(ms.input.val()).length <= cfg.maxEntryLength), selected, obj = {}; @@ -1334,27 +1400,28 @@ clearTimeout(_timer); // collapse if escape, but keep focus. - if(e.keyCode === 27 && cfg.expanded) { - ms.combobox.height(0); + if(e.keyCode === KEYCODES.ESC && cfg.expanded) { + ms.combobox.hide(); } // ignore a bunch of keys - if((e.keyCode === 9 && cfg.useTabKey === false) || (e.keyCode > 13 && e.keyCode < 32)) { - if(e.keyCode === 17){ + if((e.keyCode === KEYCODES.TAB && cfg.useTabKey === false) || (e.keyCode > KEYCODES.ENTER && e.keyCode < KEYCODES.SPACE)) { + if(e.keyCode === KEYCODES.CTRL){ _ctrlDown = false; } return; } switch(e.keyCode) { - case 40:case 38: // up, down + case KEYCODES.UPARROW: + case KEYCODES.DOWNARROW: e.preventDefault(); break; - case 13:case 9:case 188:// enter, tab, comma - // Shift + comma = < on English keyboard - if(e.keyCode !== 188 || (cfg.useCommaKey === true && - !(e.shiftKey || e.originalEvent && e.originalEvent.keyIdentifier && e.originalEvent.keyIdentifier != "U+002C"))) { + case KEYCODES.ENTER: + case KEYCODES.TAB: + case KEYCODES.COMMA: + if(e.keyCode !== KEYCODES.COMMA || cfg.useCommaKey === true) { 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'); + selected = ms.combobox.find('.ms-res-item-active:not(.ms-res-item-disabled):first'); if(selected.length > 0) { self._selectItem(selected); return; @@ -1362,7 +1429,7 @@ } // if no selection or if freetext entered and free entries allowed, add new obj to selection if(inputValid === true && cfg.allowFreeEntries === true) { - obj[cfg.displayField] = obj[cfg.valueField] = freeInput; + obj[cfg.displayField] = obj[cfg.valueField] = freeInput.trim(); ms.addToSelection(obj); ms.collapse(); // reset combo suggestions ms.input.focus(); @@ -1431,6 +1498,14 @@ } } } + }, + + /** + * Triggered when the browser window is resized + * @private + */ + _onWindowResized: function() { + self._renderSelection(); } }; @@ -1462,20 +1537,20 @@ $.each(this.children, function(index, child){ if(child.nodeName && child.nodeName.toLowerCase() === 'option'){ options.data.push({id: child.value, name: child.text}); - if(child.selected){ + if($(child).attr('selected')){ options.value.push(child.value); } } }); - } var def = {}; // set values from DOM container element $.each(this.attributes, function(i, att){ - def[att.name] = att.value; + def[att.name] = att.name === 'value' && att.value !== '' ? JSON.parse(att.value) : att.value; }); - var field = new MagicSuggest(this, $.extend(options, def)); + + var field = new MagicSuggest(this, $.extend([], $.fn.magicSuggest.defaults, options, def)); cntr.data('magicSuggest', field); field.container.data('magicSuggest', field); }); @@ -1486,5 +1561,5 @@ return obj; }; -// $.fn.magicSuggest.defaults = {}; -})(jQuery); \ No newline at end of file + $.fn.magicSuggest.defaults = {}; +})(jQuery);