[Linpha-cvs] SF.net SVN: linpha: [4572] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-10-07 13:33:33
|
Revision: 4572 http://svn.sourceforge.net/linpha/?rev=4572&view=rev Author: fangehrn Date: 2006-10-07 06:32:45 -0700 (Sat, 07 Oct 2006) Log Message: ----------- adding javascript libraries prototype and scriptaculous working on ajax image view Modified Paths: -------------- trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/css/view_img.css trunk/linpha2/templates/default/view_img.head.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_img_static.html.php Added Paths: ----------- trunk/linpha2/lib/js/ trunk/linpha2/lib/js/LinImage.js trunk/linpha2/lib/js/LinSyslog.js trunk/linpha2/lib/js/LinThumbnails.js trunk/linpha2/lib/js/builder.js trunk/linpha2/lib/js/controls.js trunk/linpha2/lib/js/dragdrop.js trunk/linpha2/lib/js/effects.js trunk/linpha2/lib/js/prototype-1.5.0_rc1/ trunk/linpha2/lib/js/prototype-1.5.0_rc1/CHANGELOG trunk/linpha2/lib/js/prototype-1.5.0_rc1/LICENSE trunk/linpha2/lib/js/prototype-1.5.0_rc1/README trunk/linpha2/lib/js/prototype-1.5.0_rc1/Rakefile trunk/linpha2/lib/js/prototype.js trunk/linpha2/lib/js/scriptaculous-js-1.6.4/ trunk/linpha2/lib/js/scriptaculous-js-1.6.4/CHANGELOG trunk/linpha2/lib/js/scriptaculous-js-1.6.4/MIT-LICENSE trunk/linpha2/lib/js/scriptaculous-js-1.6.4/README trunk/linpha2/lib/js/scriptaculous.js trunk/linpha2/lib/js/slider.js trunk/linpha2/lib/js/unittest.js Removed Paths: ------------- trunk/linpha2/lib/classes/image.js trunk/linpha2/lib/classes/syslog.js trunk/linpha2/lib/classes/thumbnails.js Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/docs/dev/TODO.txt 2006-10-07 13:32:45 UTC (rev 4572) @@ -4,9 +4,8 @@ ## Small Todos -- Better Javascript detection - Currently the no-javscript site is loaded with a javascript location.href to the javascript enabled site - -> High Pageload, LinSysLog doesnt work +- add possibility to force static view for old browsers with half javascript working +- save image height and width in database to reduce file access in get_image.php and imgview() ? ## Big Todos @@ -43,6 +42,9 @@ DONE ==== +- Better Javascript detection + Currently the no-javscript site is loaded with a javascript location.href to the javascript enabled site + -> High Pageload, LinSysLog doesnt work - Filemanager (copy from linpha1) - Add support for Write-Permissions - Admin Deleted: trunk/linpha2/lib/classes/image.js =================================================================== --- trunk/linpha2/lib/classes/image.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/image.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,165 +0,0 @@ -var http_request = false; - -function loadImage(imgid) { - - http_request = false; - - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType('text/xml'); - // zu dieser Zeile siehe weiter unten - } - } else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - http_request = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (e) {} - } - } - - if (!http_request) { - alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); - return false; - } - http_request.onreadystatechange = loadImageData; - http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); - http_request.send(null); - -} - -function loadImageData() { - - if (http_request.readyState == 4) { - if (http_request.status == 200) - { -// alert(http_request.responseText); - - var xmldoc = http_request.responseXML; - - /** - * set image source - */ - var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; - document.getElementById('mainimage').src = image_src + imgid; - - /** - * set meta data - */ - if(xmldoc.getElementsByTagName('meta').length > 0) - { - var DivRight = document.getElementById("right"); - DivRight.innerHTML = ''; - - for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) - { - var meta = xmldoc.getElementsByTagName('meta').item(i); - var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); - var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); - - DivRight.appendChild(metaname); - DivRight.appendChild(metavalue); - DivRight.appendChild( document.createElement("br") ); - } - } - - /** - * set current thumb - */ - DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); - DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; - - /** - * set prev thumbs - */ - DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); - DivPrevThumbs.innerHTML = ''; - if(xmldoc.getElementsByTagName('prevthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) - { - var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'img_prevnextthumb'; - ElemImg.setAttributeNode(myAttribute); - var myAttribute=document.createAttribute("src"); - myAttribute.nodeValue = thumb_src + prevThumbId; - ElemImg.setAttributeNode(myAttribute); - - var ElemA = document.createElement("a"); - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:loadImage(' + prevThumbId + ')'; - ElemA.setAttributeNode(myAttribute); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; - ElemDiv.setAttributeNode(myAttribute); - ElemDiv.appendChild(ElemA); - - DivPrevThumbs.appendChild(ElemDiv); - } - } - - /** - * set next thumbs - */ - DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); - DivNextThumbs.innerHTML = ''; - if(xmldoc.getElementsByTagName('nextthumb').length > 0) - { - for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) - { - var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; - - var ElemImg = document.createElement("img"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'img_prevnextthumb'; - ElemImg.setAttributeNode(myAttribute); - var myAttribute=document.createAttribute("src"); - myAttribute.nodeValue = thumb_src + nextThumbId; - ElemImg.setAttributeNode(myAttribute); - - var ElemA = document.createElement("a"); - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:loadImage(' + nextThumbId + ')'; - ElemA.setAttributeNode(myAttribute); - ElemA.appendChild(ElemImg); - - var ElemDiv = document.createElement("div"); - var myAttribute=document.createAttribute("class"); - myAttribute.nodeValue = 'thumbnavi_prevnextthumb'; - ElemDiv.setAttributeNode(myAttribute); - ElemDiv.appendChild(ElemA); - - DivNextThumbs.appendChild(ElemDiv); - } - } - -// <div class="thumbnavi_prevnextthumb"><a href="./?cat=alb&id=9"><img class="img_prevnextthumb" src="./get_thumb.php?id=9" /></a><br />0067_img.jpg</div> - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(0); -// alert(xmldoc.getElementsByTagName('nextthumb').length); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(1); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(2); -// alert(nextthumb.firstChild.data); - -// var nextthumb = xmldoc.getElementsByTagName('nextthumb').item(3); -// alert(nextthumb.firstChild.data); - - - } else { - alert('Bei dem Request ist ein Problem aufgetreten.'); - } - } - -} \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-10-07 13:32:45 UTC (rev 4572) @@ -1070,7 +1070,7 @@ if(isset($_GET['xml'])) { - $this->viewImgAjax(); + $this->viewImgXml(); exit(); } } @@ -1084,13 +1084,18 @@ /** * generate xml data for ajax image view */ -function viewImgAjax() +function viewImgXml() { + + header('Content-type: text/xml'); echo '<?xml version="1.0" ?>'."\n"; ?> <root> <imgid><?php echo $this->id_current; ?></imgid> +<imgwidth><?php echo $this->org_width; ?></imgwidth> +<imgheight><?php echo $this->org_height; ?></imgheight> +<title><?php echo str_replace('<','<',$GLOBALS['linpha']->template->linpha_title." :: ".$GLOBALS['linpha']->template->output['title']); ?></title> <?php if(isset($this->xmldata['prev_thumb'])) { foreach($this->xmldata['prev_thumb'] AS $value) @@ -1134,6 +1139,18 @@ */ function viewImgCommon() { + /** + * get image width and height + * @todo see todo.txt wether to save width and height in database + */ + $this->src_file = LinSql::getFullImagePath( $this->id_current ); + list($this->org_width,$this->org_height,$org_type) = LinIdentify::linGetImageSize( $this->src_file ); + $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + $array = LinImage::scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); + $this->img_width = $array['w']; + $this->img_height = $array['h']; + $this->viewImgSetPrevNextThumb(); $this->viewImgStoreImageInformation(); Deleted: trunk/linpha2/lib/classes/syslog.js =================================================================== --- trunk/linpha2/lib/classes/syslog.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/syslog.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,24 +0,0 @@ -var window_is_open = false; -function toggleWindow() -{ - if( window_is_open ) - { - window_is_open = false; - - document.getElementById('sys_log').style.width = '20px'; - document.getElementById('sys_log').style.height = '20px'; - - document.getElementById('sys_log_text').style.visibility = 'hidden'; - } - else - { - window_is_open = true; - - document.getElementById('sys_log').style.width = 'auto'; - document.getElementById('sys_log').style.height = 'auto'; - - document.getElementById('sys_log_text').style.visibility = ''; - } -} - -toggleWindow(); \ No newline at end of file Deleted: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-10-03 21:45:49 UTC (rev 4571) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -1,447 +0,0 @@ -/** - * javascript thumbnail viewer - * - * check performance: - var start = new Date().getTime(); - alert( (new Date().getTime() - start) ); - * - */ - -var current_page = startup_page -var nr_pages = 0; - -/** - * fine tuning - * better a space more than a space too less - */ -var img_spacer_width = 12; // used to calculate nr_cols -var img_spacer_height = 9; // used to calculate nr_rows -var img_div_spacer_height = 11; // used to calculate max-height of the image (depending how much text we would like to add) - -/** - * page numbers - */ -var pn_left = 3; -var pn_right = 3; -var pn_middle_left = 2; -var pn_middle_right = 4; -var pn_constant = pn_left + pn_right + pn_middle_left + pn_middle_right + 1; -var space_min = 2; // minimum space before replacing numbers with dots - - -function display_images() -{ - /** - * get some values - * browser incompatibilities... - * - * needs to be in display_images! - */ - var linInnerWidth, linInnerHeight; - if (window.innerHeight) // all except Explorer - { - linInnerWidth = self.innerWidth; - linInnerHeight = self.innerHeight; - } - else if (document.body && document.body.offsetWidth) - { - linInnerWidth = document.body.offsetWidth; - linInnerHeight = document.body.offsetHeight; - } - else - { - linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) - linInnerHeight = 300; // take a default value (needs teseting) - } - - /** - * set correct main height only if photos_per_page == auto - */ - document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; - - /** - * calculate nr of photos per page (from select form) - */ - switch( photos_per_page ) - { - case 'auto': - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var nr_rows = Math.floor( document.getElementById('main')['offsetHeight'] / (tn_size + img_spacer_height + img_div_spacer_height) ); - var max_photos_per_page = nr_rows * nr_cols; - break; - case 'all': - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var max_photos_per_page = tot_photos; - var nr_rows = Math.ceil(max_photos_per_page / nr_cols); - break; - default: - /** - * ceil max_photos_per_page to complet the row! - */ - var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); - var nr_rows = Math.ceil( photos_per_page / nr_cols); - var max_photos_per_page = nr_rows * nr_cols; - break; - } - /** - * at least on image per page - */ - (nr_cols == 0) ? nr_cols = 1 : ''; - (nr_rows == 0) ? nr_rows = 1 : ''; - (max_photos_per_page == 0) ? max_photos_per_page = nr_rows * nr_cols : ''; - - - /** - * prepare page numbers - */ - nr_pages = Math.ceil( tot_photos / max_photos_per_page ); - - - /** - * check if our current page still exists (maybe we changed the tn_size and now there arent so much pages anymore) - * (but not if current_page == 1 and nr_pages == 0) - */ - if(current_page > nr_pages && current_page != 1) - { - current_page = nr_pages; - } - - /** - * write page numbers - */ - write_page_numbers(); - - /** - * write divs - */ - var img_nr = 1; - var startup_img_nr = (current_page - 1)*max_photos_per_page; - - var DivMain = document.getElementById("main"); - DivMain.innerHTML=''; - divhtmltext = ''; - - for (i in img_ids) - { - if(i >= startup_img_nr && img_nr <= max_photos_per_page) - { - if( (img_nr-1) % nr_cols == 0) - { - styletext = ' style="clear:left;"'; - } - else - { - styletext = ''; - } - - divhtmltext += - '<div id="div' + i + '"' + styletext + ' class="imgdiv">' + - img_ids[i]['before'] + - '<a href="' + link_url + '&id=' + img_ids[i]['id'] + '">' + - '<img src="' + link_get_thumb + img_ids[i]['id'] + '"' + - ' height="' + tn_size + '" width="' + tn_size + '" ' + - ' alt="' + img_ids[i]['title'] + '" title="' + img_ids[i]['title'] + '"' + - ' class="img_thumbnail" />' + - '</a>' + img_ids[i]['after'] + '</div>'; - - /** - * flush buffer of divhtmltext on end of line - * with this buffer, we're 3-4 as fast as without !! - * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! - */ - if( (img_nr-1) % nr_cols == 0) - { - DivMain.innerHTML += divhtmltext; - divhtmltext = ''; - } - - img_nr++; - } - } - - DivMain.innerHTML += divhtmltext; -} - -function goto_page(nr) -{ - current_page = nr; - display_images(); -} - -function write_page_numbers() -{ - /** - * create an array with page numbers - */ - pn_nrs = new Array(); - var nr_pages_shown = 0; - var start_gap = 0; - var end_gap = 0; - - /** - * get all pages which should be shown - */ - for(var i = 1; i <= nr_pages; i++) - { - if( pn_constant >= nr_pages // show all pages if we dont have much - || i <= pn_left // left side - || (i > ( nr_pages - pn_right ) ) // right side - || (i >= ( current_page - pn_middle_left ) && i <= current_page) // middle left - || (i <= ( current_page + pn_middle_right ) && i >= current_page) // middle right - ) - { - pn_nrs[i] = 1; - nr_pages_shown++; - - if(start_gap != 0 && end_gap == 0) // make sure this is done only with the first gap - { - end_gap = i-1; // used later to fill up this gap if needed - } - } - else - { - pn_nrs[i] = 0; - - if(start_gap == 0) // make sure this is done only with the first gap - { - start_gap = i; // used later to fill up this gap if needed - } - } - } - - /** - * add current_page to array, and increment nr_pages_shown if needed - */ - if(pn_nrs[current_page] == 0) - { - nr_pages_shown++; - } - pn_nrs[current_page] = 2; - - /** - * if with have a lot of pages, fill up the array so that we have all the time the same number of page numbers - */ - if( pn_constant > nr_pages_shown && nr_pages > pn_constant) - { - /** - * fill up the gap (there is only _one_ gap if we have to fill up the array) - * stop if we filled up enough the needed value, - * or stop if we are reaching the space_min (to prevent: 1 2 3 4 5 6 ... 8 9 10 11) - */ - beginn_with_startgap = 1; - while( pn_constant > nr_pages_shown && (end_gap - start_gap) >= space_min) - { - if(beginn_with_startgap == 1) - { - pn_nrs[start_gap] = 1; - nr_pages_shown++; - start_gap++; - - beginn_with_startgap = 0; - } - else //beginn_with_startgap = 0 - { - pn_nrs[end_gap] = 1; - nr_pages_shown++; - end_gap--; - - beginn_with_startgap = 1; - } - } - } - - /** - * search for small gaps (space_min) and fill up - */ - var counter = 0; - for(var i = 1; i <= nr_pages; i++) - { - if(pn_nrs[i] == 0) - { - counter++; - } - else - { - if(counter < space_min) - { - /** - * fill up gap - */ - for(var ii = (i-1); ii >= (i-counter); ii--) - { - pn_nrs[ii] = 1; - } - } - - /** - * reset counter - */ - counter = 0; - } - } - - - - - /** - * start writing out infos - */ - - /** - * write starting '<<' and '<' - */ - DivPageNr = document.getElementById("page_nr_left"); - DivPageNr.innerHTML=''; - - if(current_page != 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode("<<"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('<<'); - DivPageNr.appendChild(myText); - } - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - - /** - * write starting '<' - */ - if(current_page != 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(current_page-1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode("<"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('<'); - DivPageNr.appendChild(myText); - } - - /** - * write page numbers - */ - DivPageNr = document.getElementById("page_nr_middle"); - DivPageNr.innerHTML=''; - - for(var i = 1; i <= nr_pages; i++) - { - if(pn_nrs[i] != 0) - { - start_gap = 0; - - if(pn_nrs[i] == 2) - { - var myText = document.createTextNode(i); - } - else if(pn_nrs[i] == 1) - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page('+i+')'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(i); - myText.appendChild(myText2); - } - DivPageNr.appendChild(myText); - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - } - else - { - if(start_gap == 0) - { - start_gap = 1; - - var myText = document.createTextNode(' ... '); - DivPageNr.appendChild(myText); - } - } - } - - /** - * write ending '>' and '>>' - */ - DivPageNr = document.getElementById("page_nr_right"); - DivPageNr.innerHTML=''; - - if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(current_page+1)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(">"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('>'); - DivPageNr.appendChild(myText); - } - - var myText = document.createTextNode(' '); - DivPageNr.appendChild(myText); - - /** - * write ending '>>' - */ - if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! - { - var myText = document.createElement('a'); - - var myAttribute=document.createAttribute("href"); - myAttribute.nodeValue = 'javascript:goto_page(nr_pages)'; - myText.setAttributeNode(myAttribute); - - var myText2 = document.createTextNode(">>"); - myText.appendChild(myText2); - DivPageNr.appendChild(myText); - } - else - { - var myText = document.createTextNode('>>'); - DivPageNr.appendChild(myText); - } -} - -function set_tn_size( tn_size_local ) -{ - tn_size = tn_size_local; - display_images(); -} - -function set_nr_images( photos_per_page_local) -{ - photos_per_page = photos_per_page_local; - display_images(); -} - -/** - * function view_source_code() removed - * use firefox extension "Aardvark" - * much nicer ;-) - */ \ No newline at end of file Added: trunk/linpha2/lib/js/LinImage.js =================================================================== --- trunk/linpha2/lib/js/LinImage.js (rev 0) +++ trunk/linpha2/lib/js/LinImage.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,310 @@ +var http_request = false; +var img_width; +var img_height; + +var colorinfoactive; +var colorinfonotactive; + + +function loadImage(imgid) { + + http_request = false; + + if (window.XMLHttpRequest) { // Mozilla, Safari,... + http_request = new XMLHttpRequest(); + if (http_request.overrideMimeType) { + http_request.overrideMimeType('text/xml'); + // zu dieser Zeile siehe weiter unten + } + } else if (window.ActiveXObject) { // IE + try { + http_request = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + http_request = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) {} + } + } + + if (!http_request) { + alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen'); + return false; + } + http_request.onreadystatechange = loadImageData; + http_request.open('GET', imagedata_url + '&id=' + imgid + '&xml', true); + http_request.send(null); + +} + +function loadImageData() { + + if (http_request.readyState == 4) { + if (http_request.status == 200) + { + setImageData(); + } else { + alert('Bei dem Request ist ein Problem aufgetreten.'); + } + } +} // end function loadImageData() + +function setImageData() +{ +// alert(http_request.responseText); + + /** + * hide meta text immediately + */ + hideImgInfoNow(); + + var xmldoc = http_request.responseXML; + + /** + * set image with source, width and height + */ + var imgid = xmldoc.getElementsByTagName('imgid').item(0).firstChild.data; + var orgwidth = xmldoc.getElementsByTagName('imgwidth').item(0).firstChild.data; + var orgheight = xmldoc.getElementsByTagName('imgheight').item(0).firstChild.data; + var sizearray = scaleToFit(orgwidth,orgheight,image_size,image_size,1); + imgwidth = sizearray[0]; + imgheight = sizearray[1]; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('src',image_src + imgid + '&max_width=' + imgwidth + '&max_height=' + imgheight); + ElemImg.setAttribute('id','mainimage'); + ElemImg.setAttribute('width',imgwidth); + ElemImg.setAttribute('height',imgheight); + + var DivMainImage = document.getElementById('divimage'); + DivMainImage.innerHTML = ''; + DivMainImage.appendChild(ElemImg); + + /** + * set title + */ + var title = xmldoc.getElementsByTagName('title').item(0).firstChild.data; + document.getElementById('title').innerHTML = title; + + /** + * set current thumb + */ + var DivCurrentThumb = document.getElementById('thumbnavi_currentthumb'); + DivCurrentThumb.innerHTML = '<a href="javascript:loadImage(' + imgid + ')"><img class="img_currentthumb" src="' + thumb_src + imgid + '" /></a>'; + + /** + * set prev thumbs + */ + var DivPrevThumbs = document.getElementById('thumbnavi_prevthumb'); + DivPrevThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('prevthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('prevthumb').length; i++) + { + var prevThumbId = xmldoc.getElementsByTagName('prevthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('class','img_prevnextthumb'); + ElemImg.setAttribute('src',thumb_src + prevThumbId); + + var ElemA = document.createElement("a"); + ElemA.setAttribute('href','javascript:loadImage(' + prevThumbId + ')'); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); + ElemDiv.appendChild(ElemA); + + DivPrevThumbs.appendChild(ElemDiv); + } + } + + /** + * set next thumbs + */ + var DivNextThumbs = document.getElementById('thumbnavi_nextthumb'); + DivNextThumbs.innerHTML = ''; + if(xmldoc.getElementsByTagName('nextthumb').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('nextthumb').length; i++) + { + var nextThumbId = xmldoc.getElementsByTagName('nextthumb').item(i).firstChild.data; + + var ElemImg = document.createElement("img"); + ElemImg.setAttribute('class','img_prevnextthumb'); + ElemImg.setAttribute('src',thumb_src + nextThumbId); + + var ElemA = document.createElement("a"); + ElemA.setAttribute('href','javascript:loadImage(' + nextThumbId + ')'); + ElemA.appendChild(ElemImg); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','thumbnavi_prevnextthumb'); + ElemDiv.appendChild(ElemA); + + DivNextThumbs.appendChild(ElemDiv); + } + } + + /** + * set meta data + */ + if(xmldoc.getElementsByTagName('meta').length > 0) + { + var DivMeta = document.getElementById("divmeta"); + DivMeta.innerHTML = ''; + + for(var i = 0; i < xmldoc.getElementsByTagName('meta').length; i++) + { + var meta = xmldoc.getElementsByTagName('meta').item(i); + var metaname = document.createTextNode( meta.getElementsByTagName('name').item(0).firstChild.data + ': ' ); + var metavalue = document.createTextNode( meta.getElementsByTagName('value').item(0).firstChild.data ); + + DivMeta.appendChild(metaname); + DivMeta.appendChild(metavalue); + DivMeta.appendChild( document.createElement("br") ); + } + } + + /** + * set comments + */ + var DivComments = document.getElementById('divcomments'); + DivComments.innerHTML = ''; + if(xmldoc.getElementsByTagName('comment').length > 0) + { + for(var i = 0; i < xmldoc.getElementsByTagName('comment').length; i++) + { + var comment = xmldoc.getElementsByTagName('comment').item(i); + var commenttime = document.createTextNode( comment.getElementsByTagName('time').item(0).firstChild.data + ' ' ); + var commentauthor = document.createTextNode( comment.getElementsByTagName('author').item(0).firstChild.data ); + var commenttext = document.createTextNode( comment.getElementsByTagName('text').item(0).firstChild.data ); + + var ElemDiv = document.createElement("div"); + ElemDiv.setAttribute('class','comments'); + ElemDiv.appendChild(commenttime); + ElemDiv.appendChild(commentauthor); + ElemDiv.appendChild( document.createElement("br") ); + ElemDiv.appendChild(commenttext); + ElemDiv.appendChild( document.createElement("br") ); + + DivComments.appendChild(ElemDiv); + } + } + + /** + * set positions of info link + */ + var mainimage = document.getElementById('mainimage'); + var divinfolinks = document.getElementById('divinfolinks'); + divinfolinks.style.top = mainimage.offsetTop + mainimage.offsetHeight; + divinfolinks.style.left = mainimage.offsetLeft + mainimage.offsetWidth - divinfolinks.offsetWidth; +// alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); + + + +} // end function setImageData() + +function testsize() +{ + /** + * set positions of info link + */ + var mainimage = document.getElementById('mainimage'); + alert(mainimage.offsetLeft + ' ' + mainimage.offsetTop + ' ' + mainimage.offsetWidth + ' ' + mainimage.offsetHeight); + +} + +var showhide = 'hide'; +function showImgInfo() +{ + /** + * make visible/invisible + */ + if( showhide == 'hide' ) + { + showhide = 'show'; + + /** + * set position + */ + $('divmeta').style.top = $('mainimage').offsetTop + 50; + $('divmeta').style.left = $('mainimage').offsetLeft + 50; + + /** + * fade in + */ + new Effect.Appear('divmeta', { duration: 0.5, from: 0.0, to: 1.0 }); + new Effect.Appear('divimage', { duration: 0.5, from: 1.0, to: 0.3 }); + + document.getElementById('hrefinfolinks').style.color = colorinfonotactive; + } + else + { + showhide = 'hide'; + + new Effect.Appear('divmeta', { duration: 0.5, from: 1.0, to: 0.0 }); + new Effect.Appear('divimage', { duration: 0.5, from: 0.3, to: 1.3 }); + + document.getElementById('hrefinfolinks').style.color = colorinfoactive; + } +} +function hideImgInfoNow() +{ + $('divmeta').style.display = 'none'; + Element.setOpacity('divimage',1); + showhide = 'hide'; +} + + +/** + * with that function it is possible to set the colors in the css template (and not in javascript file) + */ +function setInfoColors() +{ + colorinfonotactive = document.getElementById('divinfolinks').style.color; + colorinfoactive = document.getElementById('hrefinfolinks').style.color; +} + +/** + * returns an array(width, height) with the correct size to fit + * in dst_w and dst_h + */ +function scaleToFit(src_w,src_h,dst_w,dst_h,no_increase) +{ + if(src_h == 0 || src_w == 0) + { + return new Array(0, 0); + } + + var img_relation = src_w / src_h; + + // Image is smaller than screen, no resize required + if ((src_w <= dst_w) && (src_h <= dst_h) && no_increase) + { + var returnarray = new Array(src_w, src_h); + } + else + { + /* + The image is way bigger than the screen, resize maintaining aspect ratio + + $src_w, $src_h: original image sizes + $dst_w, $dst_h: screen width and height + $img_relation = $src_w/$src_h; + + Either $dst_w decisive or $dst_h, usually $dst_h + */ + + var tmp_height = dst_w / img_relation; // calc the new height with screen width + if (tmp_height > dst_h) // we were wrong, it's still widther than screen -> $dst_h is decisive + { + var returnarray = new Array(Math.round(img_relation*dst_h), dst_h); + } + else + { + var returnarray = new Array(dst_w, tmp_height); + } + } + + return returnarray; +} \ No newline at end of file Added: trunk/linpha2/lib/js/LinSyslog.js =================================================================== --- trunk/linpha2/lib/js/LinSyslog.js (rev 0) +++ trunk/linpha2/lib/js/LinSyslog.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,24 @@ +var window_is_open = false; +function toggleWindow() +{ + if( window_is_open ) + { + window_is_open = false; + + document.getElementById('sys_log').style.width = '20px'; + document.getElementById('sys_log').style.height = '20px'; + + document.getElementById('sys_log_text').style.visibility = 'hidden'; + } + else + { + window_is_open = true; + + document.getElementById('sys_log').style.width = 'auto'; + document.getElementById('sys_log').style.height = 'auto'; + + document.getElementById('sys_log_text').style.visibility = ''; + } +} + +toggleWindow(); \ No newline at end of file Added: trunk/linpha2/lib/js/LinThumbnails.js =================================================================== --- trunk/linpha2/lib/js/LinThumbnails.js (rev 0) +++ trunk/linpha2/lib/js/LinThumbnails.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,447 @@ +/** + * javascript thumbnail viewer + * + * check performance: + var start = new Date().getTime(); + alert( (new Date().getTime() - start) ); + * + */ + +var current_page = startup_page +var nr_pages = 0; + +/** + * fine tuning + * better a space more than a space too less + */ +var img_spacer_width = 12; // used to calculate nr_cols +var img_spacer_height = 9; // used to calculate nr_rows +var img_div_spacer_height = 11; // used to calculate max-height of the image (depending how much text we would like to add) + +/** + * page numbers + */ +var pn_left = 3; +var pn_right = 3; +var pn_middle_left = 2; +var pn_middle_right = 4; +var pn_constant = pn_left + pn_right + pn_middle_left + pn_middle_right + 1; +var space_min = 2; // minimum space before replacing numbers with dots + + +function display_images() +{ + /** + * get some values + * browser incompatibilities... + * + * needs to be in display_images! + */ + var linInnerWidth, linInnerHeight; + if (window.innerHeight) // all except Explorer + { + linInnerWidth = self.innerWidth; + linInnerHeight = self.innerHeight; + } + else if (document.body && document.body.offsetWidth) + { + linInnerWidth = document.body.offsetWidth; + linInnerHeight = document.body.offsetHeight; + } + else + { + linInnerWidth = 500; // take a default value (@todo needs testing, maybe anyway never needed) + linInnerHeight = 300; // take a default value (needs teseting) + } + + /** + * set correct main height only if photos_per_page == auto + */ + document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + + /** + * calculate nr of photos per page (from select form) + */ + switch( photos_per_page ) + { + case 'auto': + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var nr_rows = Math.floor( document.getElementById('main')['offsetHeight'] / (tn_size + img_spacer_height + img_div_spacer_height) ); + var max_photos_per_page = nr_rows * nr_cols; + break; + case 'all': + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var max_photos_per_page = tot_photos; + var nr_rows = Math.ceil(max_photos_per_page / nr_cols); + break; + default: + /** + * ceil max_photos_per_page to complet the row! + */ + var nr_cols = Math.floor( document.getElementById('main')['offsetWidth'] / (tn_size + img_spacer_width) ); + var nr_rows = Math.ceil( photos_per_page / nr_cols); + var max_photos_per_page = nr_rows * nr_cols; + break; + } + /** + * at least on image per page + */ + (nr_cols == 0) ? nr_cols = 1 : ''; + (nr_rows == 0) ? nr_rows = 1 : ''; + (max_photos_per_page == 0) ? max_photos_per_page = nr_rows * nr_cols : ''; + + + /** + * prepare page numbers + */ + nr_pages = Math.ceil( tot_photos / max_photos_per_page ); + + + /** + * check if our current page still exists (maybe we changed the tn_size and now there arent so much pages anymore) + * (but not if current_page == 1 and nr_pages == 0) + */ + if(current_page > nr_pages && current_page != 1) + { + current_page = nr_pages; + } + + /** + * write page numbers + */ + write_page_numbers(); + + /** + * write divs + */ + var img_nr = 1; + var startup_img_nr = (current_page - 1)*max_photos_per_page; + + var DivMain = document.getElementById("main"); + DivMain.innerHTML=''; + divhtmltext = ''; + + for (i in img_ids) + { + if(i >= startup_img_nr && img_nr <= max_photos_per_page) + { + if( (img_nr-1) % nr_cols == 0) + { + styletext = ' style="clear:left;"'; + } + else + { + styletext = ''; + } + + divhtmltext += + '<div id="div' + i + '"' + styletext + ' class="imgdiv">' + + img_ids[i]['before'] + + '<a href="' + link_url + '&id=' + img_ids[i]['id'] + '">' + + '<img src="' + link_get_thumb + img_ids[i]['id'] + '"' + + ' height="' + tn_size + '" width="' + tn_size + '" ' + + ' alt="' + img_ids[i]['title'] + '" title="' + img_ids[i]['title'] + '"' + + ' class="img_thumbnail" />' + + '</a>' + img_ids[i]['after'] + '</div>'; + + /** + * flush buffer of divhtmltext on end of line + * with this buffer, we're 3-4 as fast as without !! + * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! + */ + if( (img_nr-1) % nr_cols == 0) + { + DivMain.innerHTML += divhtmltext; + divhtmltext = ''; + } + + img_nr++; + } + } + + DivMain.innerHTML += divhtmltext; +} + +function goto_page(nr) +{ + current_page = nr; + display_images(); +} + +function write_page_numbers() +{ + /** + * create an array with page numbers + */ + pn_nrs = new Array(); + var nr_pages_shown = 0; + var start_gap = 0; + var end_gap = 0; + + /** + * get all pages which should be shown + */ + for(var i = 1; i <= nr_pages; i++) + { + if( pn_constant >= nr_pages // show all pages if we dont have much + || i <= pn_left // left side + || (i > ( nr_pages - pn_right ) ) // right side + || (i >= ( current_page - pn_middle_left ) && i <= current_page) // middle left + || (i <= ( current_page + pn_middle_right ) && i >= current_page) // middle right + ) + { + pn_nrs[i] = 1; + nr_pages_shown++; + + if(start_gap != 0 && end_gap == 0) // make sure this is done only with the first gap + { + end_gap = i-1; // used later to fill up this gap if needed + } + } + else + { + pn_nrs[i] = 0; + + if(start_gap == 0) // make sure this is done only with the first gap + { + start_gap = i; // used later to fill up this gap if needed + } + } + } + + /** + * add current_page to array, and increment nr_pages_shown if needed + */ + if(pn_nrs[current_page] == 0) + { + nr_pages_shown++; + } + pn_nrs[current_page] = 2; + + /** + * if with have a lot of pages, fill up the array so that we have all the time the same number of page numbers + */ + if( pn_constant > nr_pages_shown && nr_pages > pn_constant) + { + /** + * fill up the gap (there is only _one_ gap if we have to fill up the array) + * stop if we filled up enough the needed value, + * or stop if we are reaching the space_min (to prevent: 1 2 3 4 5 6 ... 8 9 10 11) + */ + beginn_with_startgap = 1; + while( pn_constant > nr_pages_shown && (end_gap - start_gap) >= space_min) + { + if(beginn_with_startgap == 1) + { + pn_nrs[start_gap] = 1; + nr_pages_shown++; + start_gap++; + + beginn_with_startgap = 0; + } + else //beginn_with_startgap = 0 + { + pn_nrs[end_gap] = 1; + nr_pages_shown++; + end_gap--; + + beginn_with_startgap = 1; + } + } + } + + /** + * search for small gaps (space_min) and fill up + */ + var counter = 0; + for(var i = 1; i <= nr_pages; i++) + { + if(pn_nrs[i] == 0) + { + counter++; + } + else + { + if(counter < space_min) + { + /** + * fill up gap + */ + for(var ii = (i-1); ii >= (i-counter); ii--) + { + pn_nrs[ii] = 1; + } + } + + /** + * reset counter + */ + counter = 0; + } + } + + + + + /** + * start writing out infos + */ + + /** + * write starting '<<' and '<' + */ + DivPageNr = document.getElementById("page_nr_left"); + DivPageNr.innerHTML=''; + + if(current_page != 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode("<<"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('<<'); + DivPageNr.appendChild(myText); + } + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + + /** + * write starting '<' + */ + if(current_page != 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(current_page-1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode("<"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('<'); + DivPageNr.appendChild(myText); + } + + /** + * write page numbers + */ + DivPageNr = document.getElementById("page_nr_middle"); + DivPageNr.innerHTML=''; + + for(var i = 1; i <= nr_pages; i++) + { + if(pn_nrs[i] != 0) + { + start_gap = 0; + + if(pn_nrs[i] == 2) + { + var myText = document.createTextNode(i); + } + else if(pn_nrs[i] == 1) + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page('+i+')'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(i); + myText.appendChild(myText2); + } + DivPageNr.appendChild(myText); + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + } + else + { + if(start_gap == 0) + { + start_gap = 1; + + var myText = document.createTextNode(' ... '); + DivPageNr.appendChild(myText); + } + } + } + + /** + * write ending '>' and '>>' + */ + DivPageNr = document.getElementById("page_nr_right"); + DivPageNr.innerHTML=''; + + if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(current_page+1)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(">"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('>'); + DivPageNr.appendChild(myText); + } + + var myText = document.createTextNode(' '); + DivPageNr.appendChild(myText); + + /** + * write ending '>>' + */ + if(current_page != nr_pages && nr_pages != 0) // need check nr_pages != 0 because we don't need links if nr_pages == 0! + { + var myText = document.createElement('a'); + + var myAttribute=document.createAttribute("href"); + myAttribute.nodeValue = 'javascript:goto_page(nr_pages)'; + myText.setAttributeNode(myAttribute); + + var myText2 = document.createTextNode(">>"); + myText.appendChild(myText2); + DivPageNr.appendChild(myText); + } + else + { + var myText = document.createTextNode('>>'); + DivPageNr.appendChild(myText); + } +} + +function set_tn_size( tn_size_local ) +{ + tn_size = tn_size_local; + display_images(); +} + +function set_nr_images( photos_per_page_local) +{ + photos_per_page = photos_per_page_local; + display_images(); +} + +/** + * function view_source_code() removed + * use firefox extension "Aardvark" + * much nicer ;-) + */ \ No newline at end of file Added: trunk/linpha2/lib/js/builder.js =================================================================== --- trunk/linpha2/lib/js/builder.js (rev 0) +++ trunk/linpha2/lib/js/builder.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,119 @@ +// script.aculo.us builder.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 + +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// +// See scriptaculous.js for full license. + +var Builder = { + NODEMAP: { + AREA: 'map', + CAPTION: 'table', + COL: 'table', + COLGROUP: 'table', + LEGEND: 'fieldset', + OPTGROUP: 'select', + OPTION: 'select', + PARAM: 'object', + TBODY: 'table', + TD: 'table', + TFOOT: 'table', + TH: 'table', + THEAD: 'table', + TR: 'table' + }, + // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, + // due to a Firefox bug + node: function(elementName) { + elementName = elementName.toUpperCase(); + + // try innerHTML approach + var parentTag = this.NODEMAP[elementName] || 'div'; + var parentElement = document.createElement(parentTag); + try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 + parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; + } catch(e) {} + var element = parentElement.firstChild || null; + + // see if browser added wrapping tags + if(element && (element.tagName != elementName)) + element = element.getElementsByTagName(elementName)[0]; + + // fallback to createElement approach + if(!element) element = document.createElement(elementName); + + // abort if nothing could be created + if(!element) return; + + // attributes (or text) + if(arguments[1]) + if(this._isStringOrNumber(arguments[1]) || + (arguments[1] instanceof Array)) { + this._children(element, arguments[1]); + } else { + var attrs = this._attributes(arguments[1]); + if(attrs.length) { + try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 + parentElement.innerHTML = "<" +elementName + " " + + attrs + "></" + elementName + ">"; + } catch(e) {} + element = parentElement.firstChild || null; + // workaround firefox 1.0.X bug + if(!element) { + element = document.createElement(elementName); + for(attr in arguments[1]) + element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; + } + if(element.tagName != elementName) + element = parentElement.getElementsByTagName(elementName)[0]; + } + } + + // text, or array of children + if(arguments[2]) + this._children(element, arguments[2]); + + return element; + }, + _text: function(text) { + return document.createTextNode(text); + }, + _attributes: function(attributes) { + var attrs = []; + for(attribute in attributes) + attrs.push((attribute=='className' ? 'class' : attribute) + + '="' + attributes[attribute].toString().escapeHTML() + '"'); + return attrs.join(" "); + }, + _children: function(element, children) { + if(typeof children=='object') { // array can hold nodes and text + children.flatten().each( function(e) { + if(typeof e=='object') + element.appendChild(e) + else + if(Builder._isStringOrNumber(e)) + element.appendChild(Builder._text(e)); + }); + } else + if(Builder._isStringOrNumber(children)) + element.appendChild(Builder._text(children)); + }, + _isStringOrNumber: function(param) { + return(typeof param=='string' || typeof param=='number'); + }, + dump: function(scope) { + if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope + + var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + + "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + + "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ + "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ + "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ + "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); + + tags.each( function(tag){ + scope[tag] = function() { + return Builder.node.apply(Builder, [tag].concat($A(arguments))); + } + }); + } +} \ No newline at end of file Added: trunk/linpha2/lib/js/controls.js =================================================================== --- trunk/linpha2/lib/js/controls.js (rev 0) +++ trunk/linpha2/lib/js/controls.js 2006-10-07 13:32:45 UTC (rev 4572) @@ -0,0 +1,833 @@ +// script.aculo.us controls.js v1.6.4, Wed Sep 06 11:30:58 CEST 2006 + +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) +// (c) 2005 Jon Tirsen (http://www.tirsen.com) +// Contributors: +// Richard Livsey +// Rahul Bhargava +// Rob Wills +// +// See scriptaculous.js for full license. + +// Autocompleter.Base handles all the autocompletion functionality +// that's independent of the data source for autocompletion. This +// includes drawing the autocompletion menu, observing keyboard +// and mouse events, and similar. +// +// Specific autocompleters need to provide, at the very least, +// a getUpdatedChoices function that will be invoked every time +// the text inside the monitored textbox changes. This method +// should get the text for which to provide autocompletion by +// invoking this.getToken(), NOT by directly accessing +// this.element.value. This is to allow incremental tokenized +// autocompletion. Specific auto-completion logic (AJAX, etc) +// belongs in getUpdatedChoices. +// +// Tokenized incremental autocompletion is enabled automatically +// when an autocompleter is instantiated with the 'tokens' option +// in the options parameter, e.g.: +// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); +// will incrementally autocomplete with a comma as the token. +// Additionally, ',' in the above example can be replaced with +// a token array, e.g. { tokens: [',', '\n'] } which +// enables autocompletion on multiple tokens. This is most +// useful when one of the tokens is \n (a newline), as it +// allows smart autocompletion after linebreaks. + +if(typeof Effect == 'undefined') + throw("controls.js requires including script.aculo.us' effects.js library"); + +var Autocompleter = {} +Autocompleter.Base = function() {}; +Autocompleter.Base.prototype = { + baseInitialize: function(element, update, options) { + this.element = $(element); + this.update = $(update); + this.hasFocus = false; + this.changed = false; + this.active = false; + this.index = 0; + this.entryCount = 0; + + if(this.setOptions) + this.setOptions(options); + else + this.options = options || {}; + + this.options.paramName = this.options.paramName || this.element.name; + this.options.tokens = this.options.tokens || []; + this.options.frequency = this.options.frequency || 0.4; + this.options.minChars = this.options.minChars || 1; + this.options.onShow = this.options.onShow || + function(element, update){ + if(!update.style.position || update.style.position=='absolute') { + update.style.position = 'absolute'; + Position.clone(element, update, { + setHeight: false, + offsetTop: element.offsetHeight + }); + } + Effect.Appear(update,{duration:0.15}); + }; + this.options.onHide = this.options.onHide || + function(element, update){ new Effect.Fade(update,{duration:0.15}) }; + + if(typeof(this.options.tokens) == 'string') + this.options.tokens = new Array(this.options.tokens); + + this.observer = null; + + this.element.setAttribute('autocomplete','off'); + + Element.hide(this.update); + + Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + }, + + show: function() { + if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); + if(!this.iefix && + (navigator.appVersion.indexOf('MSIE')>0) && + (navigator.userAgent.indexOf('Opera')<0) && + (Element.getStyle(this.update, 'position')=='absolute')) { + new Insertion.After(this.update, + '<iframe id="' + this.update.id + '_iefix" '+ + 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + + 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>'); + this.iefix = $(this.update.id+'_iefix'); + } + if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); + }, + + fixIEOverlapping: function() { + Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); + this.iefix.style.zIndex = 1; + this.update.style.zIndex = 2; + Element.show(this.iefix); + }, + + hide: function() { + this.stopIndicator(); + if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); + if(this.iefix) Element.hide(this.iefix); + }, + + startIndicator: function() { + if(this.options.indicator) Element.show(this.options.indicator); + }, + + stopIndicator: function() { + if(this.options.indicator) Element.hide(this.options.indicator); + }, + + onKeyPress: function(event) { + if(this.active) + switch(event.keyCode) { + case Event.KEY_TAB: + case Event.KEY_RETURN: + this.selectEntry(); + Event.stop(event); + case Event.KEY_ESC: + this.hide(); + this.active = false; + Event.stop(event); + return; + case Event.KEY_LEFT: + case Event.KEY_RIGHT: + return; + case Event.KEY_UP: + this.markPrevious(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + case Event.KEY_DOWN: + this.markNext(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + } + else + if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || + (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return; + + this.changed = true; + this.hasFocus = true; + + if(this.observer) clearTimeout(this.observer); + this.observer = + setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); + }, + + activate: function() { + this.changed = false; + this.hasFocus = true; + this.getUpdatedChoices(); + }, + + onHover: function(event) { + var element = Event.findElement(event, 'LI'); + if(this.index != element.autocompleteIndex) + { + this.index = element.autocompleteIndex; + this.render(); + } + Event.stop(event); + }, + + onClick: function(event) { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.selectEntry(); + this.hide(); + }, + + onBlur: function(event) { + // needed to make click events working + setTimeout(this.hide.bind(this), 250); + this.hasFocus = false; + this.active = false; + }, + + render: function() { + if(this.entryCount > 0) { + for (var i = 0; i < this.entryCount; i++) + this.index==i ? + Element.addClassName(this.getEntry(i),"selected") : + Element.removeClassName(this.getEntry(i),"selected"); + + if(this.hasFocus) { + this.show(); + this.active = true; + } + } else { + this.active = false; + this.hide(); + } + }, + + markPrevious: function() { + if(this.index > 0) this.index-- + else this.index = this.entryCount-1; + this.getEntry(this.index).scrollIntoView(true); + }, + + markNext: function() { + if(this.index < this.entryCount-1) this.index++ + else this.index = 0; + this.getEntry(this.index).scrollIntoView(false); + }, + + getEntry: function(index) { + return this.update.firstChild.childNodes[index]; + }, + + getCurrentEntry: function() { + return this.getEntry(this.index); + }, + + selectEntry: function() { + this.active = false; + this.updateElement(this.getCurrentEntry()); + }, + + updateElement: function(selectedElement) { + if (this.options.updateElement) { + this.options.updateElement(selectedElement); + return; + } + var value = ''; + if (this.options.select) { + var nodes = document.getElementsByClassName(this.options.select, selectedElement) || []; + if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); + } else + value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); + + var lastTokenPos = this.findLastToken(); + if (lastTokenPos != -1) { + var newValue = this.element.value.substr(0, lastTokenPos + 1); + var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); + if (whitespace) + newValue += whitespace[0]; + this.element.value = newValue + value; + } else { + this.element.value = value; + } + this.element.focus(); + + if (this.options.afterUpdateElement) + this.options.afterUpdateElement(this.element, selectedElement); + }, + + updateChoices: function(choices) { + if(!this.changed && this.hasFocus) { + this.update.innerHTML = choices; + Element.cleanWhitespace(this.update); + Element.cleanWhitespace(this.update.firstChild); + + if(this.update.firstChild && this.update.firstChild.childNodes) { + this.entryCount = + this.update.firstChild.childNodes.length; + for (var i = 0; i < this.entryCount; i++) { + var entry = this.getEntry(i); + entry.autocompleteIndex = i; + this.addObservers(entry); + } + } else { + this.entryCount = 0; + } + + this.stopIndicator(); + this.index = 0; + + if(this.entryCount==1 && this.options.autoSelect) { + this.selectEntry(); + this.hide(); + } else { + this.render(); + } + } + }, + + addObservers: function(element) { + Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); + Event.observe(element, "click", this.onClick.bindAsEventListener(this)); + }, + + onObserverEvent: function() { + this.changed = false; + if(this.getToken().length>=this.options.minChars) { + this.startIndicator(); + this.getUpdatedChoices(); + } else { + this.active = false; + this.hide(); + } + }, + + getToken: function() { + var tokenPos = this.findLastToken(); + if (tokenPos != -1) + var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); + else + var ret = this.element.value; + + return /\n/.test(ret) ? '' : ret; + }, + + findLastToken: function() { + var lastTokenPos = -1; + + for (var i=0; i<this.options.tokens.length; i++) { + var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]); + if (thisTokenPos > lastTokenPos) + lastTokenPos = thisTokenPos; + } + return lastTokenPos; + } +} + +Ajax.Autocompleter = Class.create(); +Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { + initialize: function(element, update, url, options) { + this.baseInitialize(element, update, options); + ... [truncated message content] |