#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# $Header:$
#

# This properties files defines all of the JavaScript generated by the HTML
# tags.  This file does not need I18N support.  In fact, if this is internationalized
# the JavaScriptUtils class needs updating because it caches the Bundle internally
# so it is only looked up once.

functionComment=\
\n// **** Start the NetUI Framework Generated JavaScript ****\n\
\n

# generic method to submit a form, used by Anchor and ImageAnchor
# The following method will be written out once an may be called by
# multiple anchor and imageAnchors.  The event JavaScript is defined following it.
anchorFormSubmit=\
// submit the form from an Anchor or ImageAnchor\n\
// Search for the form by actionName,\n\
// Replace the action with the passed in action\n\
// Submit the form\n\
function anchor_submit_form(netuiName, newAction)\n\
{\n\
\  for (var i=0; i<document.forms.length; i++) {\n\
\     if (document.forms[i].id == netuiName) {\n\
\        document.forms[i].method = "POST";\n\
\        document.forms[i].action = newAction;\n\
\        document.forms[i].submit();\n\
\     }\n\
\   }\n\
}\n

# The action event that will call the form submit javascript
legacyAnchorFormSubmitAction=anchor_submit_form("{0}","{1}");return false;
anchorFormSubmitAction=anchor_submit_form(''{0}'',''{1}'');return false;

# The action event that will call the form submit javascript only if this link has not been clicked.
anchorDisableAndSubmitFormAction=if (this.netui_clicked) return false; anchor_submit_form(''{0}'',''{1}''); \
this.netui_clicked=true; return false;

# The action event that will disable the anchor after it has been clicked.
anchorDisableAction=if (this.netui_clicked) return false; this.netui_clicked=true;

# generic method to disable a button and submit a form, used by Button.
# The following method will be written out once an may be called by
# multiple buttons.  The event JavaScript is defined following it.
buttonDisableAndSubmitForm=\
// submit the form from a Button after disabling the Button\n\
// Search for the form by actionName,\n\
// Replace the action with the passed in action\n\
// Submit the form\n\
function button_disable_and_submit_form(button, netuiName, newAction)\n\
{\n\
\  button.disabled = true;\n\
\  for (var i=0; i<document.forms.length; i++) {\n\
\     if (document.forms[i].id == netuiName) {\n\
\        document.forms[i].method = "POST";\n\
\        document.forms[i].action = newAction;\n\
\        document.forms[i].submit();\n\
\     }\n\
\   }\n\
}\n

# The action event that will call the form submit javascript
buttonDisableAndSubmitFormAction=button_disable_and_submit_form(this,''{0}'',''{1}'');return false;

# generic method to disable a Button, used by Button.
# The following method will be written out once an may be called by
# multiple buttons.  The event JavaScript is defined following it.
buttonDisable=\
function button_disable(button)\n\
{\n\
\  button.disabled = true;\n\
}\n

# The action event that will call the form submit javascript
buttonDisableAction=button_disable(this);return false;

# array of the popup windows associated by name
popupSupportWindowVariable=\
window_netui_popup["{0}"] = null;\n

