diff --git a/src/configuration.js b/src/configuration.js index aa734d2..b25f11d 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -1,5 +1,5 @@ /* - * EasyAutocomplete - Configuration + * EasyAutocomplete - Configuration */ var EasyAutocomplete = (function(scope){ @@ -81,7 +81,7 @@ var EasyAutocomplete = (function(scope){ onChooseEvent: function() {}, onKeyEnterEvent: function() {}, onMouseOverEvent: function() {}, - onMouseOutEvent: function() {}, + onMouseOutEvent: function() {}, onShowListEvent: function() {}, onHideListEvent: function() {} }, @@ -98,6 +98,8 @@ var EasyAutocomplete = (function(scope){ adjustWidth: true, + noResults: false, + ajaxSettings: {}, preparePostData: function(data, inputPhrase) {return data;}, @@ -114,7 +116,7 @@ var EasyAutocomplete = (function(scope){ }] }; - + var externalObjects = ["ajaxSettings", "template"]; this.get = function(propertyName) { @@ -126,8 +128,8 @@ var EasyAutocomplete = (function(scope){ if (defaults[name] === value) { return true; } - } - + } + return false; }; @@ -159,7 +161,7 @@ var EasyAutocomplete = (function(scope){ mergeOptions(); if (defaults.loggerEnabled === true) { - printPropertiesThatDoesntExist(console, options); + printPropertiesThatDoesntExist(console, options); } addAjaxSettings(); @@ -174,7 +176,7 @@ var EasyAutocomplete = (function(scope){ function prepareDefaults() { if (options.dataType === "xml") { - + if (!options.getValue) { options.getValue = function(element) { @@ -182,11 +184,11 @@ var EasyAutocomplete = (function(scope){ }; } - + if (!options.list) { options.list = {}; - } + } if (!options.list.sort) { options.list.sort = {}; @@ -196,7 +198,7 @@ var EasyAutocomplete = (function(scope){ options.list.sort.method = function(a, b) { a = options.getValue(a); b = options.getValue(b); - + //Alphabeticall sort if (a < b) { return -1; @@ -227,7 +229,7 @@ var EasyAutocomplete = (function(scope){ var categories = []; - for (var i = 0, length = options.categories.length; i < length; i += 1) { + for (var i = 0, length = options.categories.length; i < length; i += 1) { var category = options.categories[i]; @@ -258,7 +260,7 @@ var EasyAutocomplete = (function(scope){ for (var propertyName in source) { if (target[propertyName] !== undefined && target[propertyName] !== null) { - if (typeof target[propertyName] !== "object" || + if (typeof target[propertyName] !== "object" || target[propertyName] instanceof Array) { mergedObject[propertyName] = target[propertyName]; } else { @@ -266,7 +268,7 @@ var EasyAutocomplete = (function(scope){ } } } - + /* If data is an object */ if (target.data !== undefined && target.data !== null && typeof target.data === "object") { mergedObject.data = target.data; @@ -274,11 +276,11 @@ var EasyAutocomplete = (function(scope){ return mergedObject; } - } + } function processAfterMerge() { - + if (defaults.url !== "list-required" && typeof defaults.url !== "function") { var defaultUrl = defaults.url; defaults.url = function() { @@ -303,7 +305,7 @@ var EasyAutocomplete = (function(scope){ } else { defaults.listLocation = function(data) { return data[defaultlistLocation]; - }; + }; } } @@ -325,9 +327,9 @@ var EasyAutocomplete = (function(scope){ if (options.ajaxSettings !== undefined && typeof options.ajaxSettings === "object") { defaults.ajaxSettings = options.ajaxSettings; } else { - defaults.ajaxSettings = {}; + defaults.ajaxSettings = {}; } - + } function isAssigned(name) { @@ -341,19 +343,19 @@ var EasyAutocomplete = (function(scope){ //Consol is object that should have method log that prints string //Normally invoke this function with console as consol function printPropertiesThatDoesntExist(consol, optionsToCheck) { - + checkPropertiesIfExist(defaults, optionsToCheck); function checkPropertiesIfExist(source, target) { for(var property in target) { if (source[property] === undefined) { - consol.log("Property '" + property + "' does not exist in EasyAutocomplete options API."); + consol.log("Property '" + property + "' does not exist in EasyAutocomplete options API."); } if (typeof source[property] === "object" && $.inArray(property, externalObjects) === -1) { checkPropertiesIfExist(source[property], target[property]); } - } + } } } }; @@ -361,4 +363,3 @@ var EasyAutocomplete = (function(scope){ return scope; })(EasyAutocomplete || {}); - diff --git a/src/core.js b/src/core.js index 4203dfa..419e756 100644 --- a/src/core.js +++ b/src/core.js @@ -4,9 +4,9 @@ */ var EasyAutocomplete = (function(scope) { - + scope.main = function Core($input, options) { - + var module = { name: "EasyAutocomplete", shortcut: "eac" @@ -19,14 +19,14 @@ var EasyAutocomplete = (function(scope) { listBuilderService = new scope.ListBuilderService(config, scope.proccess), checkParam = config.equals, - $field = $input, + $field = $input, $container = "", elementsList = [], selectedElement = -1, requestDelayTimeoutId; scope.consts = consts; - + //------------------------ GETTERS -------------------------- @@ -63,7 +63,7 @@ var EasyAutocomplete = (function(scope) { return this.getItemData(selectedElement); }; - //------------------------ PUBLIC METHODS STARTS -------------------------- + //------------------------ PUBLIC METHODS STARTS -------------------------- this.build = function() { prepareField(); @@ -73,7 +73,7 @@ var EasyAutocomplete = (function(scope) { init(); }; - //------------------------ PUBLIC METHODS ENDS -------------------------- + //------------------------ PUBLIC METHODS ENDS -------------------------- //Main method @@ -96,7 +96,7 @@ var EasyAutocomplete = (function(scope) { prepareField(); - bindEvents(); + bindEvents(); } @@ -109,14 +109,14 @@ var EasyAutocomplete = (function(scope) { //TODO Rebuild this function function prepareField() { - + if ($field.parent().hasClass(consts.getValue("WRAPPER_CSS_CLASS"))) { removeContainer(); removeWrapper(); - } - + } + createWrapper(); - createContainer(); + createContainer(); $container = $("#" + getContainerId()); @@ -131,7 +131,7 @@ var EasyAutocomplete = (function(scope) { var $wrapper = $("