Merge "Fix build errors in autorelease full clean build"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.topologymodeler / src / main / webapp / WEB-INF / tags / idInput.tag
1 <%--
2 /*******************************************************************************
3  * Copyright (c) 2014 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
9  *
10  * Contributors:
11  *    Oliver Kopp - initial API and implementation and/or initial documentation
12  *******************************************************************************/
13 --%>
14 <%@tag description="input field for an id unique in the target namespace. Current implementation: Unique in the topology modeler" pageEncoding="UTF-8"%>
15
16 <%@attribute name="inputFieldId" required="true" description="The name and id of the input field"%>
17
18 <div class="form-group" id="${inputFieldId}Group">
19         <label for="${inputFieldId}" class="control-label">Id:</label>
20         <input id="${inputFieldId}" class="form-control" name="${inputFieldId}" type="text" required="required" />
21 </div>
22
23 <script>
24 $("#${inputFieldId}").typing({
25         stop: function(evt, elem) {
26                 // check for existinance in the current model
27                 // TODO: global check using the backend
28                 var isSuccess;
29                 try {
30                         var val = elem.val();
31                         isSuccess = (val != "") && ($("#" + elem.val()).length == 0);
32                 } catch(err) {
33                         // all syntax errors are invalid inputs
34                         isSuccess = false;
35                 }
36                 var newClass = (isSuccess? "has-success" : "has-error");
37                 var div = elem.parent();
38                 if (!div.hasClass(newClass)) {
39                         div.removeClass("has-error").removeClass("has-success").addClass(newClass);
40                 }
41         }
42 });
43 </script>