| [ 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 // | Orginial Code Care Of: | 27 // +----------------------------------------------------------------------+ 28 // | Copyright (c) 2004 Bitflux GmbH | 29 // +----------------------------------------------------------------------+ 30 // | Licensed under the Apache License, Version 2.0 (the "License"); | 31 // | you may not use this file except in compliance with the License. | 32 // | You may obtain a copy of the License at | 33 // | http://www.apache.org/licenses/LICENSE-2.0 | 34 // | Unless required by applicable law or agreed to in writing, software | 35 // | distributed under the License is distributed on an "AS IS" BASIS, | 36 // | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | 37 // | implied. See the License for the specific language governing | 38 // | permissions and limitations under the License. | 39 // +----------------------------------------------------------------------+ 40 // | Author: Bitflux GmbH <devel@bitflux.ch> | 41 // | http://blog.bitflux.ch/p1735.html | 42 // +----------------------------------------------------------------------+ 43 // 44 // 45 // +----------------------------------------------------------------------+ 46 // | Heavily Modified by Jeff Minard (07/09/04) | 47 // +----------------------------------------------------------------------+ 48 // | Same stuff as above, yo! | 49 // +----------------------------------------------------------------------+ 50 // | Author: Jeff Minard <jeff-js@creatimation.net> | 51 // | http://www.creatimation.net | 52 // | http://www.creatimation.net/journal/live-request | 53 // +----------------------------------------------------------------------+ 54 // 55 // +----------------------------------------------------------------------+ 56 // | What is this nonsense?? (07/09/04) | 57 // +----------------------------------------------------------------------+ 58 // | This is a script that, by using XMLHttpRequest javascript objects | 59 // | you can quickly add some very click live interactive feed back to | 60 // | your pages that reuire server side interaction. | 61 // | | 62 // | For instance, you use this to emulate a "live searching" feature | 63 // | wherein users type in key phrases, and once they have stopped typing | 64 // | the script will automatically search and retrive *without* a page | 65 // | reload. 66 // | | 67 // | In another instance, I use this to product live comments by passing | 68 // | the text to a Textile class that parses it to valid HTML. After | 69 // | parsing, the html is returned and displayed on the page as the | 70 // | user types. | 71 // +----------------------------------------------------------------------+ 72 // 73 // 74 // +----------------------------------------------------------------------+ 75 // | Modified by Lee O'Mara <lomara@omara.ca> 12/08/2004 | 76 // +----------------------------------------------------------------------+ 77 // | Hacked apart Jeff's script for use in Mantis. | 78 // | | 79 // | This script gets filters from the server and displays them without | 80 // | reloading the page. | 81 // | | 82 // | The script tries to follow the notion of "unobtrusive javascript". | 83 // | There are no event handlers in the HTML code. The events are added | 84 // | on pageload(based on specific id names). | 85 // +----------------------------------------------------------------------+ 86 */ 87 88 var processURI = './return_dynamic_filters.php'; 89 var liveReq = false; 90 91 /** 92 * Build the XMLHttpRequest and send it 93 */ 94 function liveReqDoReq() { 95 96 if (liveReq && liveReq.readyState < 4) { 97 liveReq.abort(); 98 } 99 100 if (window.XMLHttpRequest) { 101 // branch for IE7, Firefox, Opera, etc. 102 liveReq = new XMLHttpRequest(); 103 } else if (window.ActiveXObject) { 104 // branch for IE5, IE6 via ActiveX 105 liveReq = new ActiveXObject("Microsoft.XMLHTTP"); 106 } 107 108 name = this.id; 109 liveReq.onreadystatechange = function(){liveReqProcessReqChange(name);}; 110 t_view = document.getElementById('filters_form_open').elements['view_type'].value; 111 liveReq.open("GET", processURI + "?view_type=" + t_view + "&filter_target=" + this.id); 112 113 // show "Loading..." while waiting 114 document.getElementById(this.id+'_target').innerHTML = translations['loading']; 115 116 liveReq.send(null); 117 118 return false; 119 } 120 121 /** 122 * Processes the results of the XMLHttpRequest 123 */ 124 function liveReqProcessReqChange(name) { 125 if (liveReq.readyState == 4) { 126 document.getElementById(name+'_target').innerHTML = liveReq.responseText; 127 replaceWithContent(name); 128 } 129 } 130 131 /** 132 * Strip the tag, leave the content. 133 */ 134 function replaceWithContent(id){ 135 tag = document.getElementById(id); 136 if (!tag) return false; 137 t_parent = tag.parentNode; 138 if (!t_parent) return false; 139 for(var i=0; i <tag.childNodes.length; i++){ 140 child = tag.childNodes[i].cloneNode(true); 141 t_parent.insertBefore(child, tag); 142 } 143 t_parent.removeChild(tag); 144 } 145 146 /** 147 * Initialise the filter links 148 */ 149 function labelInit(){ 150 // keep browsers that don't support DOM or 151 // XMLHttpRequest from getting in trouble 152 if (document.getElementById && (window.XMLHttpRequest || window.ActiveXObject)) { 153 154 t_form = document.getElementById("filters_form_open"); 155 if (!t_form) return false; 156 157 t_links = t_form.getElementsByTagName("a"); 158 if (!t_links) return false; 159 160 for(var i=0; i < t_links.length; i++){ 161 var t_link = t_links[i]; 162 if (t_link.id.substring((t_link.id.length - 7), t_link.id.length) == "_filter"){ 163 // only attach event handler if a target is found 164 if (document.getElementById(t_link.id+'_target')){ 165 // setup the event handler 166 t_link.onclick = liveReqDoReq; 167 } else { 168 alert("missing target for:" +t_link.id); 169 } 170 } 171 } 172 } 173 } 174 175 addLoadEvent(labelInit);
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 |