| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 /* 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * -------------------------------------------------------- 21 * $Id$ 22 * -------------------------------------------------------- 23 */ 24 25 /* 26 * Collapsible element functions 27 */ 28 var g_collapse_clear = 1; 29 30 // global code to determine how to set visibility 31 var a = navigator.userAgent.indexOf("MSIE"); 32 var style_display; 33 34 if (a!= -1) { 35 style_display = 'block'; 36 } else { 37 style_display = 'table-row'; 38 } 39 style_display = 'block'; 40 41 $(document).ready( function() { 42 /* Global Tag change event added only if #tag_select exists */ 43 $('#tag_select').live('change', function() { 44 var selected_tag = $('#tag_select option:selected').text(); 45 tag_string_append( selected_tag ); 46 }); 47 48 $('.collapse-open').show(); 49 $('.collapse-closed').hide(); 50 $('.collapse-link').click( function(event) { 51 event.preventDefault(); 52 var id = $(this).attr('id'); 53 var t_pos = id.indexOf('_closed_link' ); 54 if( t_pos == -1 ) { 55 t_pos = id.indexOf('_open_link' ); 56 } 57 var t_div = id.substring(0, t_pos ); 58 ToggleDiv( t_div ); 59 }); 60 61 $('input[type=text].autocomplete').autocomplete({ 62 source: function(request, callback) { 63 var fieldName = $(this).attr('element').attr('id'); 64 var postData = {}; 65 postData['entrypoint']= fieldName + '_get_with_prefix'; 66 postData[fieldName] = request.term; 67 $.getJSON('xmlhttprequest.php', postData, function(data) { 68 var results = []; 69 $.each(data, function(i, value) { 70 var item = {}; 71 item.label = $('<div/>').text(value).html(); 72 item.value = value; 73 results.push(item); 74 }); 75 callback(results); 76 }); 77 } 78 }); 79 80 $('input.autofocus:first, select.autofocus:first, textarea.autofocus:first').focus(); 81 82 $('input[type=checkbox].check_all').click(function() { 83 var matchingName = $(this).attr('name').replace(/_all$/, ''); 84 $(this).closest('form').find('input[type=checkbox][name=' + matchingName + '\[\]]').attr('checked', this.checked); 85 }); 86 87 var stopwatch = { 88 timerID: null, 89 elapsedTime: 0, 90 tick: function() { 91 this.elapsedTime += 1000; 92 var seconds = Math.floor(this.elapsedTime / 1000) % 60; 93 var minutes = Math.floor(this.elapsedTime / 60000) % 60; 94 var hours = Math.floor(this.elapsedTime / 3600000) % 60; 95 if (seconds < 10) { 96 seconds = '0' + seconds; 97 } 98 if (minutes < 10) { 99 minutes = '0' + minutes; 100 } 101 if (hours < 10) { 102 hours = '0' + hours; 103 } 104 $('input[type=text].stopwatch_time').attr('value', hours + ':' + minutes + ':' + seconds); 105 this.start(); 106 }, 107 reset: function() { 108 this.stop(); 109 this.elapsedTime = 0; 110 $('input[type=text].stopwatch_time').attr('value', '00:00:00'); 111 }, 112 start: function() { 113 this.stop(); 114 var self = this; 115 this.timerID = window.setTimeout(function() { 116 self.tick(); 117 }, 1000); 118 }, 119 stop: function() { 120 if (typeof this.timerID == 'number') { 121 window.clearTimeout(this.timerID); 122 delete this.timerID; 123 } 124 } 125 } 126 $('input[type=button].stopwatch_toggle').click(function() { 127 if (stopwatch.elapsedTime == 0) { 128 stopwatch.stop(); 129 stopwatch.start(); 130 $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']); 131 } else if (typeof stopwatch.timerID == 'number') { 132 stopwatch.stop(); 133 $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']); 134 } else { 135 stopwatch.start(); 136 $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_stop']); 137 } 138 }); 139 $('input[type=button].stopwatch_reset').click(function() { 140 stopwatch.reset(); 141 $('input[type=button].stopwatch_toggle').attr('value', translations['time_tracking_stopwatch_start']); 142 }); 143 144 $('input[type=text].datetime').each(function(index, element) { 145 $(this).after('<input type="image" class="button datetime" id="' + element.id + '_datetime_button' + '" src="' + config['icon_path'] + 'calendar-img.gif" />'); 146 Calendar.setup({ 147 inputField: element.id, 148 timeFormat: 24, 149 showsTime: true, 150 ifFormat: config['calendar_js_date_format'], 151 button: element.id + '_datetime_button' 152 }); 153 }); 154 155 156 $('.bug-jump').find('[name=bug_id]').focus( function() { 157 var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); 158 if( $(this).val() == bug_label ) { 159 $(this).val(''); 160 $(this).removeClass('field-default'); 161 } 162 }); 163 $('.bug-jump').find('[name=bug_id]').blur( function() { 164 var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); 165 if( $(this).val() == '' ) { 166 $(this).val(bug_label); 167 $(this).addClass('field-default'); 168 } 169 }); 170 $('[name=source_query_id]').change( function() { 171 $(this).parent().submit(); 172 }); 173 $('[name=form_set_project]').children('[name=project_id]').change( function() { 174 $(this).parent().submit(); 175 }); 176 $('[name=form_set_project]').children('.button').hide(); 177 setBugLabel(); 178 }); 179 180 function setBugLabel() { 181 var bug_label = $('.bug-jump-form').find('[name=bug_label]').val(); 182 var field = $('.bug-jump').find('[name=bug_id]'); 183 if( field.val() == '' ) { 184 field.val(bug_label); 185 field.addClass('field-default'); 186 } 187 } 188 189 /* 190 * String manipulation 191 */ 192 function Trim( p_string ) { 193 if (typeof p_string != "string") { 194 return p_string; 195 } 196 197 var t_string = p_string; 198 var t_ch = ''; 199 200 // Trim beginning spaces 201 202 t_ch = t_string.substring( 0, 1 ); 203 while ( t_ch == " " ) { 204 t_string = t_string.substring( 1, t_string.length ); 205 t_ch = t_string.substring( 0, 1 ); 206 } 207 208 // Trim trailing spaces 209 210 t_ch = t_string.substring( t_string.length-1, t_string.length ); 211 while ( t_ch == " " ) { 212 t_string = t_string.substring( 0, t_string.length-1 ); 213 t_ch = t_string.substring( t_string.length-1, t_string.length ); 214 } 215 216 return t_string; 217 } 218 219 /* 220 * Cookie functions 221 */ 222 function GetCookie( p_cookie ) { 223 var t_cookie_name = "MANTIS_" + p_cookie; 224 var t_cookies = document.cookie; 225 226 t_cookies = t_cookies.split( ";" ); 227 228 var i = 0; 229 while( i < t_cookies.length ) { 230 var t_cookie = t_cookies[ i ]; 231 232 t_cookie = t_cookie.split( "=" ); 233 234 if ( Trim( t_cookie[ 0 ] ) == t_cookie_name ) { 235 return( t_cookie[ 1 ] ); 236 } 237 i++; 238 } 239 240 return -1; 241 } 242 243 function SetCookie( p_cookie, p_value ) { 244 var t_cookie_name = "MANTIS_" + p_cookie; 245 var t_expires = new Date(); 246 247 t_expires.setTime( t_expires.getTime() + (365 * 24 * 60 * 60 * 1000)); 248 249 document.cookie = t_cookie_name + "=" + p_value + "; expires=" + t_expires.toUTCString() + ";"; 250 } 251 252 function ToggleDiv( p_div ) { 253 t_open_div = '#' + p_div + "_open"; 254 t_closed_div = '#' + p_div + "_closed"; 255 256 t_cookie = GetCookie( "collapse_settings" ); 257 if ( 1 == g_collapse_clear ) { 258 t_cookie = ""; 259 g_collapse_clear = 0; 260 } 261 var t_open_display = $(t_open_div).css('display'); 262 $(t_open_div).toggle(); 263 264 if( $(t_closed_div).length ) { 265 $(t_closed_div).toggle(); 266 } 267 268 if ( t_open_display == "none" ) { 269 t_cookie = t_cookie + "|" + p_div + ",1"; 270 } else { 271 t_cookie = t_cookie + "|" + p_div + ",0"; 272 } 273 274 SetCookie( "collapse_settings", t_cookie ); 275 } 276 277 function setDisplay(idTag, state) 278 { 279 if(!document.getElementById(idTag)) alert('SetDisplay(): id '+idTag+' is empty'); 280 // change display visibility 281 if ( state != 0 ) { 282 document.getElementById(idTag).style.display = style_display; 283 } else { 284 document.getElementById(idTag).style.display = 'none'; 285 } 286 } 287 288 function toggleDisplay(idTag) 289 { 290 setDisplay( idTag, (document.getElementById(idTag).style.display == 'none')?1:0 ); 291 } 292 293 /* Append a tag name to the tag input box, with repect for tag separators, etc */ 294 function tag_string_append( p_string ) { 295 t_tag_separator = $('#tag_separator').val(); 296 t_tag_string = $('#tag_string'); 297 t_tag_select = $('#tag_select'); 298 299 if ( Trim( p_string ) == '' ) { return; } 300 301 if ( t_tag_string.val() != '' ) { 302 t_tag_string.val( t_tag_string.val() + t_tag_separator + p_string ); 303 } else { 304 t_tag_string.val( t_tag_string.val() + p_string ); 305 } 306 t_tag_select.val(0); 307 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 20 05:32:17 2010 | Cross-referenced by PHPXref 0.7 |