diff --git a/dist/uxrocket.autocomplete.js b/dist/uxrocket.autocomplete.js new file mode 100644 index 0000000..12ccb44 --- /dev/null +++ b/dist/uxrocket.autocomplete.js @@ -0,0 +1,534 @@ +/** + * UX Rocket + * jQuery based accordion + * @author Bilal Cinarli + * @dependency jQueryUI Autocomplete + * @dependency Handlebars + * @dependency UX Rocket Clear + */ + +; +(function($) { + var ux, // local shorthand + + defaults = { + type : "list", + item : 10, + service : null, + minLength : 2, + formdata : null, + categoryTextLimit: 25, + queryType : 'GET', + hidden : null, + template : null, + highlight : true, + arrowSelection : false, + arrowNavigation : true, + cache : false, + + // callbacks + onReady : false, + onSelect : false, + onButtonClick: false, + onClearCache : false, + onUpdate : false, + onRemove : false + }, + + templates = { + list : { + wrap: '', + item: '' + + '
  • ' + + ' ' + + ' {{{name}}}' + + ' {{#if title}}' + + '
    {{substr title 50}}' + + ' {{/if}}' + + '
    ' + + '
  • ' + }, + image : { + wrap: '', + item: '' + + '
  • ' + + ' ' + + ' ' + + ' {{{name}}}' + + ' {{#if title}}' + + '
    {{substr title 50}}' + + ' {{/if}}' + + '
    ' + + '
  • ' + }, + category: { + wrap: '', + head: '' + + '
  • ' + + ' {{substr category 25}}' + + '
  • ', + item: '' + + '
  • ' + + ' ' + + ' {{{name}}}' + + ' {{#if title}}' + + '
    {{substr title 50}}' + + ' {{/if}}' + + '
    ' + + '
  • ' + }, + tree : { + wrap: '', + head: '' + + '
  • ' + + ' {{substr category 25}}' + + '
  • ', + item: '' + + '
  • ' + + ' ' + + ' ' + + ' {{{name}}}' + + ' {{#if title}}' + + '
    {{substr title 50}}' + + ' {{/if}}' + + '
    ' + + '
  • ' + } + }, + events = { + click : 'click.uxAutocomplete', + search : 'autocompletesearch.uxAutocomplete', + response: 'autocompleteresponse.uxAutocomplete' + }, + ns = { + rocket : 'uxRocket', + data : 'uxAutocomplete', + ready : 'uxitd-autocomplete-ready', + rocketWrap: 'uxitd-plugin-wrap', + wrap : 'uxitd-autocomplete-wrap', + icon : 'icon-search', + loading : 'icon-loading' + }; + + var AutoComplete = function(el, options, selector) { + var $el = $(el), + opts = $.extend({}, defaults, options, $el.data(), {'selector': selector}); + + // terms object for caching + opts.terms = {}; + + $el.data(ns.data, opts); + + // set element layout + setLayout($el); + + // call Ready Callback + callback(opts.onReady); + + // bind actions + bindUIActions($el); + + // set template actions + setTemplate($el); + }; + + var setLayout = function($el) { + var columns, + _opts = $el.data(ns.data); + + columns = ' ' + $el.context.className.replace(ns.ready, ''); + + if(_opts.selector.charAt(0) == '.') { + columns = columns.replace(' ' + _opts.selector.substr(1), ''); + columns = columns.replace(_opts.selector.substr(1) + ' ', ''); + } + + if($el.parent().is('.' + ns.rocketWrap)) { + $el.parent().addClass(ns.wrap + columns + ' group'); + } + else { + $el.wrap(''); + } + + $el.after(''); + }; + + var setSource = function($el) { + var _opts = $el.data(ns.data), + fdata = null, + url_pattern = /^(http|https|\/|\.\/|\.\.\/)/, + source = _opts.service, + sourceFunction; + + + if(!url_pattern.test(source) || typeof source === "object") { + if(typeof source === "string") { + // we get source from "data-service" attribute, + // so we need to change its format to js array + source = eval(source); + } + // in older versions the js array or json object should + // encapsulated with "itemList" node. + var items = source.itemList || source; + + sourceFunction = function(request, response) { + // check if element is active or not : fix for IE + if(!$el.is(':focus')) { + return; + } + + var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); + + response($.map(items, function(item) { + if(matcher.test(item.name)) { + return setItem(item); + } + })); + }; + } + else { + sourceFunction = function(request, response) { + var term = request.term; + + // check if element is active or not : fix for IE + if(!$el.is(':focus')) { + return; + } + + if(_opts.cache && term in _opts.terms) { + var items = _opts.terms[term].itemList || _opts.terms[term]; + + response($.map(items.slice(0, _opts.item), function(item) { + return setItem(item); + })); + return; + } + + if(_opts.formdata != null) { + fdata = $(_opts.formdata).serialize(); + } + + $.ajax({ + url : source, + dataType: 'json', + type : _opts.queryType, + data : { + type : _opts.type, + term : term, + formdata: fdata + }, + success : function(data) { + if(_opts.cache) { + _opts.terms[term] = data; + $el.data(ns.data, _opts); + } + + var items = data.itemList || data; + + response($.map(items.slice(0, _opts.item), function(item) { + return setItem(item); + })); + } + }); + }; + } + + return sourceFunction; + }; + + var bindUIActions = function($el) { + var _opts = $el.data(ns.data); + + if(typeof _opts.props !== 'undefined' && _opts.props != '') { + var props = _opts.props.split(':'); + + $el.next('.' + ns.icon).addClass('uxitd-autocomplete-icon-clickable').on(events.click, function(e) { + e.preventDefault(); + eval(props[1]); + }); + } + + if(_opts.onButtonClick !== false) { + $el.next('.' + ns.icon).on(events.click, function() { + callback(_opts.onButtonClick); + }); + } + + $el.on(events.search, function(event, ui) { + $(this).siblings('.' + ns.icon).addClass(ns.loading); + }); + + $el.on(events.response, function(event, ui) { + $(this).siblings('.' + ns.loading).removeClass(ns.loading); + }); + + $el.autocomplete({ + open : function(event, ui) { + $(".uxitd-autocomplete-category").removeClass('ui-menu-item'); + + $(this).autocomplete("widget").css({ + "width": ($(this).outerWidth() + "px") + }); + }, + minLength: _opts.minLength, + source : setSource($el), + focus : function(event, ui) { + if(!_opts.arrowNavigation) { + event.preventDefault(); + } + }, + select : function(event, ui) { + if(_opts.hidden != null) { + $(_opts.hidden).val(ui.item.id); + } + + if(_opts.arrowSelection === true && event.keyCode == 13 && typeof ui.item.url !== 'undefined') { + // check if target is blank or not + var _target = $("#" + event.currentTarget.id).find(".ui-state-focus a").attr("target"); + + if(_target == '_blank') { + window.open(ui.item.url); + } + else { + window.location = ui.item.url; + } + } + + callback(_opts.onSelect); + } + }); + }; + + var setTemplate = function($el) { + var autocomplete = $el.data("uiAutocomplete") ? $el.data("uiAutocomplete") : $el.data("ui-autocomplete"), + _opts = $el.data(ns.data), + template = {}; + + if(_opts.template === null) { + switch(_opts.type) { + default: + case 'list': + template = templates.list; + break; + case 'image': + template = templates.image; + break; + case 'category': + template = templates.category; + break; + case 'tree': + template = templates.tree; + break; + } + } + + else { + template = _opts.template; + } + + autocomplete._renderMenu = function(ul, items) { + var _this = this, + _list = [], + currentCategory = ""; + + $.each(items, function(index, item) { + var temp; + + if((_opts.type == 'category' || _opts.type == 'tree') && typeof item.category !== 'undefined' && item.category != currentCategory) { + + var categoryHead = Handlebars.compile(template.head)(item); + + _list.push(categoryHead); + + currentCategory = item.category; + } + + temp = _this._renderItemData(ul, item); + + _list.push(temp); + }); + + ul.append(_list); + + if(currentCategory != "") { + ul.addClass('uxitd-category'); + } + }; + + autocomplete._create = function() { + var _this = this; + + _this._super(); + _this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)"); + }; + + autocomplete._renderItemData = function(ul, item) { + var rendered, + listItem = Handlebars.compile(template.item)(item); + + rendered = listItem; + + if(_opts.highlight === true) { + rendered = listItem.replace( + new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), + '$1'); + } + + return $(rendered) + .addClass('ui-menu-item') + .data("ui-autocomplete-item", item) + .attr('role', 'presentation'); + }; + }; + + // fallback for 0.x.x versions + var setItem = function(item) { + if(typeof item.value === 'undefined') { + item.value = item.name; + } + + /** + * Fallback for old data json format + * @deprecated visiblename + */ + if(typeof item.visiblename !== 'undefined') { + item.value = item.visiblename; + } + + return item; + }; + + // global callback + var callback = function(fn) { + // if callback string is function call it directly + if(typeof fn === 'function') { + fn.apply(this); + } + + // if callback defined via data-attribute, call it via new Function + else { + if(fn !== false) { + var func = new Function('return ' + fn); + func(); + } + } + }; + + // jquery bindings + ux = $.fn.uxitdautocomplete = $.uxautocomplete = function(options) { + var selector = this.selector; + + return this.each(function() { + var $el = $(this), + uxrocket = $el.data('uxRocket') || {}, + autocomplete; + + if($el.hasClass(ns.ready) || $el.hasClass(ns.rocketWrap)) { + return; + } + + $el.addClass(ns.ready); + + uxrocket[ns.data] = {'hasWrapper': true, 'wrapper': ns.wrap, 'ready': ns.ready, 'selector': selector, 'options': options}; + + $el.data(ns.rocket, uxrocket); + + autocomplete = new AutoComplete(this, options, selector); + }); + }; + + ux.clearCache = function(el) { + var $el = el !== undefined ? $(el) : $("." + ns.ready); + + $el.filter('input').each(function() { + var _this = $(this), + _instance = _this.data(ns.data); + + // set cache terms to empty object + _instance.terms = {}; + + _this.data(ns.data, _instance); + + callback(_instance.onClearCache); + }); + }; + + ux.update = function(el) { + var $el = el !== undefined ? $(el) : $("." + ns.ready); + + $el.filter('input').each(function() { + var _this = $(this), + _instance = _this.data(ns.data), + _rocket = _this.data(ns.rocket); + + // first remove jQuery UI Autocomplete + _this.autocomplete('destroy'); + + + // remove previous instance data + // since we are removing the rocket data no need to clear cache separately + _this.removeData(ns.data); + + // add new options + _instance = $.extend({}, defaults, _rocket[ns.data]['options'], $(this).data()); + + // register new instance data + _this.data(ns.data, _instance); + + _this.off(events.click + ' ' + events.search + ' ' + events.response); + + bindUIActions(_this); + + setTemplate(_this); + + callback(_instance.onUpdate); + }); + }; + + ux.remove = function(el) { + var $el = el !== undefined ? $(el) : $("." + ns.ready); + + $el.filter('input').each(function() { + var _this = $(this), + _instance = _this.data(ns.data), + _uxrocket = _this.data(ns.rocket); + + // remove ready class + _this.removeClass(ns.ready); + + // remove plugin events + _this.off(events.click + ' ' + events.search + ' ' + events.response); + + // remove icon and wrapper + _this.next('.' + ns.icon).remove(); + + if(_uxrocket[ns.data].hasWrapper) { + if(Object.keys && Object.keys(_uxrocket).length == 1) { + _this.unwrap(); + } + + else { + _this.parent().removeClass(ns.wrap); + } + } + + // remove plugin data + _this.removeData(ns.data); + + // remove uxRocket registry + delete _uxrocket[ns.data]; + _this.data(ns.rocket, _uxrocket); + + // remove jQueryUI + _this.autocomplete('destroy'); + + callback(_instance.onRemove); + }); + }; + + // version + ux.version = '1.8.1'; + + // settings + ux.settings = defaults; +})(jQuery); diff --git a/dist/uxrocket.autocomplete.min.js b/dist/uxrocket.autocomplete.min.js index e8f62b8..ddd1641 100644 --- a/dist/uxrocket.autocomplete.min.js +++ b/dist/uxrocket.autocomplete.min.js @@ -1,2 +1,8 @@ -!function($){var ux,defaults={type:"list",item:10,service:null,minLength:2,formdata:null,categoryTextLimit:25,queryType:"GET",hidden:null,template:null,highlight:!0,arrowSelection:!1,arrowNavigation:!0,cache:!1,onReady:!1,onSelect:!1,onButtonClick:!1,onClearCache:!1,onUpdate:!1,onRemove:!1},templates={list:{wrap:"",item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},image:{wrap:"",item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},category:{wrap:"",head:'
  • {{substr category 25}}
  • ',item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},tree:{wrap:"",head:'
  • {{substr category 25}}
  • ',item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '}},events={click:"click.uxAutocomplete",search:"autocompletesearch.uxAutocomplete",response:"autocompleteresponse.uxAutocomplete"},ns={rocket:"uxRocket",data:"uxAutocomplete",ready:"uxitd-autocomplete-ready",rocketWrap:"uxitd-plugin-wrap",wrap:"uxitd-autocomplete-wrap",icon:"icon-search",loading:"icon-loading"},AutoComplete=function(e,t,a){var s=$(e),n=$.extend({},defaults,t,s.data(),{selector:a});n.terms={},s.data(ns.data,n),setLayout(s),callback(n.onReady),bindUIActions(s),setTemplate(s)},setLayout=function(e){var t,a=e.data(ns.data);t=" "+e.context.className.replace(ns.ready,""),"."==a.selector.charAt(0)&&(t=t.replace(" "+a.selector.substr(1),""),t=t.replace(a.selector.substr(1)+" ","")),e.parent().is("."+ns.rocketWrap)?e.parent().addClass(ns.wrap+t+" group"):e.wrap(''),e.after('')},setSource=function($el){var _opts=$el.data(ns.data),fdata=null,url_pattern=/^(http|https|\/|\.\/|\.\.\/)/,source=_opts.service,sourceFunction;return url_pattern.test(source)?sourceFunction=function(e,t){var a=e.term;if($el.is(":focus")){if(_opts.cache&&a in _opts.terms)return void t($.map(_opts.terms[a].itemList.slice(0,_opts.item),function(e){return setItem(e)}));null!=_opts.formdata&&(fdata=$(_opts.formdata).serialize()),$.ajax({url:source,dataType:"json",type:_opts.queryType,data:{type:_opts.type,term:a,formdata:fdata},success:function(e){_opts.cache&&(_opts.terms[a]=e,$el.data(ns.data,_opts)),t($.map(e.itemList.slice(0,_opts.item),function(e){return setItem(e)}))}})}}:(source=eval(source),sourceFunction=function(e,t){if($el.is(":focus")){var a=new RegExp($.ui.autocomplete.escapeRegex(e.term),"i");t($.map(source.itemList,function(e){return a.test(e.name)?setItem(e):void 0}))}}),sourceFunction},bindUIActions=function($el){var _opts=$el.data(ns.data);if("undefined"!=typeof _opts.props&&""!=_opts.props){var props=_opts.props.split(":");$el.next("."+ns.icon).addClass("uxitd-autocomplete-icon-clickable").on(events.click,function(e){e.preventDefault(),eval(props[1])})}_opts.onButtonClick!==!1&&$el.next("."+ns.icon).on(events.click,function(){callback(_opts.onButtonClick)}),$el.on(events.search,function(e,t){$(this).siblings("."+ns.icon).addClass(ns.loading)}),$el.on(events.response,function(e,t){$(this).siblings("."+ns.loading).removeClass(ns.loading)}),$el.autocomplete({open:function(e,t){$(".uxitd-autocomplete-category").removeClass("ui-menu-item"),$(this).autocomplete("widget").css({width:$(this).outerWidth()+"px"})},minLength:_opts.minLength,source:setSource($el),focus:function(e,t){_opts.arrowNavigation||e.preventDefault()},select:function(e,t){if(null!=_opts.hidden&&$(_opts.hidden).val(t.item.id),_opts.arrowSelection===!0&&13==e.keyCode&&"undefined"!=typeof t.item.url){var a=$("#"+e.currentTarget.id).find(".ui-state-focus a").attr("target");"_blank"==a?window.open(t.item.url):window.location=t.item.url}callback(_opts.onSelect)}})},setTemplate=function(e){var t=e.data("uiAutocomplete")?e.data("uiAutocomplete"):e.data("ui-autocomplete"),a=e.data(ns.data),s={};if(null===a.template)switch(a.type){default:case"list":s=templates.list;break;case"image":s=templates.image;break;case"category":s=templates.category;break;case"tree":s=templates.tree}else s=a.template;t._renderMenu=function(e,t){var n=this,o=[],i="";$.each(t,function(t,r){var c;if(("category"==a.type||"tree"==a.type)&&"undefined"!=typeof r.category&&r.category!=i){var l=Handlebars.compile(s.head)(r);o.push(l),i=r.category}c=n._renderItemData(e,r),o.push(c)}),e.append(o),""!=i&&e.addClass("uxitd-category")},t._create=function(){var e=this;e._super(),e.widget().menu("option","items","> :not(.ui-autocomplete-category)")},t._renderItemData=function(e,t){var n,o=Handlebars.compile(s.item)(t);return n=o,a.highlight===!0&&(n=o.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+$.ui.autocomplete.escapeRegex(this.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),'$1')),$(n).addClass("ui-menu-item").data("ui-autocomplete-item",t).attr("role","presentation")}},setItem=function(e){return"undefined"==typeof e.value&&(e.value=e.name),"undefined"!=typeof e.visiblename&&(e.value=e.visiblename),e},callback=function(e){if("function"==typeof e)e.apply(this);else if(e!==!1){var t=new Function("return "+e);t()}};ux=$.fn.uxitdautocomplete=$.uxautocomplete=function(e){var t=this.selector;return this.each(function(){var a=$(this),s=a.data("uxRocket")||{},n;a.hasClass(ns.ready)||a.hasClass(ns.rocketWrap)||(a.addClass(ns.ready),s[ns.data]={hasWrapper:!0,wrapper:ns.wrap,ready:ns.ready,selector:t,options:e},a.data(ns.rocket,s),n=new AutoComplete(this,e,t))})},ux.clearCache=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data);t.terms={},e.data(ns.data,t),callback(t.onClearCache)})},ux.update=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data),a=e.data(ns.rocket);e.autocomplete("destroy"),e.removeData(ns.data),t=$.extend({},defaults,a[ns.data].options,$(this).data()),e.data(ns.data,t),e.off(events.click+" "+events.search+" "+events.response),bindUIActions(e),setTemplate(e),callback(t.onUpdate)})},ux.remove=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data),a=e.data(ns.rocket);e.removeClass(ns.ready),e.off(events.click+" "+events.search+" "+events.response),e.next("."+ns.icon).remove(),a[ns.data].hasWrapper&&(Object.keys&&1==Object.keys(a).length?e.unwrap():e.parent().removeClass(ns.wrap)),e.removeData(ns.data),delete a[ns.data],e.data(ns.rocket,a),e.autocomplete("destroy"),callback(t.onRemove)})},ux.version="1.6.0",ux.settings=defaults}(jQuery); -//# sourceMappingURL=./uxrocket.autocomplete.min.js.map \ No newline at end of file +/*! UX Rocket Autocomplete + * UX Rocket Autocomplete: A jQueryUI autocomplete wrapper + * @author Bilal Cinarli (http://bcinarli.com/) + * @version 2.0.0 + * @build 2015-07-02 + */ +!function($){var ux,defaults={type:"list",item:10,service:null,minLength:2,formdata:null,categoryTextLimit:25,queryType:"GET",hidden:null,template:null,highlight:!0,arrowSelection:!1,arrowNavigation:!0,cache:!1,onReady:!1,onSelect:!1,onButtonClick:!1,onClearCache:!1,onUpdate:!1,onRemove:!1},templates={list:{wrap:"",item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},image:{wrap:"",item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},category:{wrap:"",head:'
  • {{substr category 25}}
  • ',item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '},tree:{wrap:"",head:'
  • {{substr category 25}}
  • ',item:'
  • {{{name}}} {{#if title}}
    {{substr title 50}} {{/if}}
  • '}},events={click:"click.uxAutocomplete",search:"autocompletesearch.uxAutocomplete",response:"autocompleteresponse.uxAutocomplete"},ns={rocket:"uxRocket",data:"uxAutocomplete",ready:"uxitd-autocomplete-ready",rocketWrap:"uxitd-plugin-wrap",wrap:"uxitd-autocomplete-wrap",icon:"icon-search",loading:"icon-loading"},AutoComplete=function(e,t,a){var s=$(e),o=$.extend({},defaults,t,s.data(),{selector:a});o.terms={},s.data(ns.data,o),setLayout(s),callback(o.onReady),bindUIActions(s),setTemplate(s)},setLayout=function(e){var t,a=e.data(ns.data);t=" "+e.context.className.replace(ns.ready,""),"."==a.selector.charAt(0)&&(t=t.replace(" "+a.selector.substr(1),""),t=t.replace(a.selector.substr(1)+" ","")),e.parent().is("."+ns.rocketWrap)?e.parent().addClass(ns.wrap+t+" group"):e.wrap(''),e.after('')},setSource=function($el){var _opts=$el.data(ns.data),fdata=null,url_pattern=/^(http|https|\/|\.\/|\.\.\/)/,source=_opts.service,sourceFunction;if(url_pattern.test(source)&&"object"!=typeof source)sourceFunction=function(e,t){var a=e.term;if($el.is(":focus")){if(_opts.cache&&a in _opts.terms){var s=_opts.terms[a].itemList||_opts.terms[a];return void t($.map(s.slice(0,_opts.item),function(e){return setItem(e)}))}null!=_opts.formdata&&(fdata=$(_opts.formdata).serialize()),$.ajax({url:source,dataType:"json",type:_opts.queryType,data:{type:_opts.type,term:a,formdata:fdata},success:function(e){_opts.cache&&(_opts.terms[a]=e,$el.data(ns.data,_opts));var s=e.itemList||e;t($.map(s.slice(0,_opts.item),function(e){return setItem(e)}))}})}};else{"string"==typeof source&&(source=eval(source));var items=source.itemList||source;sourceFunction=function(e,t){if($el.is(":focus")){var a=new RegExp($.ui.autocomplete.escapeRegex(e.term),"i");t($.map(items,function(e){return a.test(e.name)?setItem(e):void 0}))}}}return sourceFunction},bindUIActions=function($el){var _opts=$el.data(ns.data);if("undefined"!=typeof _opts.props&&""!=_opts.props){var props=_opts.props.split(":");$el.next("."+ns.icon).addClass("uxitd-autocomplete-icon-clickable").on(events.click,function(e){e.preventDefault(),eval(props[1])})}_opts.onButtonClick!==!1&&$el.next("."+ns.icon).on(events.click,function(){callback(_opts.onButtonClick)}),$el.on(events.search,function(e,t){$(this).siblings("."+ns.icon).addClass(ns.loading)}),$el.on(events.response,function(e,t){$(this).siblings("."+ns.loading).removeClass(ns.loading)}),$el.autocomplete({open:function(e,t){$(".uxitd-autocomplete-category").removeClass("ui-menu-item"),$(this).autocomplete("widget").css({width:$(this).outerWidth()+"px"})},minLength:_opts.minLength,source:setSource($el),focus:function(e,t){_opts.arrowNavigation||e.preventDefault()},select:function(e,t){if(null!=_opts.hidden&&$(_opts.hidden).val(t.item.id),_opts.arrowSelection===!0&&13==e.keyCode&&"undefined"!=typeof t.item.url){var a=$("#"+e.currentTarget.id).find(".ui-state-focus a").attr("target");"_blank"==a?window.open(t.item.url):window.location=t.item.url}callback(_opts.onSelect)}})},setTemplate=function(e){var t=e.data(e.data("uiAutocomplete")?"uiAutocomplete":"ui-autocomplete"),a=e.data(ns.data),s={};if(null===a.template)switch(a.type){default:case"list":s=templates.list;break;case"image":s=templates.image;break;case"category":s=templates.category;break;case"tree":s=templates.tree}else s=a.template;t._renderMenu=function(e,t){var o=this,n=[],i="";$.each(t,function(t,r){var c;if(("category"==a.type||"tree"==a.type)&&"undefined"!=typeof r.category&&r.category!=i){var l=Handlebars.compile(s.head)(r);n.push(l),i=r.category}c=o._renderItemData(e,r),n.push(c)}),e.append(n),""!=i&&e.addClass("uxitd-category")},t._create=function(){var e=this;e._super(),e.widget().menu("option","items","> :not(.ui-autocomplete-category)")},t._renderItemData=function(e,t){var o,n=Handlebars.compile(s.item)(t);return o=n,a.highlight===!0&&(o=n.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+$.ui.autocomplete.escapeRegex(this.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),'$1')),$(o).addClass("ui-menu-item").data("ui-autocomplete-item",t).attr("role","presentation")}},setItem=function(e){return"undefined"==typeof e.value&&(e.value=e.name),"undefined"!=typeof e.visiblename&&(e.value=e.visiblename),e},callback=function(e){if("function"==typeof e)e.apply(this);else if(e!==!1){var t=new Function("return "+e);t()}};ux=$.fn.uxitdautocomplete=$.uxautocomplete=function(e){var t=this.selector;return this.each(function(){var a,s=$(this),o=s.data("uxRocket")||{};s.hasClass(ns.ready)||s.hasClass(ns.rocketWrap)||(s.addClass(ns.ready),o[ns.data]={hasWrapper:!0,wrapper:ns.wrap,ready:ns.ready,selector:t,options:e},s.data(ns.rocket,o),a=new AutoComplete(this,e,t))})},ux.clearCache=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data);t.terms={},e.data(ns.data,t),callback(t.onClearCache)})},ux.update=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data),a=e.data(ns.rocket);e.autocomplete("destroy"),e.removeData(ns.data),t=$.extend({},defaults,a[ns.data].options,$(this).data()),e.data(ns.data,t),e.off(events.click+" "+events.search+" "+events.response),bindUIActions(e),setTemplate(e),callback(t.onUpdate)})},ux.remove=function(e){var t=$(void 0!==e?e:"."+ns.ready);t.filter("input").each(function(){var e=$(this),t=e.data(ns.data),a=e.data(ns.rocket);e.removeClass(ns.ready),e.off(events.click+" "+events.search+" "+events.response),e.next("."+ns.icon).remove(),a[ns.data].hasWrapper&&(Object.keys&&1==Object.keys(a).length?e.unwrap():e.parent().removeClass(ns.wrap)),e.removeData(ns.data),delete a[ns.data],e.data(ns.rocket,a),e.autocomplete("destroy"),callback(t.onRemove)})},ux.version="1.8.1",ux.settings=defaults}(jQuery); +//# sourceMappingURL=uxrocket.autocomplete.min.js.map \ No newline at end of file diff --git a/dist/uxrocket.autocomplete.min.js.map b/dist/uxrocket.autocomplete.min.js.map index fa88ec9..09b6e63 100644 --- a/dist/uxrocket.autocomplete.min.js.map +++ b/dist/uxrocket.autocomplete.min.js.map @@ -1 +1 @@ -{"version":3,"file":"uxrocket.autocomplete.min.js","sources":["../lib/uxrocket.autocomplete.js"],"names":["$","ux","defaults","type","item","service","minLength","formdata","categoryTextLimit","queryType","hidden","template","highlight","arrowSelection","arrowNavigation","cache","onReady","onSelect","onButtonClick","onClearCache","onUpdate","onRemove","templates","list","wrap","image","category","head","tree","events","click","search","response","ns","rocket","data","ready","rocketWrap","icon","loading","AutoComplete","el","options","selector","$el","opts","extend","terms","setLayout","callback","bindUIActions","setTemplate","columns","_opts","context","className","replace","charAt","substr","parent","is","addClass","after","setSource","fdata","url_pattern","source","sourceFunction","test","request","term","map","itemList","slice","setItem","serialize","ajax","url","dataType","success","eval","matcher","RegExp","ui","autocomplete","escapeRegex","name","props","split","next","on","e","preventDefault","event","this","siblings","removeClass","open","css","width","outerWidth","focus","select","val","id","keyCode","_target","currentTarget","find","attr","window","location","_renderMenu","ul","items","_this","_list","currentCategory","each","index","temp","categoryHead","Handlebars","compile","push","_renderItemData","append","_create","_super","widget","menu","rendered","listItem","value","visiblename","fn","apply","func","Function","uxitdautocomplete","uxautocomplete","uxrocket","hasClass","hasWrapper","wrapper","clearCache","undefined","filter","_instance","update","_rocket","removeData","off","remove","_uxrocket","Object","keys","length","unwrap","version","settings","jQuery"],"mappings":"CAUA,SAAUA,GACN,GAAIC,IAEAC,UACIC,KAAmB,OACnBC,KAAmB,GACnBC,QAAmB,KACnBC,UAAmB,EACnBC,SAAmB,KACnBC,kBAAmB,GACnBC,UAAmB,MACnBC,OAAmB,KACnBC,SAAmB,KACnBC,WAAmB,EACnBC,gBAAmB,EACnBC,iBAAmB,EACnBC,OAAmB,EAGnBC,SAAmB,EACnBC,UAAmB,EACnBC,eAAmB,EACnBC,cAAmB,EACnBC,UAAmB,EACnBC,UAAmB,GAGvBC,WACIC,MACIC,KAAM,YACNpB,KAAM,uJAUVqB,OACID,KAAM,YACNpB,KAAM,qNAWVsB,UACIF,KAAM,YACNG,KAAM,gKAINvB,KAAM,uJAUVwB,MACIJ,KAAM,YACNG,KAAM,gKAINvB,KAAM,sNAYdyB,QACIC,MAAU,uBACVC,OAAU,oCACVC,SAAU,uCAEdC,IACIC,OAAY,WACZC,KAAY,iBACZC,MAAY,2BACZC,WAAY,oBACZb,KAAY,0BACZc,KAAY,cACZC,QAAY,gBAGhBC,aAAe,SAASC,EAAIC,EAASC,GACrC,GAAIC,GAAM5C,EAAEyC,GACRI,EAAO7C,EAAE8C,UAAW5C,SAAUwC,EAASE,EAAIT,QAASQ,SAAYA,GAGpEE,GAAKE,SAELH,EAAIT,KAAKF,GAAGE,KAAMU,GAGlBG,UAAUJ,GAGVK,SAASJ,EAAK7B,SAGdkC,cA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AAYvC,EAAMhF,KAAKF,GAAGC,OAG9BiF,GAAMnB,YAAY/D,GAAGG,OAGrB+E,EAAMqC,IAAI3H,OAAOC,MAAQ,IAAMD,OAAOE,OAAS,IAAMF,OAAOG,UAG5DmF,EAAM1B,KAAK,IAAMxD,GAAGK,MAAMmH,SAEvBC,EAAUzH,GAAGE,MAAM4G,aACfY,OAAOC,MAAyC,GAAjCD,OAAOC,KAAKF,GAAWG,OACrC1C,EAAM2C,SAIN3C,EAAMxD,SAASqC,YAAY/D,GAAGT,OAKtC2F,EAAMoC,WAAWtH,GAAGE,YAGbuH,GAAUzH,GAAGE,MACpBgF,EAAMhF,KAAKF,GAAGC,OAAQwH,GAGtBvC,EAAM/B,aAAa,WAEnBnC,SAASmG,EAAU/H,aAK3BpB,GAAG8J,QAAU,QAGb9J,GAAG+J,SAAW9J,UACf+J"} \ No newline at end of file +{"version":3,"sources":["uxrocket.autocomplete.js"],"names":["$","ux","defaults","type","item","service","minLength","formdata","categoryTextLimit","queryType","hidden","template","highlight","arrowSelection","arrowNavigation","cache","onReady","onSelect","onButtonClick","onClearCache","onUpdate","onRemove","templates","list","wrap","image","category","head","tree","events","click","search","response","ns","rocket","data","ready","rocketWrap","icon","loading","AutoComplete","el","options","selector","$el","opts","extend","terms","setLayout","callback","bindUIActions","setTemplate","columns","_opts","context","className","replace","charAt","substr","parent","is","addClass","after","setSource","fdata","url_pattern","source","sourceFunction","test","request","term","items","itemList","map","slice","setItem","serialize","ajax","url","dataType","success","eval","matcher","RegExp","ui","autocomplete","escapeRegex","name","props","split","next","on","e","preventDefault","event","this","siblings","removeClass","open","css","width","outerWidth","focus","select","val","id","keyCode","_target","currentTarget","find","attr","window","location","_renderMenu","ul","_this","_list","currentCategory","each","index","temp","categoryHead","Handlebars","compile","push","_renderItemData","append","_create","_super","widget","menu","rendered","listItem","value","visiblename","fn","apply","func","Function","uxitdautocomplete","uxautocomplete","uxrocket","hasClass","hasWrapper","wrapper","clearCache","undefined","filter","_instance","update","_rocket","removeData","off","remove","_uxrocket","Object","keys","length","unwrap","version","settings","jQuery"],"mappings":"CAUA,SAAUA,GACN,GAAIC,IAEAC,UACIC,KAAmB,OACnBC,KAAmB,GACnBC,QAAmB,KACnBC,UAAmB,EACnBC,SAAmB,KACnBC,kBAAmB,GACnBC,UAAmB,MACnBC,OAAmB,KACnBC,SAAmB,KACnBC,WAAmB,EACnBC,gBAAmB,EACnBC,iBAAmB,EACnBC,OAAmB,EAGnBC,SAAe,EACfC,UAAe,EACfC,eAAe,EACfC,cAAe,EACfC,UAAe,EACfC,UAAe,GAGnBC,WACIC,MACIC,KAAM,YACNpB,KAAM,uJAUVqB,OACID,KAAM,YACNpB,KAAM,qNAWVsB,UACIF,KAAM,YACNG,KAAM,gKAINvB,KAAM,uJAUVwB,MACIJ,KAAM,YACNG,KAAM,gKAINvB,KAAM,sNAYdyB,QACIC,MAAU,uBACVC,OAAU,oCACVC,SAAU,uCAEdC,IACIC,OAAY,WACZC,KAAY,iBACZC,MAAY,2BACZC,WAAY,oBACZb,KAAY,0BACZc,KAAY,cACZC,QAAY,gBAGhBC,aAAe,SAASC,EAAIC,EAASC,GACrC,GAAIC,GAAM5C,EAAEyC,GACRI,EAAO7C,EAAE8C,UAAW5C,SAAUwC,EAASE,EAAIT,QAASQ,SAAYA,GAGpEE,GAAKE,SAELH,EAAIT,KAAKF,GAAGE,KAAMU,GAGlBG,UAAUJ,GAGVK,SAASJ,EAAK7B,SAGdkC,cAAcN,GAGdO,YAAYP,IAGZI,UAAY,SAASJ,GACrB,GAAIQ,GACAC,EAAQT,EAAIT,KAAKF,GAAGE,KAExBiB,GAAU,IAAMR,EAAIU,QAAQC,UAAUC,QAAQvB,GAAGG,MAAO,IAEzB,KAA5BiB,EAAMV,SAASc,OAAO,KACrBL,EAAUA,EAAQI,QAAQ,IAAMH,EAAMV,SAASe,OAAO,GAAI,IAC1DN,EAAUA,EAAQI,QAAQH,EAAMV,SAASe,OAAO,GAAK,IAAK,KAG3Dd,E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MzD,GAAGK,MAAMmH,SAEvBC,EAAUzH,GAAGE,MAAM4G,aACfY,OAAOC,MAAyC,GAAjCD,OAAOC,KAAKF,GAAWG,OACrC1C,EAAM2C,SAIN3C,EAAMxD,SAASsC,YAAYhE,GAAGT,OAKtC2F,EAAMoC,WAAWtH,GAAGE,YAGbuH,GAAUzH,GAAGE,MACpBgF,EAAMhF,KAAKF,GAAGC,OAAQwH,GAGtBvC,EAAM9B,aAAa,WAEnBpC,SAASmG,EAAU/H,aAK3BpB,GAAG8J,QAAU,QAGb9J,GAAG+J,SAAW9J,UACf+J","file":"uxrocket.autocomplete.min.js","sourcesContent":["/**\n * UX Rocket\n * jQuery based accordion\n * @author Bilal Cinarli\n * @dependency jQueryUI Autocomplete\n * @dependency Handlebars\n * @dependency UX Rocket Clear\n */\n\n;\n(function($) {\n var ux, // local shorthand\n\n defaults = {\n type : \"list\",\n item : 10,\n service : null,\n minLength : 2,\n formdata : null,\n categoryTextLimit: 25,\n queryType : 'GET',\n hidden : null,\n template : null,\n highlight : true,\n arrowSelection : false,\n arrowNavigation : true,\n cache : false,\n\n // callbacks\n onReady : false,\n onSelect : false,\n onButtonClick: false,\n onClearCache : false,\n onUpdate : false,\n onRemove : false\n },\n\n templates = {\n list : {\n wrap: '',\n item: '' +\n '
  • ' +\n ' ' +\n ' {{{name}}}' +\n ' {{#if title}}' +\n '
    {{substr title 50}}' +\n ' {{/if}}' +\n '
    ' +\n '
  • '\n },\n image : {\n wrap: '',\n item: '' +\n '
  • ' +\n ' ' +\n ' ' +\n ' {{{name}}}' +\n ' {{#if title}}' +\n '
    {{substr title 50}}' +\n ' {{/if}}' +\n '
    ' +\n '
  • '\n },\n category: {\n wrap: '',\n head: '' +\n '
  • ' +\n ' {{substr category 25}}' +\n '
  • ',\n item: '' +\n '
  • ' +\n ' ' +\n ' {{{name}}}' +\n ' {{#if title}}' +\n '
    {{substr title 50}}' +\n ' {{/if}}' +\n '
    ' +\n '
  • '\n },\n tree : {\n wrap: '',\n head: '' +\n '
  • ' +\n ' {{substr category 25}}' +\n '
  • ',\n item: '' +\n '
  • ' +\n ' ' +\n ' ' +\n ' {{{name}}}' +\n ' {{#if title}}' +\n '
    {{substr title 50}}' +\n ' {{/if}}' +\n '
    ' +\n '
  • '\n }\n },\n events = {\n click : 'click.uxAutocomplete',\n search : 'autocompletesearch.uxAutocomplete',\n response: 'autocompleteresponse.uxAutocomplete'\n },\n ns = {\n rocket : 'uxRocket',\n data : 'uxAutocomplete',\n ready : 'uxitd-autocomplete-ready',\n rocketWrap: 'uxitd-plugin-wrap',\n wrap : 'uxitd-autocomplete-wrap',\n icon : 'icon-search',\n loading : 'icon-loading'\n };\n\n var AutoComplete = function(el, options, selector) {\n var $el = $(el),\n opts = $.extend({}, defaults, options, $el.data(), {'selector': selector});\n\n // terms object for caching\n opts.terms = {};\n\n $el.data(ns.data, opts);\n\n // set element layout\n setLayout($el);\n\n // call Ready Callback\n callback(opts.onReady);\n\n // bind actions\n bindUIActions($el);\n\n // set template actions\n setTemplate($el);\n };\n\n var setLayout = function($el) {\n var columns,\n _opts = $el.data(ns.data);\n\n columns = ' ' + $el.context.className.replace(ns.ready, '');\n\n if(_opts.selector.charAt(0) == '.') {\n columns = columns.replace(' ' + _opts.selector.substr(1), '');\n columns = columns.replace(_opts.selector.substr(1) + ' ', '');\n }\n\n if($el.parent().is('.' + ns.rocketWrap)) {\n $el.parent().addClass(ns.wrap + columns + ' group');\n }\n else {\n $el.wrap('');\n }\n\n $el.after('');\n };\n\n var setSource = function($el) {\n var _opts = $el.data(ns.data),\n fdata = null,\n url_pattern = /^(http|https|\\/|\\.\\/|\\.\\.\\/)/,\n source = _opts.service,\n sourceFunction;\n\n\n if(!url_pattern.test(source) || typeof source === \"object\") {\n if(typeof source === \"string\") {\n // we get source from \"data-service\" attribute,\n // so we need to change its format to js array\n source = eval(source);\n }\n // in older versions the js array or json object should\n // encapsulated with \"itemList\" node.\n var items = source.itemList || source;\n\n sourceFunction = function(request, response) {\n // check if element is active or not : fix for IE\n if(!$el.is(':focus')) {\n return;\n }\n\n var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), \"i\");\n\n response($.map(items, function(item) {\n if(matcher.test(item.name)) {\n return setItem(item);\n }\n }));\n };\n }\n else {\n sourceFunction = function(request, response) {\n var term = request.term;\n\n // check if element is active or not : fix for IE\n if(!$el.is(':focus')) {\n return;\n }\n\n if(_opts.cache && term in _opts.terms) {\n var items = _opts.terms[term].itemList || _opts.terms[term];\n\n response($.map(items.slice(0, _opts.item), function(item) {\n return setItem(item);\n }));\n return;\n }\n\n if(_opts.formdata != null) {\n fdata = $(_opts.formdata).serialize();\n }\n\n $.ajax({\n url : source,\n dataType: 'json',\n type : _opts.queryType,\n data : {\n type : _opts.type,\n term : term,\n formdata: fdata\n },\n success : function(data) {\n if(_opts.cache) {\n _opts.terms[term] = data;\n $el.data(ns.data, _opts);\n }\n\n var items = data.itemList || data;\n\n response($.map(items.slice(0, _opts.item), function(item) {\n return setItem(item);\n }));\n }\n });\n };\n }\n\n return sourceFunction;\n };\n\n var bindUIActions = function($el) {\n var _opts = $el.data(ns.data);\n\n if(typeof _opts.props !== 'undefined' && _opts.props != '') {\n var props = _opts.props.split(':');\n\n $el.next('.' + ns.icon).addClass('uxitd-autocomplete-icon-clickable').on(events.click, function(e) {\n e.preventDefault();\n eval(props[1]);\n });\n }\n\n if(_opts.onButtonClick !== false) {\n $el.next('.' + ns.icon).on(events.click, function() {\n callback(_opts.onButtonClick);\n });\n }\n\n $el.on(events.search, function(event, ui) {\n $(this).siblings('.' + ns.icon).addClass(ns.loading);\n });\n\n $el.on(events.response, function(event, ui) {\n $(this).siblings('.' + ns.loading).removeClass(ns.loading);\n });\n\n $el.autocomplete({\n open : function(event, ui) {\n $(\".uxitd-autocomplete-category\").removeClass('ui-menu-item');\n\n $(this).autocomplete(\"widget\").css({\n \"width\": ($(this).outerWidth() + \"px\")\n });\n },\n minLength: _opts.minLength,\n source : setSource($el),\n focus : function(event, ui) {\n if(!_opts.arrowNavigation) {\n event.preventDefault();\n }\n },\n select : function(event, ui) {\n if(_opts.hidden != null) {\n $(_opts.hidden).val(ui.item.id);\n }\n\n if(_opts.arrowSelection === true && event.keyCode == 13 && typeof ui.item.url !== 'undefined') {\n // check if target is blank or not\n var _target = $(\"#\" + event.currentTarget.id).find(\".ui-state-focus a\").attr(\"target\");\n\n if(_target == '_blank') {\n window.open(ui.item.url);\n }\n else {\n window.location = ui.item.url;\n }\n }\n\n callback(_opts.onSelect);\n }\n });\n };\n\n var setTemplate = function($el) {\n var autocomplete = $el.data(\"uiAutocomplete\") ? $el.data(\"uiAutocomplete\") : $el.data(\"ui-autocomplete\"),\n _opts = $el.data(ns.data),\n template = {};\n\n if(_opts.template === null) {\n switch(_opts.type) {\n default:\n case 'list':\n template = templates.list;\n break;\n case 'image':\n template = templates.image;\n break;\n case 'category':\n template = templates.category;\n break;\n case 'tree':\n template = templates.tree;\n break;\n }\n }\n\n else {\n template = _opts.template;\n }\n\n autocomplete._renderMenu = function(ul, items) {\n var _this = this,\n _list = [],\n currentCategory = \"\";\n\n $.each(items, function(index, item) {\n var temp;\n\n if((_opts.type == 'category' || _opts.type == 'tree') && typeof item.category !== 'undefined' && item.category != currentCategory) {\n\n var categoryHead = Handlebars.compile(template.head)(item);\n\n _list.push(categoryHead);\n\n currentCategory = item.category;\n }\n\n temp = _this._renderItemData(ul, item);\n\n _list.push(temp);\n });\n\n ul.append(_list);\n\n if(currentCategory != \"\") {\n ul.addClass('uxitd-category');\n }\n };\n\n autocomplete._create = function() {\n var _this = this;\n\n _this._super();\n _this.widget().menu(\"option\", \"items\", \"> :not(.ui-autocomplete-category)\");\n };\n\n autocomplete._renderItemData = function(ul, item) {\n var rendered,\n listItem = Handlebars.compile(template.item)(item);\n\n rendered = listItem;\n\n if(_opts.highlight === true) {\n rendered = listItem.replace(\n new RegExp(\"(?![^&;]+;)(?!<[^<>]*)(\" + $.ui.autocomplete.escapeRegex(this.term) + \")(?![^<>]*>)(?![^&;]+;)\", \"gi\"),\n '$1');\n }\n\n return $(rendered)\n .addClass('ui-menu-item')\n .data(\"ui-autocomplete-item\", item)\n .attr('role', 'presentation');\n };\n };\n\n // fallback for 0.x.x versions\n var setItem = function(item) {\n if(typeof item.value === 'undefined') {\n item.value = item.name;\n }\n\n /**\n * Fallback for old data json format\n * @deprecated visiblename\n */\n if(typeof item.visiblename !== 'undefined') {\n item.value = item.visiblename;\n }\n\n return item;\n };\n\n // global callback\n var callback = function(fn) {\n // if callback string is function call it directly\n if(typeof fn === 'function') {\n fn.apply(this);\n }\n\n // if callback defined via data-attribute, call it via new Function\n else {\n if(fn !== false) {\n var func = new Function('return ' + fn);\n func();\n }\n }\n };\n\n // jquery bindings\n ux = $.fn.uxitdautocomplete = $.uxautocomplete = function(options) {\n var selector = this.selector;\n\n return this.each(function() {\n var $el = $(this),\n uxrocket = $el.data('uxRocket') || {},\n autocomplete;\n\n if($el.hasClass(ns.ready) || $el.hasClass(ns.rocketWrap)) {\n return;\n }\n\n $el.addClass(ns.ready);\n\n uxrocket[ns.data] = {'hasWrapper': true, 'wrapper': ns.wrap, 'ready': ns.ready, 'selector': selector, 'options': options};\n\n $el.data(ns.rocket, uxrocket);\n\n autocomplete = new AutoComplete(this, options, selector);\n });\n };\n\n ux.clearCache = function(el) {\n var $el = el !== undefined ? $(el) : $(\".\" + ns.ready);\n\n $el.filter('input').each(function() {\n var _this = $(this),\n _instance = _this.data(ns.data);\n\n // set cache terms to empty object\n _instance.terms = {};\n\n _this.data(ns.data, _instance);\n\n callback(_instance.onClearCache);\n });\n };\n\n ux.update = function(el) {\n var $el = el !== undefined ? $(el) : $(\".\" + ns.ready);\n\n $el.filter('input').each(function() {\n var _this = $(this),\n _instance = _this.data(ns.data),\n _rocket = _this.data(ns.rocket);\n\n // first remove jQuery UI Autocomplete\n _this.autocomplete('destroy');\n\n\n // remove previous instance data\n // since we are removing the rocket data no need to clear cache separately\n _this.removeData(ns.data);\n\n // add new options\n _instance = $.extend({}, defaults, _rocket[ns.data]['options'], $(this).data());\n\n // register new instance data\n _this.data(ns.data, _instance);\n\n _this.off(events.click + ' ' + events.search + ' ' + events.response);\n\n bindUIActions(_this);\n\n setTemplate(_this);\n\n callback(_instance.onUpdate);\n });\n };\n\n ux.remove = function(el) {\n var $el = el !== undefined ? $(el) : $(\".\" + ns.ready);\n\n $el.filter('input').each(function() {\n var _this = $(this),\n _instance = _this.data(ns.data),\n _uxrocket = _this.data(ns.rocket);\n\n // remove ready class\n _this.removeClass(ns.ready);\n\n // remove plugin events\n _this.off(events.click + ' ' + events.search + ' ' + events.response);\n\n // remove icon and wrapper\n _this.next('.' + ns.icon).remove();\n\n if(_uxrocket[ns.data].hasWrapper) {\n if(Object.keys && Object.keys(_uxrocket).length == 1) {\n _this.unwrap();\n }\n\n else {\n _this.parent().removeClass(ns.wrap);\n }\n }\n\n // remove plugin data\n _this.removeData(ns.data);\n\n // remove uxRocket registry\n delete _uxrocket[ns.data];\n _this.data(ns.rocket, _uxrocket);\n\n // remove jQueryUI\n _this.autocomplete('destroy');\n\n callback(_instance.onRemove);\n });\n };\n\n // version\n ux.version = '1.8.1';\n\n // settings\n ux.settings = defaults;\n})(jQuery);\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/autocomplete.php b/examples/autocomplete.php new file mode 100755 index 0000000..769e07a --- /dev/null +++ b/examples/autocomplete.php @@ -0,0 +1,64 @@ + $value) { + $id = $key + 1; + + if ($id < 10) { + $id = '0' . $id; + } + + $autocomplete[] = array( + 'category' => substr($value, 0, 1), + 'image' => 'placeholder/profile-' . $id . '.jpg', + 'name' => $value, + 'value' => $value, + 'title' => 'Developer', + 'id' => $id); +} + +$items['itemList'] = array(); +$itemList = array(); + +foreach ($autocomplete as $item) { + if (stripos($item['name'], $_GET['term']) !== false) { + switch ($type) { + default: + case 'list': + $items['itemList'][] = array('name' => $item['name'], 'id' => $item['id']); + $itemList[] = array('name' => $item['name'], 'id' => $item['id']); + break; + case 'image': + $items['itemList'][] = array('value' => $item['value'], 'image' => $item['image'], 'name' => $item['name'], 'id' => $item['id']); + $itemList[] = array('value' => $item['value'], 'image' => $item['image'], 'name' => $item['name'], 'id' => $item['id']); + break; + case 'category': + $items['itemList'][] = array('value' => $item['value'], 'category' => $item['category'], 'name' => $item['name'], + 'id' => $item['id'], 'visiblename' => $item['category'] . ', ' . $item['name']); + $itemList[] = array('value' => $item['value'], 'category' => $item['category'], 'name' => $item['name'], + 'id' => $item['id'], 'visiblename' => $item['category'] . ', ' . $item['name']); + break; + case 'tree': + $items['itemList'][] = array('value' => $item['value'], 'category' => $item['category'], 'image' => $item['image'], 'name' => $item['name'], 'id' => $item['id']); + $itemList[] = array('value' => $item['value'], 'category' => $item['category'], 'image' => $item['image'], 'name' => $item['name'], 'id' => $item['id']); + break; + } + } +} + +sleep(2); + +header('Content-Type: application/json'); + +//echo json_encode($items); +echo json_encode($itemList); \ No newline at end of file diff --git a/examples/placeholder/profile-01.jpg b/examples/placeholder/profile-01.jpg new file mode 100755 index 0000000..c631730 Binary files /dev/null and b/examples/placeholder/profile-01.jpg differ diff --git a/examples/placeholder/profile-02.jpg b/examples/placeholder/profile-02.jpg new file mode 100755 index 0000000..b5b17ab Binary files /dev/null and b/examples/placeholder/profile-02.jpg differ diff --git a/examples/placeholder/profile-03.jpg b/examples/placeholder/profile-03.jpg new file mode 100755 index 0000000..8ea5e80 Binary files /dev/null and b/examples/placeholder/profile-03.jpg differ diff --git a/examples/placeholder/profile-04.jpg b/examples/placeholder/profile-04.jpg new file mode 100755 index 0000000..e9e1e63 Binary files /dev/null and b/examples/placeholder/profile-04.jpg differ diff --git a/examples/placeholder/profile-05.jpg b/examples/placeholder/profile-05.jpg new file mode 100755 index 0000000..cf7794c Binary files /dev/null and b/examples/placeholder/profile-05.jpg differ diff --git a/examples/placeholder/profile-06.jpg b/examples/placeholder/profile-06.jpg new file mode 100755 index 0000000..8d4ef6d Binary files /dev/null and b/examples/placeholder/profile-06.jpg differ diff --git a/examples/placeholder/profile-07.jpg b/examples/placeholder/profile-07.jpg new file mode 100755 index 0000000..67a98e9 Binary files /dev/null and b/examples/placeholder/profile-07.jpg differ diff --git a/examples/placeholder/profile-08.jpg b/examples/placeholder/profile-08.jpg new file mode 100755 index 0000000..8b43de9 Binary files /dev/null and b/examples/placeholder/profile-08.jpg differ diff --git a/examples/placeholder/profile-09.jpg b/examples/placeholder/profile-09.jpg new file mode 100755 index 0000000..f112175 Binary files /dev/null and b/examples/placeholder/profile-09.jpg differ diff --git a/examples/placeholder/profile-11.jpg b/examples/placeholder/profile-11.jpg new file mode 100755 index 0000000..5ed4d04 Binary files /dev/null and b/examples/placeholder/profile-11.jpg differ diff --git a/examples/placeholder/profile-12.jpg b/examples/placeholder/profile-12.jpg new file mode 100755 index 0000000..4d370b6 Binary files /dev/null and b/examples/placeholder/profile-12.jpg differ diff --git a/examples/placeholder/profile-13.jpg b/examples/placeholder/profile-13.jpg new file mode 100755 index 0000000..2458a42 Binary files /dev/null and b/examples/placeholder/profile-13.jpg differ diff --git a/examples/placeholder/profile-14.jpg b/examples/placeholder/profile-14.jpg new file mode 100755 index 0000000..5ff592c Binary files /dev/null and b/examples/placeholder/profile-14.jpg differ diff --git a/examples/placeholder/profile-15.jpg b/examples/placeholder/profile-15.jpg new file mode 100755 index 0000000..51757c2 Binary files /dev/null and b/examples/placeholder/profile-15.jpg differ diff --git a/examples/placeholder/profile-16.jpg b/examples/placeholder/profile-16.jpg new file mode 100755 index 0000000..ca5cd71 Binary files /dev/null and b/examples/placeholder/profile-16.jpg differ diff --git a/examples/placeholder/profile-17.jpg b/examples/placeholder/profile-17.jpg new file mode 100755 index 0000000..033b76e Binary files /dev/null and b/examples/placeholder/profile-17.jpg differ diff --git a/examples/placeholder/profile-18.jpg b/examples/placeholder/profile-18.jpg new file mode 100755 index 0000000..5645e7c Binary files /dev/null and b/examples/placeholder/profile-18.jpg differ diff --git a/examples/placeholder/profile-19.jpg b/examples/placeholder/profile-19.jpg new file mode 100755 index 0000000..fa49302 Binary files /dev/null and b/examples/placeholder/profile-19.jpg differ diff --git a/examples/placeholder/profile-20.jpg b/examples/placeholder/profile-20.jpg new file mode 100755 index 0000000..43c53bf Binary files /dev/null and b/examples/placeholder/profile-20.jpg differ diff --git a/examples/placeholder/profile-21.jpg b/examples/placeholder/profile-21.jpg new file mode 100755 index 0000000..c56fe8d Binary files /dev/null and b/examples/placeholder/profile-21.jpg differ diff --git a/examples/placeholder/profile-22.jpg b/examples/placeholder/profile-22.jpg new file mode 100755 index 0000000..d826d32 Binary files /dev/null and b/examples/placeholder/profile-22.jpg differ diff --git a/examples/placeholder/profile-23.jpg b/examples/placeholder/profile-23.jpg new file mode 100755 index 0000000..33a82cb Binary files /dev/null and b/examples/placeholder/profile-23.jpg differ diff --git a/examples/placeholder/server.png b/examples/placeholder/server.png new file mode 100755 index 0000000..5b0c06e Binary files /dev/null and b/examples/placeholder/server.png differ diff --git a/examples/sample.html b/examples/sample.html new file mode 100755 index 0000000..9367ac5 --- /dev/null +++ b/examples/sample.html @@ -0,0 +1,82 @@ + + + + UX Rocket Autocomplete Sample + + + + + + + + + +
    +
    +

    Please type a programing language like 'ActionScript', 'AppleScript', 'Asp', 'Basic', 'C', 'C++', 'Clojure', 'Cobol', 'ColdFusion', 'Erlang', 'Fortran', 'Groovy', 'Haskell', 'Java', 'JavaScript', 'List', 'Perl', 'PHP', 'Ruby', 'Python', 'Scala', 'Scheme'

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    + +

    +
    + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/lib/uxrocket.autocomplete.js b/lib/uxrocket.autocomplete.js index 6ae3d49..e633eb9 100644 --- a/lib/uxrocket.autocomplete.js +++ b/lib/uxrocket.autocomplete.js @@ -17,6 +17,7 @@ service : null, minLength : 2, formdata : null, + serialize : 'String', // String || Array || Object categoryTextLimit: 25, queryType : 'GET', hidden : null, @@ -213,7 +214,7 @@ } if(_opts.formdata != null) { - fdata = $(_opts.formdata).serialize(); + fdata = _opts.serialize === 'String' ? $(_opts.formdata).serialize() : $(_opts.formdata)['serialize' + _opts.serialize](); } $.ajax({ @@ -416,6 +417,24 @@ return item; }; + $.fn.serializeObject = function() { + var _o = {}, + _a = this.serializeArray(); + + $.each(_a, function() { + if(_o[this.name]) { + if(!_o[this.name].push) { + _o[this.name] = [_o[this.name]]; + } + _o[this.name].push(this.value || ''); + } else { + _o[this.name] = this.value || ''; + } + }); + + return _o; + }; + // global callback var callback = function(fn) { // if callback string is function call it directly @@ -545,7 +564,7 @@ }; // version - ux.version = '1.8.1'; + ux.version = '1.8.2'; // settings ux.settings = defaults;