Skip to content

Commit 3708eac

Browse files
committed
/series/add: use selectize.js for choosing country.
1 parent 08f2757 commit 3708eac

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
-->
4242
<bootstrap.version>3.3.5</bootstrap.version>
4343
<jquery.version>1.9.1</jquery.version>
44+
<selectizejs.version>0.12.1</selectizejs.version>
4445

4546
<testng.version>6.8.8</testng.version>
4647
<cglib.version>2.2.2</cglib.version>
@@ -319,6 +320,13 @@
319320
<scope>runtime</scope>
320321
</dependency>
321322

323+
<dependency>
324+
<groupId>org.webjars</groupId>
325+
<artifactId>selectize.js</artifactId>
326+
<version>${selectizejs.version}</version>
327+
<scope>runtime</scope>
328+
</dependency>
329+
322330
<dependency>
323331
<groupId>org.projectlombok</groupId>
324332
<artifactId>lombok</artifactId>

src/main/java/ru/mystamps/web/Url.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ public final class Url {
8383
public static final String BOOTSTRAP_JS = "/public/bootstrap/js/bootstrap.min.js";
8484
public static final String JQUERY_JS = "/public/jquery/jquery.min.js";
8585

86-
// see also pom.xml and ru.mystamps.web.config.MvcConfig#addResourceHandlers()
8786
// CheckStyle: ignore LineLength for next 3 lines
87+
// TODO: use minimal version of CSS file when it will be available (https://github.com/webjars/selectize.js/issues/3)
88+
public static final String SELECTIZE_CSS = "/public/selectize/css/selectize.bootstrap3.css";
89+
public static final String SELECTIZE_JS = "/public/selectize/js/standalone/selectize.min.js";
90+
91+
// see also pom.xml and ru.mystamps.web.config.MvcConfig#addResourceHandlers()
92+
// CheckStyle: ignore LineLength for next 5 lines
8893
public static final String BOOTSTRAP_CSS_CDN = "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css";
8994
public static final String BOOTSTRAP_JS_CDN = "http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js";
9095
public static final String JQUERY_JS_CDN = "http://yandex.st/jquery/1.9.1/jquery.min.js";
96+
public static final String SELECTIZE_CSS_CDN = "http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/css/selectize.bootstrap3.min.css";
97+
public static final String SELECTIZE_JS_CDN = "http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/js/standalone/selectize.min.js";
9198

9299
// see also ru.mystamps.web.support.togglz.TogglzConfig#getTogglzConsole()
93100
public static final String TOGGLZ_CONSOLE_PAGE = "/togglz";
@@ -119,6 +126,8 @@ public static Map<String, String> asMap(boolean serveContentFromSingleHost) {
119126
map.put("BOOTSTRAP_CSS", BOOTSTRAP_CSS);
120127
map.put("BOOTSTRAP_JS", BOOTSTRAP_JS);
121128
map.put("JQUERY_JS", JQUERY_JS);
129+
map.put("SELECTIZE_CSS", SELECTIZE_CSS);
130+
map.put("SELECTIZE_JS", SELECTIZE_JS);
122131
map.put("GET_IMAGE_PAGE", GET_IMAGE_PAGE);
123132
map.put("FAVICON_ICO", FAVICON_ICO);
124133
map.put("MAIN_CSS", MAIN_CSS);
@@ -134,6 +143,8 @@ public static Map<String, String> asMap(boolean serveContentFromSingleHost) {
134143
map.put("BOOTSTRAP_CSS", BOOTSTRAP_CSS_CDN);
135144
map.put("BOOTSTRAP_JS", BOOTSTRAP_JS_CDN);
136145
map.put("JQUERY_JS", JQUERY_JS_CDN);
146+
map.put("SELECTIZE_CSS", SELECTIZE_CSS_CDN);
147+
map.put("SELECTIZE_JS", SELECTIZE_JS_CDN);
137148
}
138149

139150
return map;

src/main/java/ru/mystamps/web/config/MvcConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
6969
.addResourceLocations("classpath:/META-INF/resources/webjars/bootstrap/3.3.5/");
7070
registry.addResourceHandler("/public/jquery/**")
7171
.addResourceLocations("classpath:/META-INF/resources/webjars/jquery/1.9.1/");
72+
registry.addResourceHandler("/public/selectize/**")
73+
.addResourceLocations("classpath:/META-INF/resources/webjars/selectize.js/0.12.1/");
7274
}
7375

7476
@Override

src/main/webapp/WEB-INF/views/series/add.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" th:href="${FAVICON_ICO}" />
1212
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" th:href="${BOOTSTRAP_CSS}" />
1313
<link rel="stylesheet" href="../../static/styles/main.css" th:href="${MAIN_CSS}" />
14+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/css/selectize.bootstrap3.min.css" th:href="${SELECTIZE_CSS}" />
1415
</head>
1516
<body lang="en" th:lang="${#locale.language == 'ru' ? 'ru' : 'en'}">
1617
<div class="container-fluid">
@@ -408,11 +409,14 @@ <h3 th:text="#{t_add_series_ucfirst}">
408409
<!-- Placed at the end of the document so the pages load faster -->
409410
<script src="http://yandex.st/jquery/1.9.1/jquery.min.js" th:src="${JQUERY_JS}"></script>
410411
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" th:src="${BOOTSTRAP_JS}"></script>
412+
<script src="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/js/standalone/selectize.min.js" th:src="${SELECTIZE_JS}"></script>
411413

412414
<script src="../../../../javascript/CatalogUtils.js" th:src="${CATALOG_UTILS_JS}"></script>
413415

414416
<script>
415417
$(function() {
418+
$('#country').selectize();
419+
416420
$('.js-catalog-numbers').on('blur', function() {
417421
$(this).val(function(idx, val) {
418422
return CatalogUtils.expandNumbers(val);

0 commit comments

Comments
 (0)