# generic method to open a popup window
popupSupportPopupWindow=\
if (!window_netui_popup) '{'\n\
\  var window_netui_popup = new Array();\n\
'}'\n\
\n\
// Parse the field names and values from a Form and return\n\
// them as a string of parameters to add to a url query\n\
function get_form_query(formNode)\n\
'{'\n\
\  var params = "";\n\
\n\
\  if (formNode != null)\n\
\  '{'\n\
\    var sep = "";\n\
\    for (var i = 0; i < formNode.elements.length; i++) '{'\n\
\      switch (formNode[i].type) '{'\n\
\        case "radio":\n\
\        case "checkbox":        // input type='checkbox'\n\
\          if (!formNode[i].checked)\n\
\            break;\n\
\          params += sep + formNode[i].name + "=" + formNode[i].value;\n\
\          sep="&";\n\
\          break;\n\
\        case "file":            // input type='file'\n\
\        case "hidden":          // input type='hidden'\n\
\        case "text":            // input type='text'\n\
\        case "textArea":        // textarea\n\
\        case "select-one":      // select\n\
\        case "select-multiple": // select multiple\n\
\          if (formNode[i].value == "")\n\
\            break;\n\
\          params += sep + formNode[i].name + "=" + formNode[i].value;\n\
\          sep="&";\n\
\          break;\n\
\        // ignore these...\n\
\        case "submit":          // input type='submit'\n\
\        case "reset":           // input type='reset'\n\
\        case "button":          // input type='button'\n\
\        case "password":        // input type='password'\n\
\          break;\n\
\      '}'\n\
\    '}'\n\
\  '}'\n\
\n\
\  return params;\n\
'}'\n\
\n\
function {0}(url, name, features, replace, popup, formName)\n\
'{'\n\
\  if (window_netui_popup[popup] != null && ! window_netui_popup[popup].closed)\n\
\  '{'\n\
\    window_netui_popup[popup].focus();\n\
\    return;\n\
\  '}'\n\
\n\
\  if (formName != null && formName.length > 0) '{'\n\
\    var formNode = null;\n\
\    for (var i = 0; i < document.forms.length; i++) '{'\n\
\      if (document.forms[i].name == formName) '{'\n\
\          formNode = document.forms[i];\n\
\          break;\n\
\      '}'\n\
\    '}'\n\
\n\
\    if (formNode != null) '{'\n\
\      var sep = "?";\n\
\      if (url != null && url.length != 0 && url.indexOf("?") > 0) '{'\n\
\          sep = "&";\n\
\      '}'\n\
\      url += sep + get_form_query(formNode);\n\
\    '}'\n\
\  '}'\n\
\n\
\  window_netui_popup[popup]=open(url, name, features, replace);\n\
\  if (window_netui_popup[popup].opener == null) window_netui_popup[popup].opener=self;\n\
'}'\n

# Open a popup window using a custom function
popupSupportOnClick={0}(''{1}'',''{2}'',''{3}'',{4},''{5}'',null);return false;

popupSupportUpdateFormOnClick={0}(''{1}'',''{2}'',''{3}'',{4},''{5}'',''{6}'');return false;

popupDone=\
function {0}(map)\n\
'{'\n\
\  for (var i in map)\n\
\  '{'\n\
\    var element = document.getElementById(i);\n\
\    if (element != null)\n\
\    '{'\n\
\      element.value=map[i];\n\
\    '}'\n\
\  '}'\n\
'}'\n

popupReturn_begin=\
var map = new Object();\n

popupReturn_item=\
map["{0}"] = "{1}";\n

popupReturn_end=\
top.opener.{0}(map);\n\
window.close();\n

# This script will run and set the focus onto the named element
# It is a page level statement that runs to set the initial focus on
# the page.
setFocus=\
// set the focus on a field within the named form\n\
if (document.forms["{0}"]["{1}"].type != "hidden")\n\
\    document.forms["{0}"]["{1}"].focus();\n

# This script will do a standard image replacement in a rollover
rollover=\
// Simple rollover function which replaces the image.src with the passed image\n\
function swapImage(control, image)\n\
{\n\
\  control.src = image;\n\
}\n

# JavaScript that will become the mapping between the id and real name
idMappingTable=\
// Build the netui_names table to map the tagId attributes\n\
// to the real id written into the HTML\n\
if (netui_names == null)\n\
\   var netui_names = new Object();\n\
{0}\n

# JavaScript that will become the mapping between the tagId and the real name
tagIdNameMappingTable=\
// Build the netui_names table to map the tagId attributes\n\
// to the real id written into the HTML\n\
if (netui_tagIdNameMap == null)\n\
\   var netui_tagIdNameMap = new Object();\n\
{0}\n


# this is the individual entry into the mapping table for each mapping
idMappingEntry=\
netui_names.{0}="{1}"\n

# This is a mapping between tagId and name
tagIdNameMappingEntry=\
netui_tagIdNameMap["{0}"]="{1}"\n

