Login | Register
My pages Projects Community openCollabNet

Discussions > commits > [WebSVN commit] svn commit: r1280 - trunk: . include javascript templates/BlueGrey templates/calm

websvn
Discussion topic

Back to topic list

[WebSVN commit] svn commit: r1280 - trunk: . include javascript templates/BlueGrey templates/calm

Reply

Author quinntaylor
Full name Quinn Taylor
Date 2012-01-19 10:48:13 PST
Message Author: quinntaylor
Date: 2012-01-19 10:48:13-0800
New Revision: 1280

Added:
   trunk/javascript/com​pare-checkboxes.js (contents, props changed)
Modified:
   trunk/include/template.php
   trunk/listing.php
   trunk/log.php
   trunk/templates/Blue​Grey/header.tmpl
   trunk/templates/calm​/header.tmpl

Log:
Consolidated duplicate code for only allowing two compare checkboxes to be selected into a shared script loaded only for directory and log listings. (This behavior was missing in the Elegant template.)

Modified: trunk/include/template.php
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/include/​template.php?view=di​ff&pathrev=1280​&r1=1279&r2=1​280
====================​====================​====================​==================
--- trunk/include/template.php (original)
+++ trunk/include/template.php 2012-01-19 10:48:13-0800
@@ -264,7 +264,7 @@
 // Renders the templates for the given view
 
 function renderTemplate($view) {
- global $config, $rep, $vars, $listing, $lang;
+ global $config, $rep, $vars, $listing, $lang, $locwebsvnhttp;
 
     // Set the view in the templates variables
     $vars['template'] = $view;
@@ -279,6 +279,9 @@
         parseTemplate('header.tmpl');
         flush(); // http://developer.yah​oo.com/performance/r​ules.html#flush
         parseTemplate($view . '.tmpl');
+ if ($view === 'directory' || $view === 'log') {
+ print '<script type="text/javascript" src="'.$locwebsvnht​tp.'/javascript/comp​are-checkboxes.js"​></script>';
+ }
         parseTemplate('footer.tmpl');
     }
 }

Added: trunk/javascript/com​pare-checkboxes.js
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/javascri​pt/compare-checkboxe​s.js?view=markup​&pathrev=1280
====================​====================​====================​==================
--- (empty file)
+++ trunk/javascript/com​pare-checkboxes.js 2012-01-19 10:48:13-0800
@@ -0,0 +1,18 @@
+// Enforce only two compare boxes being checked at once.
+function enforceOnlyTwoChecke​d(clickedCheckbox) {
+ count = 0;
+ first = null;
+ form = clickedCheckbox.form;
+ for (i = 0; i < form.elements.length; i++) {
+ if (form.elements[i].type == 'checkbox' && form.elements[i].checked) {
+ if (first == null && form.elements[i] != clickedCheckbox) {
+ first = form.elements[i];
+ }
+ count += 1;
+ }
+ }
+ if (count > 2) {
+ first.checked = false;
+ count -= 1;
+ }
+}

Modified: trunk/listing.php
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/listing.​php?view=diff&pa​threv=1280&r1=12​79&r2=1280
====================​====================​====================​==================
--- trunk/listing.php (original)
+++ trunk/listing.php 2012-01-19 10:48:13-0800
@@ -139,7 +139,7 @@
                 }
 
                 if ($treeview) {
- $listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$path.$fi​le.'@'.$passrev.'" onclick="checkCB(this)" />';
+ $listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$path.$fi​le.'@'.$passrev.'" onclick="enforceOnly​TwoChecked(this)" />';
                 }
                 if ($config->showLa​stModInListing()) {
                     $listvar['committime'] = $entry->committime;

Modified: trunk/log.php
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/log.php?​view=diff&pathre​v=1280&r1=1279​&r2=1280
====================​====================​====================​==================
--- trunk/log.php (original)
+++ trunk/log.php 2012-01-19 10:48:13-0800
@@ -294,7 +294,7 @@
                 $compareValue = (($isDir) ? $parent : $rpath).'@'.$thisrev;
 
                 $listvar = &$listing[$index];
- $listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$compareValue.'" onclick="checkCB(this)" />';
+ $listvar['compare_box'] = '<input type="checkbox" name="compare[]" value="'.$compareValue.'" onclick="enforceOnly​TwoChecked(this)" />';
                 $url = $config->getURL($rep, $rpath, 'revision').$thisRevString;
                 $listvar['revlink'] = '<a href="'.$url.'">​'.$thisrev.'</a​>';
 

Modified: trunk/templates/Blue​Grey/header.tmpl
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/template​s/BlueGrey/header.tm​pl?view=diff&pat​hrev=1280&r1=127​9&r2=1280
====================​====================​====================​==================
--- trunk/templates/Blue​Grey/header.tmpl (original)
+++ trunk/templates/Blue​Grey/header.tmpl 2012-01-19 10:48:13-0800
@@ -40,25 +40,6 @@
   <!--[if lt IE 7]>
   <script type="text/javascript" src="[websvn:locwebs​vnhttp]/templates/Bl​ueGrey/png.js">​</script>
   <![endif]-->
- <script type="text/javascript">
- //<![CDATA[
- function checkCB(chBox) {
- count = 0;
- first = null;
- f = chBox.form;
- for (i = 0 ; i < f.elements.length ; i++)
- if (f.elements[i].type == 'checkbox' && f.elements[i].checked) {
- if (first == null && f.elements[i] != chBox)
- first = f.elements[i];
- count += 1;
- }
- if (count > 2) {
- first.checked = false;
- count -= 1;
- }
- }
- //]]>
- </script>
 </head>
 <body id="[websvn:template]">
   <div id="header">

Modified: trunk/templates/calm​/header.tmpl
Url: http://websvn.tigris​.org/source/browse/w​ebsvn/trunk/template​s/calm/header.tmpl?v​iew=diff&pathrev​=1280&r1=1279​&r2=1280
====================​====================​====================​==================
--- trunk/templates/calm​/header.tmpl (original)
+++ trunk/templates/calm​/header.tmpl 2012-01-19 10:48:13-0800
@@ -45,34 +45,6 @@
          [websvn-endtest]
        [websvn-endtest]
   </title>
- <script type="text/javascript">
- //<![CDATA[
- function getPath()
- {
- return '[websvn:locwebsvnhttp]';
- }
-
- function checkCB(chBox)
- {
- count = 0
- first = null
- f = chBox.form
- for (i = 0 ; i < f.elements.length ; i++)
- if (f.elements[i].type == 'checkbox' && f.elements[i].checked)
- {
- if (first == null && f.elements[i] != chBox)
- first = f.elements[i]
- count += 1
- }
-
- if (count > 2)
- {
- first.checked = false
- count -= 1
- }
- }
- //]]>
- </script>
 </head>
 <body id="[websvn:template]">
 <div id="container">

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

[WebSVN commit] svn commit: r1280 - trunk: . include javascript templates/BlueGrey templates/calm quinntaylor Quinn Taylor 2012-01-19 10:48:13 PST
Messages per page: