-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
945 additions
and
867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
SRC_DIR := $(ROOT_DIR)/src | ||
BUILD_DIR := $(ROOT_DIR)/build | ||
JS_DEBUG := $(BUILD_DIR)/ol3-geocoder-debug.js | ||
JS_FINAL := $(BUILD_DIR)/ol3-geocoder.js | ||
CSS_COMBINED := $(BUILD_DIR)/ol3-geocoder.css | ||
CSS_FINAL := $(BUILD_DIR)/ol3-geocoder.min.css | ||
|
||
JS_FILES = $(SRC_DIR)/wrapper-head.js \ | ||
$(SRC_DIR)/base.js \ | ||
$(SRC_DIR)/nominatim.js \ | ||
$(SRC_DIR)/utils.js \ | ||
$(SRC_DIR)/wrapper-tail.js | ||
|
||
CSS_FILES = $(SRC_DIR)/ol3-geocoder.css | ||
|
||
CLEANCSS = /usr/local/bin/cleancss | ||
CLEANCSSFLAGS = --skip-restructuring | ||
POSTCSS = /usr/bin/postcss | ||
POSTCSSFLAGS = --use autoprefixer -b "last 2 versions" | ||
JSHINT = /usr/bin/jshint | ||
UGLIFYJS = /usr/bin/uglifyjs | ||
UGLIFYJSFLAGS = --mangle --mangle-regex --screw-ie8 -c warnings=false | ||
JS_BEAUTIFY = /usr/bin/js-beautify | ||
BEAUTIFYFLAGS = -f - --indent-size 2 --preserve-newlines | ||
NODEMON = /usr/bin/nodemon | ||
PARALLELSHELL = /usr/bin/parallelshell | ||
|
||
# just to create variables like NODEMON_JS_FLAGS when called | ||
define NodemonFlags | ||
UP_LANG = $(shell echo $(1) | tr '[:lower:]' '[:upper:]') | ||
NODEMON_$$(UP_LANG)_FLAGS := --on-change-only --watch "$(SRC_DIR)" --ext "$(1)" --exec "make build-$(1)" | ||
endef | ||
|
||
# targets | ||
build-watch: build watch | ||
|
||
watch: | ||
$(PARALLELSHELL) "make watch-js" "make watch-css" | ||
|
||
build: build-js build-css | ||
|
||
build-js: combine-js jshint uglifyjs | ||
@echo "Build JS ... OK" | ||
|
||
build-css: combine-css cleancss | ||
@echo "Build CSS ... OK" | ||
|
||
uglifyjs: | ||
@$(UGLIFYJS) $(JS_DEBUG) $(UGLIFYJSFLAGS) > $(JS_FINAL) | ||
|
||
jshint: | ||
@$(JSHINT) $(JS_DEBUG) | ||
|
||
cleancss: | ||
@$(POSTCSS) $(POSTCSSFLAGS) $(CSS_COMBINED) | $(CLEANCSS) $(CLEANCSSFLAGS) > $(CSS_FINAL) | ||
|
||
combine-js: | ||
@cat $(JS_FILES) | $(JS_BEAUTIFY) $(BEAUTIFYFLAGS) > $(JS_DEBUG) | ||
|
||
combine-css: | ||
@cat $(CSS_FILES) > $(CSS_COMBINED) | ||
|
||
watch-js: $(JS_FILES) | ||
$(eval $(call NodemonFlags,js)) | ||
@$(NODEMON) $(NODEMON_JS_FLAGS) | ||
|
||
watch-css: $(CSS_FILES) | ||
$(eval $(call NodemonFlags,css)) | ||
@$(NODEMON) $(NODEMON_CSS_FLAGS) | ||
|
||
.DEFAULT_GOAL := build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,16 @@ | ||
{ | ||
"name": "ol3-geocoder", | ||
"version": "1.2.0", | ||
"version": "1.4.0", | ||
"description": "A geocoder extension for OpenLayers 3.", | ||
"main": "ol3-geocoder.js", | ||
"author": "Jonatas Walker", | ||
"license": "MIT", | ||
"config": { | ||
"js_debug": "ol3-geocoder-debug.js", | ||
"js_minified": "ol3-geocoder.js", | ||
"css_combined": "ol3-geocoder.css", | ||
"css_minified": "ol3-geocoder.min.css" | ||
}, | ||
"devDependencies": { | ||
"jshint": "latest", | ||
"opener": "latest", | ||
"live-reload": "latest", | ||
"uglify-js": "latest", | ||
"clean-css": "latest", | ||
"postcss": "latest", | ||
"nodemon": "latest", | ||
"parallelshell": "latest" | ||
}, | ||
"scripts": { | ||
"prelint": "node combine.js", | ||
"lint": "jshint build/$npm_package_config_js_debug", | ||
|
||
"preuglify": "npm run lint", | ||
"uglify": "uglifyjs build/$npm_package_config_js_debug --mangle --mangle-regex --screw-ie8 -c warnings=false -o build/$npm_package_config_js_minified", | ||
|
||
"prebuild:css": "postcss --use autoprefixer -b 'last 2 versions' src/$npm_package_config_css_combined -o build/$npm_package_config_css_combined", | ||
|
||
"build:css": "cleancss --skip-restructuring -o build/$npm_package_config_css_minified build/$npm_package_config_css_combined", | ||
|
||
"watch:css": "nodemon --quiet --on-change-only --watch 'src' --ext 'css' --exec 'npm run build:css'", | ||
|
||
"build:js": "npm run uglify", | ||
"watch:js": "nodemon --quiet --on-change-only --watch 'src' --ext 'js' --exec 'npm run build:js'", | ||
|
||
"build": "npm run build:js && npm run build:css", | ||
|
||
"build:watch": "npm run build && parallelshell 'npm run watch:js' 'npm run watch:css'" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,39 @@ | ||
/** | ||
* @constructor | ||
* @extends {ol.control.Control} | ||
* @fires change:geocoder | ||
* @param {string|undefined} control_type Nominatim|Reverse. | ||
* @fires {Geocoder.EventType} | ||
* @param {string} control_type Nominatim|Reverse. | ||
* @param {object|undefined} opt_options Options. | ||
*/ | ||
var Geocoder = function(control_type, opt_options){ | ||
//some checks before continue | ||
utils.assert( | ||
typeof control_type === "string" || typeof control_type === "undefined", | ||
'@param `control_type` should be string|undefined type!' | ||
); | ||
utils.assert( | ||
typeof opt_options === "object" || typeof opt_options === "undefined", | ||
'@param `opt_options` should be object|undefined type!' | ||
); | ||
|
||
control_type = control_type || 'nominatim'; | ||
|
||
var nominatim = new Geocoder.Nominatim(this, opt_options); | ||
this.layer = nominatim.layer; | ||
|
||
ol.control.Control.call(this, { | ||
element: nominatim.els.container | ||
}); | ||
|
||
//set event to be captured with 'change:geocoder' | ||
this.set('geocoder', ''); | ||
utils.assert(typeof control_type === 'string', '@param `control_type`' + | ||
' should be string type!' | ||
); | ||
utils.assert(typeof opt_options === 'object' || typeof opt_options === 'undefined', | ||
'@param `opt_options` should be object|undefined type!' | ||
); | ||
|
||
control_type = control_type || 'nominatim'; | ||
|
||
var nominatim = new Geocoder.Nominatim(this, opt_options); | ||
this.layer = nominatim.layer; | ||
|
||
ol.control.Control.call(this, { | ||
element: nominatim.els.container | ||
}); | ||
}; | ||
ol.inherits(Geocoder, ol.control.Control); | ||
|
||
/** | ||
* @return {ol.source.Vector} Returns the source created by this control | ||
*/ | ||
Geocoder.prototype.getSource = function(){ | ||
return this.layer.getSource(); | ||
return this.layer.getSource(); | ||
}; | ||
|
||
|
||
/** | ||
* @return {ol.layer.Vector} Returns the layer created by this control | ||
*/ | ||
Geocoder.prototype.getLayer = function(){ | ||
return this.layer; | ||
return this.layer; | ||
}; | ||
|
Oops, something went wrong.