# simple method to return the real id for the a scoped tagId
getNetuiTagNameAdvanced=\
// method which will return a real id for a tagId,\n\
// the tag parameter will be used to find the idScope for\n\
// containers that may scope their ids\n\
function getNetuiTagName(id, tag)\n\
{\n\
\   var idScope = getScopeId(tag);\n\
\   if (idScope == \"\")\n\
\      return netui_names[id];\n\
\   else\n\
\      return netui_names[idScope  + "__" + id];\n\
}\n

#method map the TagId to the real ID
lookupIdByTagId=\
// lookup by tagId to "real id"\n\
function lookupIdByTagId(id, tag)\n\
{\n\
\   var idScope = lookupIdScope(tag,".");\n\
\   return (idScope == "") ? id : idScope + id;\n\
}\n

#method to do lookup in netui_tagIdNameMap
lookupNameByTagId=\
// lookup by tagId to "real name"\n\
function lookupNameByTagId(id, tag)\n\
{\n\
\   var idScope = lookupIdScope(tag,"_");\n\
\   if (idScope == \"\")\n\
\      return netui_tagIdNameMap[id];\n\
\   else\n\
\      return netui_tagIdNameMap[idScope  + "__" + id];\n\
}\n

# method to find the scope id
getScopeId=\
// This method will walk the hierarchy from the pass element looking for a idScope.\n\
// The first idScope found will be returned or the empty string if a idScope is not found.\n\
function getScopeId(tag)\n\
{\n\
\   if (tag == null || tag.getAttribute == null)\n\
\      return "";\n\
\   try {\n\
\      var attrVal = tag.getAttribute("netui:idScope");\n\
\   } catch (e) { /* ignore, in IE6 calling on a table results in an exception */ }\n\
\   if (attrVal != null)\n\
\      return attrVal;\n\
\   return getScopeId(tag.parentNode);\n\
}\n

lookupScopeId=\
//Non-Legacy lookup method creating a fully qualified scope id\n\
function lookupIdScope(tag,sep)\n\
{\n\
\   var val = "";\n\
\   if (sep == null) sep = "";\n\
\   while (tag != null && tag.getAttribute != null) {\n\
\      try {\n\
\         var attrVal = tag.getAttribute("netui:idScope");\n\
\      } catch (e) { /* ignore, in IE6 calling on a table results in an exception */ }\n\
\      if (attrVal != null)\n\
\         val = attrVal + sep + val;\n\
\      tag = tag.parentNode;\n\
\   }\n\
\   return val;\n\
}\n\

# JavaScript that will become the mapping between the id and real name (legacy mode)
singleIdMappingTable=\
// Build the netui_names table to map the tagId attributes\n\
// to the real id written into the HTML\n\
if (netui_names == null)\n\
\   var netui_names = new Object();\n\
netui_names.{0}="{1}"\n

#JavaScript that will become the mapping between the id and the real name
singleIdToNameMappingTable=\
\n// map tagId to "real name"\n\
if (netui_tagIdNameMap == null)\n\
\   var netui_tagIdNameMap = new Object();\n\
netui_tagIdNameMap["{0}"]="{1}"\n

#This method will invoke the NetUICommand infrastructure
netuiAction=\
return netUI.action(this, ''{0}'');

#initialization code for the tree
initTree=\
if (netUI.netUITree == null) '{\n\
\    netUI.netUITree = new NetUITree();\n\
\    netUI.netUITree.trees = new Object();\n\
'}\n\
netUI.netUITree.trees.{1} = new Object();\n\
netUI.netUITree.trees["{1}"].imgExpandName = "{0}" + "{2}";\n\
netUI.netUITree.trees["{1}"].imgCollapseName = "{0}" + "{3}";\n\
netUI.netUITree.trees["{1}"].imgExpandLastName = "{0}" + "{4}";\n\
netUI.netUITree.trees["{1}"].imgCollapseLastName = "{0}" + "{5}";\n\
netUI.netUITree.trees["{1}"].altExpand = "{6}";\n\
netUI.netUITree.trees["{1}"].altCollapse = "{7}";\n\
netUI.netUITree.init();\n

# The AJAX Prefix
initTreePrefix=\
netUI.netUITree.trees["{0}"].ajaxPrefix = "{1}";\n

# The AJAX Paramter
initTreeParam=\
netUI.netUITree.trees["{0}"].ajaxParam = "{1}";\n



#initialization code for the divPanel
initDivPanel=\
netUI.netUIDivPanel = new NetUIDivPanel();\n\
netUI.netUIDivPanel.init();\n

#initialize the webapp name
writeWebAppName=\
// write out the webapp name\n\
netUI.webAppName = "{0}";\n
