2 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * This file is a part of Codendi.
6 * Codendi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Codendi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Hide references from the current item to other items
24 function hide_references_to() {
25 var references = $$(".reference_to");
28 // hide all <li> with class "reference_to"
30 if ( ! li.up().childElements().find(function(other_li) {
31 return other_li.visible();
34 // if no other <li> are visible, hide also <ul> and nature of the reference (previous)
36 li.up().previous().hide();
40 // display 'show link'
41 if (references.size() > 0) {
42 $('cross_references_legend').replace('<p id="cross_references_legend">'+
43 codendi.getText('cross_ref_fact_include','legend_referenced_by') +
44 ' <span><a href="#" onclick="show_references_to(); return false;">'+
45 codendi.getText('cross_ref_fact_include','show_references_to') +
51 * Show references from the current item to other items
53 function show_references_to() {
54 var references = $$(".reference_to");
57 // show all <li> with class "reference_to"
59 // shwo also <ul> and nature of the reference (previous)
61 li.up().previous().show();
64 // display 'hide link'
65 if (references.size() > 0) {
66 $('cross_references_legend').replace('<p id="cross_references_legend">'+
67 codendi.getText('cross_ref_fact_include','legend') +
68 ' <span><a href="#" onclick="hide_references_to(); return false;">'+
69 codendi.getText('cross_ref_fact_include','hide_references_to') +
75 *Show the delete icon for items
77 function show_delete_icon(){
82 function delete_ref( id, message ){
86 onComplete:function(){
87 /*if current id has 1 sibling (the img), we hide the 'cross_reference'
88 *else if current id has no sibling, we hide the reference nature
89 *else we just hide the reference
91 if($(id).siblings().length==1 && $(id).up().siblings().length > 0){
93 }else if($(id).up().siblings().length==0){
94 $(id).up('.nature').hide();
100 new Ajax.Updater('id', $(id).down('.delete_ref').href, opt);
105 document.observe('dom:loaded', function() {
107 //hide reference to item to clean the ui
108 if ($('cross_references_legend')) {
109 hide_references_to();
112 //hide the delete ref icon to clean the ui
113 $$('.link_to_ref').each(function (l) {
114 if (l.down('.delete_ref')) {
115 var a = l.down('.delete_ref');
116 var img = a.down('img');
117 img.src = img.src.replace('cross.png', 'cross-disabled.png');
118 img.observe('mouseover', function(evt) {
119 img.src = img.src.replace('cross-disabled.png', 'cross.png');
121 img.observe('mouseout', function() {
122 img.src = img.src.replace('cross.png', 'cross-disabled.png');