From cf2f5a48382a1ce98099d478d8e1d3fb669baca6 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 10 Feb 2014 00:48:20 +0100 Subject: [PATCH] Remove darline dependency --- fabfile.py | 1 - umap/static/darline | 1 - umap/static/favicon.ico | Bin 3005 -> 638 bytes umap/static/umap/js/autocomplete.js | 339 ++++++++++++++++++++++++++++ umap/static/umap/umap.css | 35 +++ umap/templates/base.html | 13 +- 6 files changed, 379 insertions(+), 10 deletions(-) delete mode 160000 umap/static/darline create mode 100644 umap/static/umap/js/autocomplete.js diff --git a/fabfile.py b/fabfile.py index ac773963..62b26cfd 100644 --- a/fabfile.py +++ b/fabfile.py @@ -244,7 +244,6 @@ def collect_remote_statics(): 'storage': 'git://github.com/yohanboniface/Leaflet.Storage.git@master', 'edit_in_osm': 'git://github.com/yohanboniface/Leaflet.EditInOSM.git@master', 'minimap': 'git://github.com/Norkart/Leaflet-MiniMap.git@master', - 'darline': 'git://github.com/yohanboniface/Darline.git@master', 'i18n': 'git://github.com/yohanboniface/Leaflet.i18n.git@master', 'csv2geojson': 'git://github.com/mapbox/csv2geojson.git@gh-pages', 'togeojson': 'git://github.com/mapbox/togeojson.git@gh-pages', diff --git a/umap/static/darline b/umap/static/darline deleted file mode 160000 index 987916f7..00000000 --- a/umap/static/darline +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 987916f72bf3601e4c70402a4434d53b951284ac diff --git a/umap/static/favicon.ico b/umap/static/favicon.ico index 8db4c81a5947f2e263a67e94a0f804676382eec1..0aa459cc6435a5c785ca11a72977e0040fc55085 100644 GIT binary patch delta 615 zcmV-t0+{{17ybkm000310RRvX00031AOL6r000&M00599e*!N_L_t(IjeV0rNRx3G z#((dBo34WfgMvVbC-CV2@hVn7Gj4;9dsxn=ujUt z5sPV317VmDMnSHD7Nd7tnJ_TU95<{)1juGI~zF*HC+(0cSA5k6aN({9ce;02Q2pLy)Y77tlvBD~6;5QI* z@kWC{FMuc7QZa;`-PuAQd<>klQ2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R_ktLNYS;`>X_Sp3-V3;B!Bzpi004R=004l4008;_004mL004C`008P>0026e z000+nl3&F}0002mNklR+e zbbNUY!&3@?Aq1LADXg_Fd)EaW4N|lg`H-qoRo8$x0sufUNC;uwcdN2B%BC^8Gse{$ vw*V7>c@UocN7@67ARpmx01p|44e%HMY9iMiukzU_00000NkvXXu0mjf5 0) { + if(this.CURRENT !== null && this.CURRENT < this.RESULTS.length - 1) { // what if one resutl? + this.CURRENT++; + this.highlight(); + } + else if(this.CURRENT === null) { + this.CURRENT = 0; + this.highlight(); + } + } + break; + case L.S.Keys.UP: + if(this.CURRENT !== null) { + L.DomEvent.stop(e); + } + if(this.RESULTS.length > 0) { + if(this.CURRENT > 0) { + this.CURRENT--; + this.highlight(); + } + else if(this.CURRENT === 0) { + this.CURRENT = null; + this.highlight(); + } + } + break; + } + }, + + onKeyUp: function (e) { + var special = [ + L.S.Keys.TAB, + L.S.Keys.RETURN, + L.S.Keys.LEFT, + L.S.Keys.RIGHT, + L.S.Keys.DOWN, + L.S.Keys.UP, + L.S.Keys.APPLE, + L.S.Keys.SHIFT, + L.S.Keys.ALT, + L.S.Keys.CTRL + ]; + if (special.indexOf(e.keyCode) === -1) + { + this.search(); + } + }, + + onBlur: function (e) { + var self = this; + setTimeout(function () { + self.hide(); + }, 100); + }, + + clear: function () { + this.RESULTS = []; + this.CURRENT = null; + this.CACHE = ''; + this.container.innerHTML = ''; + }, + + hide: function() { + this.clear(); + this.container.style.display = 'none'; + this.input.value = ""; + }, + + setChoice: function (choice) { + choice = choice || this.RESULTS[this.CURRENT]; + if (choice) { + this.input.value = choice.display; + this.select(choice); + this.displaySelected(choice); + this.hide(); + if (this.options.callback) { + L.Util.bind(this.options.callback, this)(choice); + } + } + }, + + search: function() { + var val = this.input.value; + if (val.length < this.options.minChar) { + this.clear(); + return; + } + if(!val) { + this.clear(); + return; + } + if( val + '' === this.CACHE + '') { + return; + } + else { + this.CACHE = val; + } + var results = this._do_search(val); + return this.handleResults(results); + }, + + createResult: function (item) { + var el = L.DomUtil.element('li', {}, this.container); + el.innerHTML = item.display; + var result = { + value: item.value, + display: item.display, + el: el + }; + L.DomEvent.on(el, 'mouseover', function (e) { + this.CURRENT = result; + this.highlight(); + }, this); + L.DomEvent.on(el, 'mousedown', function (e) { + this.setChoice(); + }, this); + return result; + }, + + resultToIndex: function (result) { + var out = null; + this.forEach(this.RESULTS, function (item, index) { + if (item.value == result.value) { + out = index; + return; + } + }); + return out; + }, + + handleResults: function(data) { + var self = this; + this.clear(); + this.container.style.display = "block"; + this.resizeContainer(); + this.forEach(data, function (item, index) { + self.RESULTS.push(self.createResult(item)); + }); + this.CURRENT = 0; + this.highlight(); + //TODO manage no results + }, + + highlight: function () { + var self = this; + this.forEach(this.RESULTS, function (item, index) { + if (index === self.CURRENT) { + L.DomUtil.addClass(item.el, 'on'); + } + else { + L.DomUtil.removeClass(item.el, 'on'); + } + }); + }, + + getLeft: function (el) { + var tmp = el.offsetLeft; + el = el.offsetParent; + while(el) { + tmp += el.offsetLeft; + el = el.offsetParent; + } + return tmp; + }, + + getTop: function (el) { + var tmp = el.offsetTop; + el = el.offsetParent; + while(el) { + tmp += el.offsetTop; + el = el.offsetParent; + } + return tmp; + }, + + forEach: function (els, callback) { + Array.prototype.forEach.call(els, callback); + } + + }; + + var MULTISELECT = { + + init: function (el, options) { + this._init(el, options); + if (!this.el) return this; + this.el.style.display = "none"; + this.createInput(); + this.createContainer(); + this.initSelectedContainer(); + }, + + initSelectedContainer: function (initial) { + this.selected_container = L.DomUtil.after(this.input, L.DomUtil.element('ul', {className: 'umap-multiresult'})); + var self = this; + this.forEach(this.el, function (option) { + if (option.selected) { + self.displaySelected(self.optionToResult(option)); + } + }); + }, + + optionToResult: function (option) { + return { + value: option.value, + display: option.innerHTML + }; + }, + + displaySelected: function (result) { + var result_el = L.DomUtil.element('li', {}, this.selected_container); + result_el.innerHTML = result.display; + var close = L.DomUtil.element('span', {className: 'close'}, result_el); + close.innerHTML = "×"; + L.DomEvent.on(close, 'click', function () { + this.selected_container.removeChild(result_el); + this.unselect(result); + }, this); + this.hide(); + }, + + _do_search: function (val) { + var results = [], + self = this, + count = 0; + this.forEach(this.el, function (item, index) { + if (item.innerHTML.toLowerCase().indexOf(val.toLowerCase()) !== -1 && !item.selected && count < self.options.maxResults) { + results.push(self.optionToResult(item)); + count++; + } + }); + return results; + }, + + select: function (option) { + this.forEach(this.el, function (item, index) { + if (item.value == option.value) { + item.selected = true; + } + }); + }, + + unselect: function (option) { + this.forEach(this.el, function (item, index) { + if (item.value == option.value) { + item.selected = false; + } + }); + } + + }; + + this.multiselect = function () { + return L.Util.extend(API, MULTISELECT).init(el, options); + }; + return this; + +}; \ No newline at end of file diff --git a/umap/static/umap/umap.css b/umap/static/umap/umap.css index 8143235b..54b69e59 100644 --- a/umap/static/umap/umap.css +++ b/umap/static/umap/umap.css @@ -552,6 +552,41 @@ a { } +/* **************************** */ +/* Autocomplete */ +/* **************************** */ +ul.umap-autocomplete { + position: absolute; + background-color: white; + z-index: 1000; + box-shadow: 0 4px 9px #999999; +} +.umap-autocomplete li { + height: 56px; + line-height: 28px; + padding: 14px; +} +.umap-autocomplete li.on { + background-color: SeaGreen; + cursor: pointer; +} +.umap-multiresult li { + width: 100%; + background-color: #e5e5e5; + border-radius: 2px; + padding: 7px; + color: #464646; +} +.umap-multiresult li + li { + margin-top: 7px; +} +.umap-multiresult li .close { + float: right; + cursor: pointer; +} + + + /* **************************** */ /* Override Leaflet.Storage */ /* **************************** */ diff --git a/umap/templates/base.html b/umap/templates/base.html index 6ac58a31..af4e8614 100644 --- a/umap/templates/base.html +++ b/umap/templates/base.html @@ -6,21 +6,18 @@ {% compress css %} - {% endcompress css %} - {% compress js %} - - - - {% endcompress js %} {% block extra_head %} {% endblock extra_head %} + {% compress js %} + + {% endcompress js %} @@ -37,8 +34,8 @@ {% block bottom_js %}