From: <rv...@us...> - 2010-03-23 18:15:18
|
Revision: 652 http://treebase.svn.sourceforge.net/treebase/?rev=652&view=rev Author: rvos Date: 2010-03-23 18:15:11 +0000 (Tue, 23 Mar 2010) Log Message: ----------- IE fixes Modified Paths: -------------- trunk/treebase-web/src/main/webapp/WEB-INF/pages/home.jsp trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/matrixSimpleSearchForm.jsp trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/studyKeywordSearchForm.jsp trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/treeSimpleSearchForm.jsp trunk/treebase-web/src/main/webapp/common/header.jsp trunk/treebase-web/src/main/webapp/common/meta.jsp trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp trunk/treebase-web/src/main/webapp/scripts/common.js Added Paths: ----------- trunk/treebase-web/src/main/webapp/scripts/prototype/prototype-1.6.1.js Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/home.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/home.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/home.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -1,6 +1,6 @@ <div id="contentRight"> <div class="gutter"> - <h1>Welcome to TreeBASE</h1> + <h1>Welcome to TreeBASE</h1> <p> TreeBASE is a repository of phylogenetic information, specifically user-submitted phylogenetic trees and the data used to generate them. TreeBASE accepts all types of phylogenetic data (e.g., trees of species, trees of populations, trees of genes) representing all biotic taxa. Data in TreeBASE are exposed to the public if they are used in a publication that is in press or published in a peer-reviewed scientific journal, book, conference proceedings, or thesis. Data used in publications that are in preparation or in review can be submitted to TreeBASE but are only available to the publication editors or reviewers using a special access code. </p> <p>The current release includes a host of new features and improvements over the previous TreeBASE prototype. New features include:</p> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/matrixSimpleSearchForm.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/matrixSimpleSearchForm.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/matrixSimpleSearchForm.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -2,11 +2,6 @@ <form id="searchSimple" method="post"> <fieldset> Search: <input type="hidden" name="formName" value="matrixSimple"/> - <script type="text/javascript"> - //<![CDATA[ - TreeBASE.register( function() { $('keyword').focus(); } ); - //]]> - </script> <input type=text class="textCell" style="width:150px" name="searchTerm" id="keyword" value="${searchTerm}"/> <button type="submit" name="searchButton" value="matrixID">Matrix ID</button> <button type="submit" name="searchButton" value="matrixTitle">Title</button> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/searchResultsListControls.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -1,5 +1,5 @@ <%@ include file="/common/taglibs.jsp"%> -<script type="text/javascript" src="/treebase-web/scripts/prototype/prototype-1.6.0.3.js"></script> +<%-- script type="text/javascript" src="/treebase-web/scripts/prototype/prototype-1.6.0.3.js"></script --%> <c:if test="${! isEmpty }"> <script type="text/javascript"> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/studyKeywordSearchForm.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/studyKeywordSearchForm.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/studyKeywordSearchForm.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -2,11 +2,6 @@ <form id="searchSimple" method="post"> <fieldset> Search: <input type="hidden" name="formName" value="searchKeyword"/> - <script type="text/javascript"> - //<![CDATA[ - TreeBASE.register( function() { $('keyword').focus(); } ); - //]]> - </script> <input type="text" class="textCell" style="width:150px" name="searchTerm" id="keyword" value="${searchTerm}"/> <button type="submit" name="searchButton" value="studyID">Study ID</button> <button type="submit" name="searchButton" value="legacyStudyID">Legacy Study ID</button> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/treeSimpleSearchForm.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/treeSimpleSearchForm.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/search/treeSimpleSearchForm.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -1,12 +1,7 @@ <%@ include file="/common/taglibs.jsp"%> <form id="searchSimple" method="post"> <fieldset> - Search: <input type="hidden" name="formName" value="treeSimple"/> - <script type="text/javascript"> - //<![CDATA[ - TreeBASE.register( function() { $('keyword').focus(); } ); - //]]> - </script> + Search: <input type="hidden" name="formName" value="treeSimple"/> <input type="text" class="textCell" style="width:150px" name="searchTerm" id="keyword" value="${searchTerm}"/> <button type="submit" name="searchButton" value="treeID">Tree ID</button> <button type="submit" name="searchButton" value="treeTitle">Title</button> Modified: trunk/treebase-web/src/main/webapp/common/header.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/header.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/common/header.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -1,8 +1,17 @@ <%@ include file="/common/taglibs.jsp"%> -<h1> +<h1 style="padding-bottom:0px !important;margin-bottom:0px !important"> <a href="<c:url value="/home.html"/>"> - <img src="<c:url value="/images/logo.gif"/>" alt="TreeBase Logo" width="523" height="112" border="0" /> + <img + src="<c:url value="/images/logo.gif"/>" + alt="TreeBase Logo" + width="523" + height="112" + border="0" /> </a> + <img + src="<c:url value="/images/gradient.jpg"/>" + style="width:100%;height:10px;padding:0px !important;margin:0px !important" + height="10" + alt="" /> </h1> -<img src="images/gradient.jpg" style="width:100%;height:10px" alt="" /> Modified: trunk/treebase-web/src/main/webapp/common/meta.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/meta.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/common/meta.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -7,3 +7,22 @@ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta name="author" content="Rutger A. Vos (rut...@gm...)"/> <link rel="icon" href="<c:url value="/images/favicon.ico"/>"/> +<% + String ua = request.getHeader( "User-Agent" ); + boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 ); + boolean isOldMSIE = false; + if ( isMSIE ) { + isOldMSIE = ua.indexOf("MSIE 8.0") == -1; + + } +%> +<!-- <%= ua %> --> +<% if( isOldMSIE ){ %> + <script type="text/javascript"> + alert("Please upgrade your browser!\n\n"+ + "The TreeBASE team simply do not have the resources to support\n"+ + "old versions of Internet Explorer. There are many good, free\n"+ + "browsers available (IE8, FireFox, Safari, Chrome, Opera, etc.),\n"+ + "please use one of those instead."); + </script> +<% } %> \ No newline at end of file Modified: trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/decorators/defaultSearchTemplate.jsp 2010-03-23 18:15:11 UTC (rev 652) @@ -29,8 +29,9 @@ <script type="text/javascript" src="<c:url value='/dwr/engine.js'/>"> </script> <script type="text/javascript" src="<c:url value='/dwr/util.js'/>"></script> -<script type="text/javascript" src="<c:url value='/scripts/prototype/prototype.js'/>"></script> +<!-- script type="text/javascript" src="<c:url value='/scripts/prototype/prototype.js'/>"></script--> <script type="text/javascript" src="<c:url value='/scripts/prototype/prototype-1.6.0.3.js'/>"></script> +<!-- script type="text/javascript" src="<c:url value='/scripts/prototype/prototype-1.6.1.js'/>"></script--> <script type="text/javascript" src="<c:url value='/scripts/script.aculo.us/effects.js'/>"></script> <script type="text/javascript" src="<c:url value='/scripts/script.aculo.us/controls.js'/>"></script> Modified: trunk/treebase-web/src/main/webapp/scripts/common.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/common.js 2010-03-23 17:44:56 UTC (rev 651) +++ trunk/treebase-web/src/main/webapp/scripts/common.js 2010-03-23 18:15:11 UTC (rev 652) @@ -1,223 +1,224 @@ -var newwindow - -function popup_new_window(url) -{ - newwindow=window.open(url,'help','width=800,height=400,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); -} -function popup(url) { - if (newwindow) - newwindow.close(); - - newwindow=window.open(url,'help','width=600,height=400,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); - newwindow.moveTo(220, 100) -} -function popupWithSizes(url, width, height) { - if (newwindow) newwindow.close(); - newwindow=window.open(url,'help','width=' + width + ',height=' + height + ',scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); -} -function openHelp(tag) { - var url = '/treebase-web/help.html?helpTag=' + tag; - var req = new Ajax.Request(url, { - 'method':'get', - 'onSuccess':function(response){ - top.consoleRef=window.open('','help', - 'width=400,height=350' - +',menubar=no' - +',toolbar=no' - +',location=no' - +',status=no' - +',top=100' - +',left=100' - +',scrollbars=yes' - +',resizable=yes'); - if ( top.consoleRef == null || top.consoleRef.closed ) { - alert("Couldn't open window! The help system requires that popups are allowed for the TreeBASE site."); - } - top.consoleRef.document.writeln(response.responseText); - top.consoleRef.document.close(); - } - }); -} - -/* - The TreeBASE object has three functions: - 1. it provides for a way to scope our javascript code within the TreeBASE - namespace so it doesn't clash with all the other libraries we're using - 2. it allows you to register callbacks with it - 3. it implements a TreeBASE.initialize() method that executes those - registered callbacks. Typically we would call this from within the - body tag, i.e. <body onload="TreeBASE.initialize()"/>, as is done in the - main template. This allows us to write more unobtrusive javascript. -*/ -var TreeBASE = { - 'init' : [], - 'initialize' : function () { - for ( var i = 0; i < TreeBASE.init.length; i++ ) { - TreeBASE.init[i](); - } - }, - 'register' : function(func) { - TreeBASE.init.push(func); - } -}; - -/* - Here we register a function that fetches all table headers for columns that - contain icon buttons (i.e. of class "iconColumn"). It sets the background of - those header cells to pink, and places a link to the icon legend in the first - of these header cells. -*/ -TreeBASE.register( - function () { - var headers = document.getElementsByTagName('th'); - var iconColumnHeaders = new Array(); - for ( var i = 0; i < headers.length; i++ ) { - if ( headers[i].className == 'iconColumn' ) { - iconColumnHeaders.push(headers[i]); - } - } - if ( iconColumnHeaders.length > 0 ) { - iconColumnHeaders[0].innerHTML = '<a href="/treebase-web/help/iconLegend.jsp"><img src="/treebase-web/images/icons/help.png" class="iconButton" alt="Icon Legend" title="Icon Legend"/></a>'; - for ( var i = 0; i < iconColumnHeaders.length; i++ ) { - iconColumnHeaders[i].style.backgroundColor = 'pink'; - } - } - } -); - -/* - Here we register a function that fetches all input elements for text of class - "textCell", to which we add the following behaviours: - 1. onfocus (i.e. we click in the input) it selects the text it contains - 2. onfocus we change the border to soft blue - 3. onblur (i.e. we leave the input) we go back to the previous border -*/ -TreeBASE.register( - function() { - var inputs = $(document).getElementsByClassName('textCell'); - for ( var i = 0; i < inputs.length; i++ ) { - if ( inputs[i] ) { - var currentColor = inputs[i].style.borderColor; - inputs[i].onfocus = function () { - this.style.borderColor = '#3863A4'; - this.select(); - } - inputs[i].onblur = function () { - this.style.borderColor = currentColor; - } - } - } - } -); - -TreeBASE.register( - function () { - if ( document.getElementsByClassName ) { - var checkBoxCells = document.getElementsByClassName('checkBoxColumn'); - var buttonContainer = $('buttonContainer'); - if ( checkBoxCells.length > 0 && buttonContainer ) { - var checkButton = new Element('input',{'type':'button','value':'Check all'}); - checkButton.observe('click',function () { - for ( var i = 0; i < checkBoxCells.length; i++ ) { - if ( checkBoxCells[i] ) { - var checkBoxes = $(checkBoxCells[i]).select('input'); - for ( var j = 0; j < checkBoxes.length; j++ ) { - if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { - if ( ! checkBoxes[j].disabled ) { - checkBoxes[j].checked = 'checked'; - } - } - } - } - } - }); - var uncheckButton = new Element('input',{'type':'button','value':'Uncheck all'}); - uncheckButton.observe('click',function () { - for ( var i = 0; i < checkBoxCells.length; i++ ) { - if ( checkBoxCells[i] ) { - var checkBoxes = $(checkBoxCells[i]).select('input'); - for ( var j = 0; j < checkBoxes.length; j++ ) { - if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { - if ( ! checkBoxes[j].disabled ) { - checkBoxes[j].checked = null; - } - } - } - } - } - }); - var invertButton = new Element('input',{'type':'button','value':'Invert'}); - invertButton.observe('click',function () { - for ( var i = 0; i < checkBoxCells.length; i++ ) { - if ( checkBoxCells[i] ) { - var checkBoxes = $(checkBoxCells[i]).select('input'); - for ( var j = 0; j < checkBoxes.length; j++ ) { - if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { - if ( ! checkBoxes[j].disabled ) { - if ( checkBoxes[j].checked ) { - checkBoxes[j].checked = null; - } - else { - checkBoxes[j].checked = 'checked'; - } - } - } - } - } - } - }); - buttonContainer.insertBefore(invertButton,buttonContainer.firstChild); - buttonContainer.insertBefore(uncheckButton,buttonContainer.firstChild); - buttonContainer.insertBefore(checkButton,buttonContainer.firstChild); - } - } - } -); - -/* add a tooltip for the help buttons */ -TreeBASE.register( - function() { - var links = document.getElementsByTagName('a'); - for ( var i = 0; i < links.length; i++ ) { - var link = $(links[i]); - if ( link.hasClassName('openHelp') ) { - if ( link.title == null || link.title == '' ) { - link.title = 'Open help popup'; - } - } - } - } -); - -/* - Collapse/expands elements (identified by id), where - the expanded version is shown as 'displayAs' (i.e. - 'block' or 'inline'). This behaviour is added to - 'link', such that: - <a onclick="TreeBASE.collapseExpand('foo','block',this)"> - <img src="/treebase-web/images/plus.gif"/> - </a> - <div id="foo"> - <!-- this will be collapsed/expanded --> - </div> -*/ -TreeBASE.collapseExpand = function(id,displayAs,link) { - var objToExpand = $(id); - var img = $(link).firstDescendant(); - if ( img == null ) { - img = document.createElement(img); - link.appendChild(img); - } - if ( objToExpand.style.display == 'none' ) { - objToExpand.style.display = displayAs; - img.src='/treebase-web/images/minus.gif'; - img.alt='collapse' - link.title='collapse'; - } - else { - objToExpand.style.display = 'none'; - img.src='/treebase-web/images/plus.gif'; - img.alt='expand'; - link.title='expand'; - } -} +var newwindow + +function popup_new_window(url) +{ + newwindow=window.open(url,'help','width=800,height=400,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); +} +function popup(url) { + if (newwindow) + newwindow.close(); + + newwindow=window.open(url,'help','width=600,height=400,scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); + newwindow.moveTo(220, 100) +} +function popupWithSizes(url, width, height) { + if (newwindow) newwindow.close(); + newwindow=window.open(url,'help','width=' + width + ',height=' + height + ',scrollbars=yes,menubar=no,resizable=yes,toolbar=no,status=no'); +} +function openHelp(tag) { + var url = '/treebase-web/help.html?helpTag=' + tag; + var req = new Ajax.Request(url, { + 'method':'get', + 'onSuccess':function(response){ + top.consoleRef=window.open('','help', + 'width=400,height=350' + +',menubar=no' + +',toolbar=no' + +',location=no' + +',status=no' + +',top=100' + +',left=100' + +',scrollbars=yes' + +',resizable=yes'); + if ( top.consoleRef == null || top.consoleRef.closed ) { + alert("Couldn't open window! The help system requires that popups are allowed for the TreeBASE site."); + } + top.consoleRef.document.writeln(response.responseText); + top.consoleRef.document.close(); + } + }); +} + +/* + The TreeBASE object has three functions: + 1. it provides for a way to scope our javascript code within the TreeBASE + namespace so it doesn't clash with all the other libraries we're using + 2. it allows you to register callbacks with it + 3. it implements a TreeBASE.initialize() method that executes those + registered callbacks. Typically we would call this from within the + body tag, i.e. <body onload="TreeBASE.initialize()"/>, as is done in the + main template. This allows us to write more unobtrusive javascript. +*/ +var TreeBASE = { + 'init' : [], + 'initialize' : function () { + for ( var i = 0; i < TreeBASE.init.length; i++ ) { + TreeBASE.init[i](); + } + }, + 'register' : function(func) { + TreeBASE.init.push(func); + } +}; + +/* + Here we register a function that fetches all table headers for columns that + contain icon buttons (i.e. of class "iconColumn"). It sets the background of + those header cells to pink, and places a link to the icon legend in the first + of these header cells. +*/ +TreeBASE.register( + function () { + var headers = document.getElementsByTagName('th'); + var iconColumnHeaders = new Array(); + for ( var i = 0; i < headers.length; i++ ) { + if ( headers[i].className == 'iconColumn' ) { + iconColumnHeaders.push(headers[i]); + } + } + if ( iconColumnHeaders.length > 0 ) { + iconColumnHeaders[0].innerHTML = '<a href="/treebase-web/help/iconLegend.jsp"><img src="/treebase-web/images/icons/help.png" class="iconButton" alt="Icon Legend" title="Icon Legend"/></a>'; + for ( var i = 0; i < iconColumnHeaders.length; i++ ) { + iconColumnHeaders[i].style.backgroundColor = 'pink'; + } + } + } +); + +/* + Here we register a function that fetches all input elements for text of class + "textCell", to which we add the following behaviours: + 1. onfocus (i.e. we click in the input) it selects the text it contains + 2. onfocus we change the border to soft blue + 3. onblur (i.e. we leave the input) we go back to the previous border +*/ + +TreeBASE.register( + function() { + var inputs = $$('.textCell'); + for ( var i = 0; i < inputs.length; i++ ) { + if ( inputs[i] ) { + var currentColor = inputs[i].style.borderColor; + inputs[i].onfocus = function () { + this.style.borderColor = '#3863A4'; + this.select(); + } + inputs[i].onblur = function () { + this.style.borderColor = currentColor; + } + } + } + } +); + +TreeBASE.register( + function () { + if ( document.getElementsByClassName ) { + var checkBoxCells = $$('.checkBoxColumn'); + var buttonContainer = $('buttonContainer'); + if ( checkBoxCells.length > 0 && buttonContainer ) { + var checkButton = new Element('input',{'type':'button','value':'Check all'}); + checkButton.observe('click',function () { + for ( var i = 0; i < checkBoxCells.length; i++ ) { + if ( checkBoxCells[i] ) { + var checkBoxes = $(checkBoxCells[i]).select('input'); + for ( var j = 0; j < checkBoxes.length; j++ ) { + if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { + if ( ! checkBoxes[j].disabled ) { + checkBoxes[j].checked = 'checked'; + } + } + } + } + } + }); + var uncheckButton = new Element('input',{'type':'button','value':'Uncheck all'}); + uncheckButton.observe('click',function () { + for ( var i = 0; i < checkBoxCells.length; i++ ) { + if ( checkBoxCells[i] ) { + var checkBoxes = $(checkBoxCells[i]).select('input'); + for ( var j = 0; j < checkBoxes.length; j++ ) { + if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { + if ( ! checkBoxes[j].disabled ) { + checkBoxes[j].checked = null; + } + } + } + } + } + }); + var invertButton = new Element('input',{'type':'button','value':'Invert'}); + invertButton.observe('click',function () { + for ( var i = 0; i < checkBoxCells.length; i++ ) { + if ( checkBoxCells[i] ) { + var checkBoxes = $(checkBoxCells[i]).select('input'); + for ( var j = 0; j < checkBoxes.length; j++ ) { + if ( checkBoxes[j] && checkBoxes[j].type == 'checkbox' || checkBoxes[j].type == 'radio' ) { + if ( ! checkBoxes[j].disabled ) { + if ( checkBoxes[j].checked ) { + checkBoxes[j].checked = null; + } + else { + checkBoxes[j].checked = 'checked'; + } + } + } + } + } + } + }); + buttonContainer.insertBefore(invertButton,buttonContainer.firstChild); + buttonContainer.insertBefore(uncheckButton,buttonContainer.firstChild); + buttonContainer.insertBefore(checkButton,buttonContainer.firstChild); + } + } + } +); + +/* add a tooltip for the help buttons */ +TreeBASE.register( + function() { + var links = document.getElementsByTagName('a'); + for ( var i = 0; i < links.length; i++ ) { + var link = $(links[i]); + if ( link.hasClassName('openHelp') ) { + if ( link.title == null || link.title == '' ) { + link.title = 'Open help popup'; + } + } + } + } +); + +/* + Collapse/expands elements (identified by id), where + the expanded version is shown as 'displayAs' (i.e. + 'block' or 'inline'). This behaviour is added to + 'link', such that: + <a onclick="TreeBASE.collapseExpand('foo','block',this)"> + <img src="/treebase-web/images/plus.gif"/> + </a> + <div id="foo"> + <!-- this will be collapsed/expanded --> + </div> +*/ +TreeBASE.collapseExpand = function(id,displayAs,link) { + var objToExpand = $(id); + var img = $(link).firstDescendant(); + if ( img == null ) { + img = document.createElement(img); + link.appendChild(img); + } + if ( objToExpand.style.display == 'none' ) { + objToExpand.style.display = displayAs; + img.src='/treebase-web/images/minus.gif'; + img.alt='collapse' + link.title='collapse'; + } + else { + objToExpand.style.display = 'none'; + img.src='/treebase-web/images/plus.gif'; + img.alt='expand'; + link.title='expand'; + } +} Added: trunk/treebase-web/src/main/webapp/scripts/prototype/prototype-1.6.1.js =================================================================== --- trunk/treebase-web/src/main/webapp/scripts/prototype/prototype-1.6.1.js (rev 0) +++ trunk/treebase-web/src/main/webapp/scripts/prototype/prototype-1.6.1.js 2010-03-23 18:15:11 UTC (rev 652) @@ -0,0 +1,4874 @@ +/* Prototype JavaScript framework, version 1.6.1 + * (c) 2005-2009 Sam Stephenson + * + * Prototype is freely distributable under the terms of an MIT-style license. + * For details, see the Prototype web site: http://www.prototypejs.org/ + * + *--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.6.1', + + Browser: (function(){ + var ua = navigator.userAgent; + var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]'; + return { + IE: !!window.attachEvent && !isOpera, + Opera: isOpera, + WebKit: ua.indexOf('AppleWebKit/') > -1, + Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1, + MobileSafari: /Apple.*Mobile.*Safari/.test(ua) + } + })(), + + BrowserFeatures: { + XPath: !!document.evaluate, + SelectorsAPI: !!document.querySelector, + ElementExtensions: (function() { + var constructor = window.Element || window.HTMLElement; + return !!(constructor && constructor.prototype); + })(), + SpecificElementExtensions: (function() { + if (typeof window.HTMLDivElement !== 'undefined') + return true; + + var div = document.createElement('div'); + var form = document.createElement('form'); + var isSupported = false; + + if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) { + isSupported = true; + } + + div = form = null; + + return isSupported; + })() + }, + + ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, + + emptyFunction: function() { }, + K: function(x) { return x } +}; + +if (Prototype.Browser.MobileSafari) + Prototype.BrowserFeatures.SpecificElementExtensions = false; + + +var Abstract = { }; + + +var Try = { + these: function() { + var returnValue; + + for (var i = 0, length = arguments.length; i < length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) { } + } + + return returnValue; + } +}; + +/* Based on Alex Arnell's inheritance implementation. */ + +var Class = (function() { + function subclass() {}; + function create() { + var parent = null, properties = $A(arguments); + if (Object.isFunction(properties[0])) + parent = properties.shift(); + + function klass() { + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + for (var i = 0; i < properties.length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) + klass.prototype.initialize = Prototype.emptyFunction; + + klass.prototype.constructor = klass; + return klass; + } + + function addMethods(source) { + var ancestor = this.superclass && this.superclass.prototype; + var properties = Object.keys(source); + + if (!Object.keys({ toString: true }).length) { + if (source.toString != Object.prototype.toString) + properties.push("toString"); + if (source.valueOf != Object.prototype.valueOf) + properties.push("valueOf"); + } + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && Object.isFunction(value) && + value.argumentNames().first() == "$super") { + var method = value; + value = (function(m) { + return function() { return ancestor[m].apply(this, arguments); }; + })(property).wrap(method); + + value.valueOf = method.valueOf.bind(method); + value.toString = method.toString.bind(method); + } + this.prototype[property] = value; + } + + return this; + } + + return { + create: create, + Methods: { + addMethods: addMethods + } + }; +})(); +(function() { + + var _toString = Object.prototype.toString; + + function extend(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; + } + + function inspect(object) { + try { + if (isUndefined(object)) return 'undefined'; + if (object === null) return 'null'; + return object.inspect ? object.inspect() : String(object); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } + } + + function toJSON(object) { + var type = typeof object; + switch (type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (isElement(object)) return; + + var results = []; + for (var property in object) { + var value = toJSON(object[property]); + if (!isUndefined(value)) + results.push(property.toJSON() + ': ' + value); + } + + return '{' + results.join(', ') + '}'; + } + + function toQueryString(object) { + return $H(object).toQueryString(); + } + + function toHTML(object) { + return object && object.toHTML ? object.toHTML() : String.interpret(object); + } + + function keys(object) { + var results = []; + for (var property in object) + results.push(property); + return results; + } + + function values(object) { + var results = []; + for (var property in object) + results.push(object[property]); + return results; + } + + function clone(object) { + return extend({ }, object); + } + + function isElement(object) { + return !!(object && object.nodeType == 1); + } + + function isArray(object) { + return _toString.call(object) == "[object Array]"; + } + + + function isHash(object) { + return object instanceof Hash; + } + + function isFunction(object) { + return typeof object === "function"; + } + + function isString(object) { + return _toString.call(object) == "[object String]"; + } + + function isNumber(object) { + return _toString.call(object) == "[object Number]"; + } + + function isUndefined(object) { + return typeof object === "undefined"; + } + + extend(Object, { + extend: extend, + inspect: inspect, + toJSON: toJSON, + toQueryString: toQueryString, + toHTML: toHTML, + keys: keys, + values: values, + clone: clone, + isElement: isElement, + isArray: isArray, + isHash: isHash, + isFunction: isFunction, + isString: isString, + isNumber: isNumber, + isUndefined: isUndefined + }); +})(); +Object.extend(Function.prototype, (function() { + var slice = Array.prototype.slice; + + function update(array, args) { + var arrayLength = array.length, length = args.length; + while (length--) array[arrayLength + length] = args[length]; + return array; + } + + function merge(array, args) { + array = slice.call(array, 0); + return update(array, args); + } + + function argumentNames() { + var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1] + .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '') + .replace(/\s+/g, '').split(','); + return names.length == 1 && !names[0] ? [] : names; + } + + function bind(context) { + if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; + var __method = this, args = slice.call(arguments, 1); + return function() { + var a = merge(args, arguments); + return __method.apply(context, a); + } + } + + function bindAsEventListener(context) { + var __method = this, args = slice.call(arguments, 1); + return function(event) { + var a = update([event || window.event], args); + return __method.apply(context, a); + } + } + + function curry() { + if (!arguments.length) return this; + var __method = this, args = slice.call(arguments, 0); + return function() { + var a = merge(args, arguments); + return __method.apply(this, a); + } + } + + function delay(timeout) { + var __method = this, args = slice.call(arguments, 1); + timeout = timeout * 1000 + return window.setTimeout(function() { + return __method.apply(__method, args); + }, timeout); + } + + function defer() { + var args = update([0.01], arguments); + return this.delay.apply(this, args); + } + + function wrap(wrapper) { + var __method = this; + return function() { + var a = update([__method.bind(this)], arguments); + return wrapper.apply(this, a); + } + } + + function methodize() { + if (this._methodized) return this._methodized; + var __method = this; + return this._methodized = function() { + var a = update([this], arguments); + return __method.apply(null, a); + }; + } + + return { + argumentNames: argumentNames, + bind: bind, + bindAsEventListener: bindAsEventListener, + curry: curry, + delay: delay, + defer: defer, + wrap: wrap, + methodize: methodize + } +})()); + + +Date.prototype.toJSON = function() { + return '"' + this.getUTCFullYear() + '-' + + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + + this.getUTCDate().toPaddedString(2) + 'T' + + this.getUTCHours().toPaddedString(2) + ':' + + this.getUTCMinutes().toPaddedString(2) + ':' + + this.getUTCSeconds().toPaddedString(2) + 'Z"'; +}; + + +RegExp.prototype.match = RegExp.prototype.test; + +RegExp.escape = function(str) { + return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); +}; +var PeriodicalExecuter = Class.create({ + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + execute: function() { + this.callback(this); + }, + + stop: function() { + if (!this.timer) return; + clearInterval(this.timer); + this.timer = null; + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.execute(); + this.currentlyExecuting = false; + } catch(e) { + this.currentlyExecuting = false; + throw e; + } + } + } +}); +Object.extend(String, { + interpret: function(value) { + return value == null ? '' : String(value); + }, + specialChar: { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '\\': '\\\\' + } +}); + +Object.extend(String.prototype, (function() { + + function prepareReplacement(replacement) { + if (Object.isFunction(replacement)) return replacement; + var template = new Template(replacement); + return function(match) { return template.evaluate(match) }; + } + + function gsub(pattern, replacement) { + var result = '', source = this, match; + replacement = prepareReplacement(replacement); + + if (Object.isString(pattern)) + pattern = RegExp.escape(pattern); + + if (!(pattern.length || pattern.source)) { + replacement = replacement(''); + return replacement + source.split('').join(replacement) + replacement; + } + + while (source.length > 0) { + if (match = source.match(pattern)) { + result += source.slice(0, match.index); + result += String.interpret(replacement(match)); + source = source.slice(match.index + match[0].length); + } else { + result += source, source = ''; + } + } + return result; + } + + function sub(pattern, replacement, count) { + replacement = prepareReplacement(replacement); + count = Object.isUndefined(count) ? 1 : count; + + return this.gsub(pattern, function(match) { + if (--count < 0) return match[0]; + return replacement(match); + }); + } + + function scan(pattern, iterator) { + this.gsub(pattern, iterator); + return String(this); + } + + function truncate(length, truncation) { + length = length || 30; + truncation = Object.isUndefined(truncation) ? '...' : truncation; + return this.length > length ? + this.slice(0, length - truncation.length) + truncation : String(this); + } + + function strip() { + return this.replace(/^\s+/, '').replace(/\s+$/, ''); + } + + function stripTags() { + return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, ''); + } + + function stripScripts() { + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); + } + + function extractScripts() { + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); + return (this.match(matchAll) || []).map(function(scriptTag) { + return (scriptTag.match(matchOne) || ['', ''])[1]; + }); + } + + function evalScripts() { + return this.extractScripts().map(function(script) { return eval(script) }); + } + + function escapeHTML() { + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + } + + function unescapeHTML() { + return this.stripTags().replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); + } + + + function toQueryParams(separator) { + var match = this.strip().match(/([^?#]*)(#.*)?$/); + if (!match) return { }; + + return match[1].split(separator || '&').inject({ }, function(hash, pair) { + if ((pair = pair.split('='))[0]) { + var key = decodeURIComponent(pair.shift()); + var value = pair.length > 1 ? pair.join('=') : pair[0]; + if (value != undefined) value = decodeURIComponent(value); + + if (key in hash) { + if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; + hash[key].push(value); + } + else hash[key] = value; + } + return hash; + }); + } + + function toArray() { + return this.split(''); + } + + function succ() { + return this.slice(0, this.length - 1) + + String.fromCharCode(this.charCodeAt(this.length - 1) + 1); + } + + function times(count) { + return count < 1 ? '' : new Array(count + 1).join(this); + } + + function camelize() { + var parts = this.split('-'), len = parts.length; + if (len == 1) return parts[0]; + + var camelized = this.charAt(0) == '-' + ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) + : parts[0]; + + for (var i = 1; i < len; i++) + camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); + + return camelized; + } + + function capitalize() { + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); + } + + function underscore() { + return this.replace(/::/g, '/') + .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') + .replace(/([a-z\d])([A-Z])/g, '$1_$2') + .replace(/-/g, '_') + .toLowerCase(); + } + + function dasherize() { + return this.replace(/_/g, '-'); + } + + function inspect(useDoubleQuotes) { + var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) { + if (character in String.specialChar) { + return String.specialChar[character]; + } + return '\\u00' + character.charCodeAt().toPaddedString(2, 16); + }); + if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; + return "'" + escapedString.replace(/'/g, '\\\'') + "'"; + } + + function toJSON() { + return this.inspect(true); + } + + function unfilterJSON(filter) { + return this.replace(filter || Prototype.JSONFilter, '$1'); + } + + function isJSON() { + var str = this; + if (str.blank()) return false; + str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); + } + + function evalJSON(sanitize) { + var json = this.unfilterJSON(); + try { + if (!sanitize || json.isJSON()) return eval('(' + json + ')'); + } catch (e) { } + throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); + } + + function include(pattern) { + return this.indexOf(pattern) > -1; + } + + function startsWith(pattern) { + return this.indexOf(pattern) === 0; + } + + function endsWith(pattern) { + var d = this.length - pattern.length; + return d >= 0 && this.lastIndexOf(pattern) === d; + } + + function empty() { + return this == ''; + } + + function blank() { + return /^\s*$/.test(this); + } + + function interpolate(object, pattern) { + return new Template(this, pattern).evaluate(object); + } + + return { + gsub: gsub, + sub: sub, + scan: scan, + truncate: truncate, + strip: String.prototype.trim ? String.prototype.trim : strip, + stripTags: stripTags, + stripScripts: stripScripts, + extractScripts: extractScripts, + evalScripts: evalScripts, + escapeHTML: escapeHTML, + unescapeHTML: unescapeHTML, + toQueryParams: toQueryParams, + parseQuery: toQueryParams, + toArray: toArray, + succ: succ, + times: times, + camelize: camelize, + capitalize: capitalize, + underscore: underscore, + dasherize: dasherize, + inspect: inspect, + toJSON: toJSON, + unfilterJSON: unfilterJSON, + isJSON: isJSON, + evalJSON: evalJSON, + include: include, + startsWith: startsWith, + endsWith: endsWith, + empty: empty, + blank: blank, + interpolate: interpolate + }; +})()); + +var Template = Class.create({ + initialize: function(template, pattern) { + this.template = template.toString(); + this.pattern = pattern || Template.Pattern; + }, + + evaluate: function(object) { + if (object && Object.isFunction(object.toTemplateReplacements)) + object = object.toTemplateReplacements(); + + return this.template.gsub(this.pattern, function(match) { + if (object == null) return (match[1] + ''); + + var before = match[1] || ''; + if (before == '\\') return match[2]; + + var ctx = object, expr = match[3]; + var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; + match = pattern.exec(expr); + if (match == null) return before; + + while (match != null) { + var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1]; + ctx = ctx[comp]; + if (null == ctx || '' == match[3]) break; + expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); + match = pattern.exec(expr); + } + + return before + String.interpret(ctx); + }); + } +}); +Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; + +var $break = { }; + +var Enumerable = (function() { + function each(iterator, context) { + var index = 0; + try { + this._each(function(value) { + iterator.call(context, value, index++); + }); + } catch (e) { + if (e != $break) throw e; + } + return this; + } + + function eachSlice(number, iterator, context) { + var index = -number, slices = [], array = this.toArray(); + if (number < 1) return array; + while ((index += number) < array.length) + slices.push(array.slice(index, index+number)); + return slices.collect(iterator, context); + } + + function all(iterator, context) { + iterator = iterator || Prototype.K; + var result = true; + this.each(function(value, index) { + result = result && !!iterator.call(context, value, index); + if (!result) throw $break; + }); + return result; + } + + function any(iterator, context) { + iterator = iterator || Prototype.K; + var result = false; + this.each(function(value, index) { + if (result = !!iterator.call(context, value, index)) + throw $break; + }); + return result; + } + + function collect(iterator, context) { + iterator = iterator || Prototype.K; + var results = []; + this.each(function(value, index) { + results.push(iterator.call(context, value, index)); + }); + return results; + } + + function detect(iterator, context) { + var result; + this.each(function(value, index) { + if (iterator.call(context, value, index)) { + result = value; + throw $break; + } + }); + return result; + } + + function findAll(iterator, context) { + var results = []; + this.each(function(value, index) { + if (iterator.call(context, value, index)) + results.push(value); + }); + return results; + } + + function grep(filter, iterator, context) { + iterator = iterator || Prototype.K; + var results = []; + + if (Object.isString(filter)) + filter = new RegExp(RegExp.escape(filter)); + + this.each(function(value, index) { + if (filter.match(value)) + results.push(iterator.call(context, value, index)); + }); + return results; + } + + function include(object) { + if (Object.isFunction(this.indexOf)) + if (this.indexOf(object) != -1) return true; + + var found = false; + this.each(function(value) { + if (value == object) { + found = true; + throw $break; + } + }); + return found; + } + + function inGroupsOf(number, fillWith) { + fillWith = Object.isUndefined(fillWith) ? null : fillWith; + return this.eachSlice(number, function(slice) { + while(slice.length < number) slice.push(fillWith); + return slice; + }); + } + + function inject(memo, iterator, context) { + this.each(function(value, index) { + memo = iterator.call(context, memo, value, index); + }); + return memo; + } + + function invoke(method) { + var args = $A(arguments).slice(1); + return this.map(function(value) { + return value[method].apply(value, args); + }); + } + + function max(iterator, context) { + iterator = iterator || Prototype.K; + var result; + this.each(function(value, index) { + value = iterator.call(context, value, index); + if (result == null || value >= result) + result = value; + }); + return result; + } + + function min(iterator, context) { + iterator = iterator || Prototype.K; + var result; + this.each(function(value, index) { + value = iterator.call(context, value, index); + if (result == null || value < result) + result = value; + }); + return result; + } + + function partition(iterator, context) { + iterator = iterator || Prototype.K; + var trues = [], falses = []; + this.each(function(value, index) { + (iterator.call(context, value, index) ? + trues : falses).push(value); + }); + return [trues, falses]; + } + + function pluck(property) { + var results = []; + this.each(function(value) { + results.push(value[property]); + }); + return results; + } + + function reject(iterator, context) { + var results = []; + this.each(function(value, index) { + if (!iterator.call(context, value, index)) + results.push(value); + }); + return results; + } + + function sortBy(iterator, context) { + return this.map(function(value, index) { + return { + value: value, + criteria: iterator.call(context, value, index) + }; + }).sort(function(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }).pluck('value'); + } + + function toArray() { + return this.map(); + } + + function zip() { + var iterator = Prototype.K, args = $A(arguments); + if (Object.isFunction(args.last())) + iterator = args.pop(); + + var collections = [this].concat(args).map($A); + return this.map(function(value, index) { + return iterator(collections.pluck(index)); + }); + } + + function size() { + return this.toArray().length; + } + + function inspect() { + return '#<Enumerable:' + this.toArray().inspect() + '>'; + } + + + + + + + + + + return { + each: each, + eachSlice: eachSlice, + all: all, + every: all, + any: any, + some: any, + collect: collect, + map: collect, + detect: detect, + findAll: findAll, + select: findAll, + filter: findAll, + grep: grep, + include: include, + member: include, + inGroupsOf: inGroupsOf, + inject: inject, + invoke: invoke, + max: max, + min: min, + partition: partition, + pluck: pluck, + reject: reject, + sortBy: sortBy, + toArray: toArray, + entries: toArray, + zip: zip, + size: size, + inspect: inspect, + find: detect + }; +})(); +function $A(iterable) { + if (!iterable) return []; + if ('toArray' in Object(iterable)) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; +} + +function $w(string) { + if (!Object.isString(string)) return []; + string = string.strip(); + return string ? string.split(/\s+/) : []; +} + +Array.from = $A; + + +(function() { + var arrayProto = Array.prototype, + slice = arrayProto.slice, + _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available + + function each(iterator) { + for (var i = 0, length = this.length; i < length; i++) + iterator(this[i]); + } + if (!_each) _each = each; + + function clear() { + this.length = 0; + return this; + } + + function first() { + return this[0]; + } + + function last() { + return this[this.length - 1]; + } + + function compact() { + return this.select(function(value) { + return value != null; + }); + } + + function flatten() { + return this.inject([], function(array, value) { + if (Object.isArray(value)) + return array.concat(value.flatten()); + array.push(value); + return array; + }); + } + + function without() { + var values = slice.call(arguments, 0); + return this.select(function(value) { + return !values.include(value); + }); + } + + function reverse(inline) { + return (inline !== false ? this : this.toArray())._reverse(); + } + + function uniq(sorted) { + return this.inject([], function(array, value, index) { + if (0 == index || (sorted ? array.last() != value : !array.include(value))) + array.push(value); + return array; + }); + } + + function intersect(array) { + return this.uniq().findAll(function(item) { + return array.detect(function(value) { return item === value }); + }); + } + + + function clone() { + return slice.call(this, 0); + } + + function size() { + return this.length; + } + + function inspect() { + return '[' + this.map(Object.inspect).join(', ') + ']'; + } + + function toJSON() { + var results = []; + this.each(function(object) { + var value = Object.toJSON(object); + if (!Object.isUndefined(value)) results.push(value); + }); + return '[' + results.join(', ') + ']'; + } + + function indexOf(item, i) { + i || (i = 0); + var length = this.length; + if (i < 0) i = length + i; + for (; i < length; i++) + if (this[i] === item) return i; + return -1; + } + + function lastIndexOf(item, i) { + i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; + var n = this.slice(0, i).reverse().indexOf(item); + return (n < 0) ? n : i - n - 1; + } + + function concat() { + var array = slice.call(this, 0), item; + for (var i = 0, length = arguments.length; i < length; i++) { + item = arguments[i]; + if (Object.isArray(item) && !('callee' in item)) { + for (var j = 0, arrayLength = item.length; j < arrayLength; j++) + array.push(item[j]); + } else { + array.push(item); + } + } + return array; + } + + Object.extend(arrayProto, Enumerable); + + if (!arrayProto._reverse) + arrayProto._reverse = arrayProto.reverse; + + Object.extend(arrayProto, { + _each: _each, + clear: clear, + first: first, + last: last, + compact: compact, + flatten: flatten, + without: without, + reverse: reverse, + uniq: uniq, + intersect: intersect, + clone: clone, + toArray: clone, + size: size, + inspect: inspect, + toJSON: toJSON + }); + + var CONCAT_ARGUMENTS_BUGGY = (function() { + return [].concat(arguments)[0][0] !== 1; + })(1,2) + + if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat; + + if (!arrayProto.indexOf) arrayProto.indexOf = indexOf; + if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf; +})(); +function $H(object) { + return new Hash(object); +}; + +var Hash = Class.create(Enumerable, (function() { + function initialize(object) { + this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); + } + + function _each(iterator) { + for (var key in this._object) { + var value = this._object[key], pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } + } + + function set(key, value) { + return this._object[key] = value; + } + + function get(key) { + if (this._object[key] !== Object.prototype[key]) + return this._object[key]; + } + + function unset(key) { + var value = this._object[key]; + delete this._object[key]; + return value; + } + + function toObject() { + return Object.clone(this._object); + } + + function keys() { + return this.pluck('key'); + } + + function values() { + return this.pluck('value'); + } + + function index(value) { + var match = this.detect(function(pair) { + return pair.value === value; + }); + return match && match.key; + } + + function merge(object) { + return this.clone().update(object); + } + + function update(object) { + return new Hash(object).inject(this, function(result, pair) { + result.set(pair.key, pair.value); + return result; + }); + } + + function toQueryPair(key, value) { + if (Object.isUndefined(value)) return key; + return key + '=' + encodeURIComponent(String.interpret(value)); + } + + function toQueryString() { + return this.inject([], function(results, pair) { + var key = encodeURIComponent(pair.key), values = pair.value; + + if (values && typeof values == 'object') { + if (Object.isArray(values)) + return results.concat(values.map(toQueryPair.curry(key))); + } else results.push(toQueryPair(key, values)); + return results; + }).join('&'); + } + + function inspect() { + return '#<Hash:{' + this.map(function(pair) { + return pair.map(Object.inspect).join(': '); + }).join(', ') + '}>'; + } + + function toJSON() { + return Object.toJSON(this.toObject()); + } + + function clone() { + return new Hash(this); + } + + return { + initialize: initialize, + _each: _each, + set: set, + get: get, + unset: unset, + toObject: toObject, + toTemplateReplacements: toObject, + keys: keys, + values: values, + index: index, + merge: merge, + update: update, + toQueryString: toQueryString, + inspect: inspect, + toJSON: toJSON, + clone: clone + }; +})()); + +Hash.from = $H; +Object.extend(Number.prototype, (function() { + function toColorPart() { + return this.toPaddedString(2, 16); + } + + function succ() { + return this + 1; + } + + function times(iterator, context) { + $R(0, this, true).each(iterator, context); + return this; + } + + function toPaddedString(length, radix) { + var string = this.toString(radix || 10); + return '0'.times(length - string.length) + string; + } + + function toJSON() { + return isFinite(this) ? this.toString() : 'null'; + } + + function abs() { + return Math.abs(this); + } + + function round() { + return Math.round(this); + } + + function ceil() { + return Math.ceil(this); + } + + function floor() { + return Math.floor(this); + } + + return { + toColorPart: toColorPart, + succ: succ, + times: times, + toPaddedString: toPaddedString, + toJSON: toJSON, + abs: abs, + round: round, + ceil: ceil, + floor: floor + }; +})()); + +function $R(start, end, exclusive) { + return new ObjectRange(start, end, exclusive); +} + +var O... [truncated message content] |