2 /*******************************************************************************
3 * Copyright (c) 2013 University of Stuttgart.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and the Apache License 2.0 which both accompany this distribution,
7 * and are available at http://www.eclipse.org/legal/epl-v10.html
8 * and http://www.apache.org/licenses/LICENSE-2.0
11 * Yves Schubert - initial API and implementation and/or initial documentation
12 * Oliver Kopp - minor improvements
13 *******************************************************************************/
15 <%@tag description="A spinner with the possibility to set to inphty via button" pageEncoding="UTF-8"%>
16 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
18 <%-- Code copied between repository and topology-modeler --%>
21 Could also be realized as
22 * HTML5 Web Component (http://www.ibm.com/developerworks/library/wa-html5components1/) or
23 * x-tags (http://www.x-tags.org/)
24 We decided to use JSP tags to avoid an additional JavaScript library
27 <%@attribute name="label" required="true"%>
28 <%@attribute name="id" required="true"%>
29 <%@attribute name="min"%>
30 <%@attribute name="max" required="false" description="Maximum value. Default is 1000. The underlying library does not allow arbitrary high values."%>
31 <%@attribute name="name" required="false" description="The name of the input field. Defaults to the id"%>
32 <%@attribute name="withinphty" required="false" description="If set, then an inphty button is provded"%>
33 <%@attribute name="value"%>
34 <%@attribute name="width" required="false" description="The Column with according to bootstrap rules. Default is 3 (should not be smaller)."%>
35 <%@attribute name="changedfunction" required="false" description="Called if value changed"%>
37 <%-- Set default name value if required --%>
38 <c:if test="${empty name}">
39 <c:set var="name" value="${id}"></c:set>
42 <c:if test="${empty width}">
43 <c:set var="width" value="3"></c:set>
46 <div class="form-group">
47 <label for="${id}">${label}</label>
49 <div class="col-lg-${width}">
50 <div class="input-group">
51 <input id="${id}" class="spinner form-control" name="${name}" type="text" <c:if test="${not empty changedfunction}">onblur="${changedfunction}();"</c:if>/>
52 <c:if test="${not empty withinphty}">
53 <span class="input-group-addon" style="cursor: pointer; border-left:0" onclick="setToInfin('${id}'<c:if test="${not empty changedfunction}">, ${changedfunction}</c:if>);">∞</span>
62 included multiple times.
63 Drawback when not using HTML5 components and keeping the JavaScript functions closed to the HTML code
65 function setToInfin(id, changedFunction) {
66 var spinner = $("#" + id);
67 spinner.val('∞'); // &inphty; - jQuery does not decode that, but places the plain text. Therefore, we directly pass the char we want
68 if (changedFunction !== undefined) {
75 <c:if test="${not empty min}">
76 param.minimum = "${min}";
78 <c:if test="${empty max}">
82 // use bootstrap-spinedit plugin
83 $("#${id}").spinedit(param);
85 <c:if test="${not empty changedfunction}">
86 $("#${id}").on('valueChanged', ${changedfunction});