Skip to content

Commit

Permalink
fixed javascript related with categories #112
Browse files Browse the repository at this point in the history
  • Loading branch information
garciademarina committed Jan 12, 2012
1 parent 92ef325 commit 1c961af
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
26 changes: 12 additions & 14 deletions oc-admin/themes/modern/fields/iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<tr style="vertical-align: top;">
<td style="font-weight: bold;" colspan="<?php echo $numCols; ?>">
<label for="categories"><?php _e("Preset categories");?></label><br />
<a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('field_form', true); return false;"><?php _e("Check all");?></a> - <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('field_form', false); return false;"><?php _e("Uncheck all");?></a>
<a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('cat_tree', true); return false;"><?php _e("Check all");?></a> - <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('cat_tree', false); return false;"><?php _e("Uncheck all");?></a>
</td>
<td>
<ul id="cat_tree">
Expand Down Expand Up @@ -127,23 +127,21 @@
}
});

function checkAll (frm, check) {
var aa = document.getElementById(frm);
for (var i = 0 ; i < aa.elements.length ; i++) {
aa.elements[i].checked = check;
}
function checkAll (id, check) {
aa = $('#'+id+' input[type=checkbox]').each(
function(){
$(this).attr('checked', check);
}
);
}

function checkCat(id, check) {
var lay = document.getElementById("cat" + id);
if(lay) {
inp = lay.getElementsByTagName("input");
for (var i = 0, maxI = inp.length ; i < maxI; ++i) {
if(inp[i].type == "checkbox") {
inp[i].checked = check;
aa = $('#cat'+id+' input[type=checkbox]').each(
function(){
$(this).attr('checked', check);
}
}}
}
);
}

$(document).ready(function() {
$('#settings_form form').submit(function() {
Expand Down
34 changes: 16 additions & 18 deletions oc-admin/themes/modern/fields/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

$fields = __get("fields");
$last = end($fields); $last_id = $last['pk_i_id'];
$fields = __get("fields");
$last = end($fields); $last_id = $last['pk_i_id'];
$categories = __get("categories");
$selected = __get("default_selected");
$numCols = 1;
$selected = __get("default_selected");
$numCols = 1;

?>

Expand Down Expand Up @@ -130,23 +130,21 @@ function delete_field(id){

});

function checkAll (frm, check) {
var aa = document.getElementById(frm);
for (var i = 0 ; i < aa.elements.length ; i++) {
aa.elements[i].checked = check;
}
function checkAll (id, check) {
aa = $('#'+id+' input[type=checkbox]').each(
function(){
$(this).attr('checked', check);
}
);
}

function checkCat(id, check) {
var lay = document.getElementById("cat" + id);
if(lay) {
inp = lay.getElementsByTagName("input");
for (var i = 0, maxI = inp.length ; i < maxI; ++i) {
if(inp[i].type == "checkbox") {
inp[i].checked = check;
aa = $('#cat'+id+' input[type=checkbox]').each(
function(){
$(this).attr('checked', check);
}
}}
}
);
}
</script>
<div id="content">
<div id="separator"></div>
Expand Down Expand Up @@ -206,7 +204,7 @@ function checkCat(id, check) {
<tr style="vertical-align: top;">
<td style="font-weight: bold;" colspan="<?php echo $numCols; ?>">
<label for="categories"><?php _e("Preset categories");?></label><br />
<a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('new_field_form', true); return false;"><?php _e("Check all");?></a> - <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('new_field_form', false); return false;"><?php _e("Uncheck all");?></a>
<a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('cat_tree', true); return false;"><?php _e("Check all");?></a> - <a style="font-size: x-small; color: gray;" href="#" onclick="checkAll('cat_tree', false); return false;"><?php _e("Uncheck all");?></a>
</td>
<td>
<ul id="new_cat_tree">
Expand Down

0 comments on commit 1c961af

Please sign in to comment.