From 71ebac9fbe2729f6c4753db83a753e21d8d60ab3 Mon Sep 17 00:00:00 2001 From: Rolux Date: Thu, 18 Feb 2010 23:15:37 +0530 Subject: [PATCH] autocomplete, continued --- build/css/ox.ui.classic.css | 4 ++++ build/css/ox.ui.css | 1 + build/css/ox.ui.modern.css | 4 ++++ build/js/ox.js | 8 ++++++++ build/js/ox.ui.js | 2 +- demos/test/index.html | 5 +++-- 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build/css/ox.ui.classic.css b/build/css/ox.ui.classic.css index 5aaf4c3..d320935 100644 --- a/build/css/ox.ui.classic.css +++ b/build/css/ox.ui.classic.css @@ -4,6 +4,10 @@ body.OxThemeClassic { .OxThemeClassic div { color: rgb(16, 16, 16); } +.OxThemeClassic .OxHighlight { + background: rgb(255, 255, 0); +} + /* ================================================================================ diff --git a/build/css/ox.ui.css b/build/css/ox.ui.css index 2cbb5bd..d25a794 100644 --- a/build/css/ox.ui.css +++ b/build/css/ox.ui.css @@ -20,6 +20,7 @@ div, input { td { padding: 0px; } + /* ================================================================================ Core diff --git a/build/css/ox.ui.modern.css b/build/css/ox.ui.modern.css index 09854aa..3131830 100644 --- a/build/css/ox.ui.modern.css +++ b/build/css/ox.ui.modern.css @@ -4,6 +4,10 @@ body.OxThemeModern { .OxThemeModern div { color: rgb(240, 240, 240); } +.OxThemeModern .OxHighlight { + background: rgb(255, 255, 0); + color: rgb(0, 0, 0); +} /* ================================================================================ diff --git a/build/js/ox.js b/build/js/ox.js index a361cb0..ed0bf3d 100644 --- a/build/js/ox.js +++ b/build/js/ox.js @@ -1360,6 +1360,14 @@ Ox.startsWith = function(str, sub) { return str.substr(0, sub.length) === sub; }; +Ox.stripTags = function(str) { + /* + >>> Ox.stripTags("foo") + foo + */ + return str.replace(/(<.*?>)/gi, ""); +}; + Ox.toCamelCase = function(str) { /* >>> Ox.toCamelCase("foo-bar-baz") diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 88a429c..8d697e7 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1629,7 +1629,7 @@ requires } function onClick(event, data) { Ox.print("onClick", data) - that.focus().val(data.title); + that.focus().val(Ox.stripTags(data.title)); self.menu.hideMenu(); } function selection() { diff --git a/demos/test/index.html b/demos/test/index.html index 19db1a1..241d5c3 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -330,7 +330,8 @@ id: "state", autocomplete: function(value, callback) { value = value.toLowerCase(); - var items = []; + var items = [], + regexp = new RegExp("(" + value + ")", "ig"), states = [ "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", @@ -349,7 +350,7 @@ } else { $.each(states, function(i, state) { if (state.toLowerCase().indexOf(value) > -1) { - items.push(state); + items.push(state.replace(regexp, "$1")); } }); }