Commit d2800f79 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 477465: Move JS code out of flag/list.html.tmpl - Patch by Fré©ric Buclin…

Bug 477465: Move JS code out of flag/list.html.tmpl - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent c0ab2bba
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Bugzilla Bug Tracking System.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Myk Melez <myk@mozilla.org>
* Frédéric Buclin <LpSolit@gmail.com>
*
* ***** END LICENSE BLOCK ***** */
// Enables or disables a requestee field depending on whether or not
// the user is requesting the corresponding flag.
function toggleRequesteeField(flagField, no_focus)
{
// Convert the ID of the flag field into the ID of its corresponding
// requestee field and then use the ID to get the field.
var id = flagField.name.replace(/flag(_type)?-(\d+)/, "requestee$1-$2");
var requesteeField = document.getElementById(id);
if (!requesteeField) return;
// Enable or disable the requestee field based on the value
// of the flag field.
if (flagField.value == "?") {
requesteeField.disabled = false;
if (!no_focus) requesteeField.focus();
} else
requesteeField.disabled = true;
}
// Disables requestee fields when the window is loaded since they shouldn't
// be enabled until the user requests that flag type.
function disableRequesteeFields()
{
var inputElements = document.getElementsByTagName("input");
var selectElements = document.getElementsByTagName("select");
//You cannot update Node lists, so you must create an array to combine the NodeLists
var allElements = [];
for( var i=0; i < inputElements.length; i++ ) {
allElements[allElements.length] = inputElements.item(i);
}
for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects
allElements[allElements.length] = selectElements.item(i);
}
var inputElement, id, flagField;
for ( var i=0 ; i<allElements.length ; i++ )
{
inputElement = allElements[i];
if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
{
// Convert the ID of the requestee field into the ID of its corresponding
// flag field and then use the ID to get the field.
id = inputElement.name.replace(/requestee(_type)?-(\d+)/, "flag$1-$2");
flagField = document.getElementById(id);
if (flagField && flagField.value != "?")
inputElement.disabled = true;
}
}
}
YAHOO.util.Event.addListener(window, "load", disableRequesteeFields);
...@@ -18,60 +18,6 @@ ...@@ -18,60 +18,6 @@
# Contributor(s): Myk Melez <myk@mozilla.org> # Contributor(s): Myk Melez <myk@mozilla.org>
#%] #%]
<script type="text/javascript">
<!--
// Enables or disables a requestee field depending on whether or not
// the user is requesting the corresponding flag.
function toggleRequesteeField(flagField, no_focus)
{
// Convert the ID of the flag field into the ID of its corresponding
// requestee field and then use the ID to get the field.
var id = flagField.name.replace(/flag(_type)?-(\d+)/, "requestee$1-$2");
var requesteeField = document.getElementById(id);
if (!requesteeField) return;
// Enable or disable the requestee field based on the value
// of the flag field.
if (flagField.value == "?") {
requesteeField.disabled = false;
if (!no_focus) requesteeField.focus();
} else
requesteeField.disabled = true;
}
// Disables requestee fields when the window is loaded since they shouldn't
// be enabled until the user requests that flag type.
function disableRequesteeFields()
{
var inputElements = document.getElementsByTagName("input");
var selectElements = document.getElementsByTagName("select");
//You cannot update Node lists, so you must create an array to combine the NodeLists
var allElements = [];
for( var i=0; i < inputElements.length; i++ ) {
allElements[allElements.length] = inputElements.item(i);
}
for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects
allElements[allElements.length] = selectElements.item(i);
}
var inputElement, id, flagField;
for ( var i=0 ; i<allElements.length ; i++ )
{
inputElement = allElements[i];
if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
{
// Convert the ID of the requestee field into the ID of its corresponding
// flag field and then use the ID to get the field.
id = inputElement.name.replace(/requestee(_type)?-(\d+)/, "flag$1-$2");
flagField = document.getElementById(id);
if (flagField && flagField.value != "?")
inputElement.disabled = true;
}
}
}
YAHOO.util.Event.addListener(window, "load", disableRequesteeFields);
// -->
</script>
[% IF user.id %] [% IF user.id %]
[%# We list flags by looping twice over the flag types relevant for the bug. [%# We list flags by looping twice over the flag types relevant for the bug.
...@@ -84,6 +30,8 @@ ...@@ -84,6 +30,8 @@
[% DEFAULT flag_table_id = "flags" %] [% DEFAULT flag_table_id = "flags" %]
<script type="text/javascript" src="js/flag.js"></script>
<table id="[% flag_table_id FILTER html %]"> <table id="[% flag_table_id FILTER html %]">
[% UNLESS flag_no_header %] [% UNLESS flag_no_header %]
<tr> <tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment