NIHVIVO-646 Move custom form utilities to a separate js file and add utility mixin methods to mix them in to specific custom forms. Make paths to css and js files in formPrefix.jsp and formSuffix.jsp absolute instead of relative.
This commit is contained in:
parent
ba418660e3
commit
7e1d4186ad
4 changed files with 72 additions and 10 deletions
|
@ -64,15 +64,15 @@
|
||||||
|
|
||||||
<% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false";
|
<% String useAutoComplete = (useAutoComplete=request.getParameter("useAutoComplete")) != null && !(useAutoComplete.equals("")) ? useAutoComplete : "false";
|
||||||
if (useAutoComplete.equalsIgnoreCase("true")) { %>
|
if (useAutoComplete.equalsIgnoreCase("true")) { %>
|
||||||
<link rel="stylesheet" type="text/css" href="../js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.css"/>
|
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.css"/>" />
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
<c:forEach var="cssFile" items="${customCss}">
|
<c:forEach var="cssFile" items="${customCss}">
|
||||||
<link rel="stylesheet" type="text/css" href="${cssFile}" media="screen"/>
|
<link rel="stylesheet" type="text/css" href="<c:url value="${cssFile}"/>" media="screen"/>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="../js/jquery_plugins/thickbox/thickbox.css"/>
|
<link rel="stylesheet" type="text/css" href="<c:url value="/js/jquery_plugins/thickbox/thickbox.css"/>" />
|
||||||
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/screen.css"/>" media="screen"/>
|
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/screen.css"/>" media="screen"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/formedit.css" />" media="screen"/>
|
<link rel="stylesheet" type="text/css" href="<c:url value="/${themeDir}css/formedit.css" />" media="screen"/>
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
|
|
||||||
</div><!-- end wrap -->
|
</div><!-- end wrap -->
|
||||||
|
|
||||||
<script language="javascript" type="text/javascript" src="../js/extensions/String.js"></script>
|
<script type="text/javascript" src="<c:url value="/js/extensions/String.js"/>"></script>></script>
|
||||||
<script language="javascript" type="text/javascript" src="../js/jquery.js"></script>
|
<script type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script>
|
||||||
<script language="javascript" type="text/javascript" src="../js/jquery_plugins/jquery.bgiframe.pack.js"></script>
|
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery.bgiframe.pack.js"/>"></script>
|
||||||
<script language="javascript" type="text/javascript" src="../js/jquery_plugins/thickbox/thickbox-compressed.js"></script>
|
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/thickbox/thickbox-compressed.js"/>"></script>
|
||||||
<!-- <script language="javascript" type="text/javascript" src="../js/jquery_plugins/ui.datepicker.js"></script> -->
|
<!-- <script type="text/javascript" src="<c:url value="/js/jquery_plugins/ui.datepicker.js"/>"></script> -->
|
||||||
<script language="javascript" type="text/javascript" src="../js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.pack.js"></script>
|
<script type="text/javascript" src="<c:url value="/js/jquery_plugins/jquery-autocomplete/jquery.autocomplete.pack.js"/>"></script>
|
||||||
|
|
||||||
<c:forEach var="jsFile" items="${customJs}">
|
<c:forEach var="jsFile" items="${customJs}">
|
||||||
<script type="text/javascript" src="${jsFile}"></script>
|
<script type="text/javascript" src="<c:url value="${jsFile}"/>"></script>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
27
webapp/web/js/customFormUtils.js
Normal file
27
webapp/web/js/customFormUtils.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
var vitro;
|
||||||
|
if (!vitro) {
|
||||||
|
vitro = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
vitro.customFormUtils = {
|
||||||
|
|
||||||
|
// This method should always be called instead of calling hide() directly on any
|
||||||
|
// element containing form fields.
|
||||||
|
hideFields: function(el) {
|
||||||
|
// Clear any input and error message, so if we re-show the element it won't still be there.
|
||||||
|
this.clearFields(el);
|
||||||
|
el.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
// Clear data from form elements in element el
|
||||||
|
clearFields: function(el) {
|
||||||
|
el.find(':input[type!="hidden"][type!="submit"][type!="button"]').val('');
|
||||||
|
|
||||||
|
// For now we can remove the error elements. Later we may include them in
|
||||||
|
// the markup, for customized positioning, in which case we will empty them
|
||||||
|
// but not remove them here. See findValidationErrors().
|
||||||
|
el.find('.validationError').remove();
|
||||||
|
}
|
||||||
|
}
|
35
webapp/web/js/utils.js
Normal file
35
webapp/web/js/utils.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
var vitro;
|
||||||
|
if (!vitro) {
|
||||||
|
vitro = {};
|
||||||
|
}
|
||||||
|
/* From "JavaScript: The Definitive Guide," 5th edition, by David Flanagan
|
||||||
|
* Copyright 2006 O'Reilly Media, Inc.
|
||||||
|
* ISBN 978-0-596-10199-2
|
||||||
|
*/
|
||||||
|
|
||||||
|
vitro.utils = {
|
||||||
|
|
||||||
|
// Borrow methods from one class for use by another.
|
||||||
|
// The arguments should be the constructor functions for the classes.
|
||||||
|
// Methods of built-in types such as Object, Array, Date, and RegExp are
|
||||||
|
// not enumerable and cannot be borrowed from with this method.
|
||||||
|
borrowPrototypeMethods: function(borrowFrom, addTo) {
|
||||||
|
var from = borrowFrom.prototype; // prototype object to borrow from
|
||||||
|
var to = addTo.prototype; // prototype object to extend
|
||||||
|
|
||||||
|
for (m in from) { // loop through all properties of the prototype
|
||||||
|
if (typeof from[m] != "function") { continue; } // ignore non-functions
|
||||||
|
to[m] = from[m];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
borrowMethods: function(borrowFrom, addTo) {
|
||||||
|
for (m in borrowFrom) { // loop through all properties of the prototype
|
||||||
|
if (typeof borrowFrom[m] != "function") { continue; } // ignore non-functions
|
||||||
|
addTo[m] = borrowFrom[m];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue