Revision: 1796
Author: andreassolberg
Date: Mon Sep 28 08:19:51 2009
Log: Major update to discopower module.. improved ui with live search.
http://code.google.com/p/simplesamlphp/source/detail?r=1796

Added:
  /trunk/modules/discopower/www/icons
  /trunk/modules/discopower/www/icons/arrow_right.png
  /trunk/modules/discopower/www/icons/heart.png
  /trunk/modules/discopower/www/icons/magnify.png
  /trunk/modules/discopower/www/icons/star.png
  /trunk/modules/discopower/www/js
  /trunk/modules/discopower/www/js/jquery.livesearch.js
  /trunk/modules/discopower/www/js/quicksilver.js
  /trunk/modules/discopower/www/style.css
Modified:
  /trunk/modules/discopower/dictionaries/tabs.php
  /trunk/modules/discopower/lib/PowerIdPDisco.php
  /trunk/modules/discopower/templates/disco-tpl.php

=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/icons/arrow_right.png Mon Sep 28 08:19:51  
2009
@@ -0,0 +1,11 @@
+‰PNG
+ 
+   
+IHDR              óÿa    tEXtSoftware Adobe  
ImageReadyqÉe<   +IDATxÚ”“[Rƒ0 † :XG à Ú -Þ6á³OîÍ-¸  
+ŸÝˆ—ZuèEl(i ’’Ð š Ú  Bþä|srÈqnï
+P!¹  M  ¨QàŸ”A» ..ÏÑ­€4  åg¹YvÚ
+"6ÃÙi êÛ qÕëæúJOî ŸV ÊKÄ/&     á› ‚À‡” Ïo ²\ 
+è ˜‘Ú oL„ŽßÒ —Þç
+¢ D ؼa$Ðny òúþ¥! @X  Oi ûÇÞ 2™¡× e HÉ X¼¥Â1APº®Á. ( F &,Æú [Ö@)Š â)Çß"n™ ‹9 
.`üÆpøcž3÷ö›.  öô| 
šß‡™H ¾p74Šöò Ùt
+ðüBQšY›Ê­ë
+„ ŠX{GÖ6SU°Ò\€  &¹ž‡" :ì    IEND®B`‚
=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/icons/heart.png       Mon Sep 28 08:19:51 2009
@@ -0,0 +1,19 @@
+‰PNG
+ 
+   
+IHDR              óÿa    tEXtSoftware Adobe ImageReadyqÉe<   
+IDATxÚ¤’½rÓ@ ÇW'9(‰e EN&þ(`  ¸¤LÃ+@ ™¡óK¤cèhy :
+ ä  á  Kâ™LÂW,› 
+ ’c'–twì®- &1 hFÒ þûûïj÷ ­5üÏeÑã]óþvbˆV"Ä5Úç”ú˜Óêù öÎÓ éÆÛ ÷¶Ï
+ùx³Ñ°
+ß ª'  àëÞÞ¹­ä  H÷o7ìUÏcýôd ÃN‡u‹œ      öª5ˆƒ. x•*½í“ÝÝ   ì–ËpÖ=fÝÁX¥Á
+uö[V"ŒëNi át ¡ ñVPœ Õ ÷ 
+G!ë
+Ëë% "Ë= FÊ$a‘Öq Aª Áñ| 
P˜sBp Îâ(>ž‚© 71Œ§Ó«V> j2¦¬ˆhHÑDý Ù`V ðš†f \Hâ˜øP )_ { ˜k>H %Á”  
 C ¨4 WÙZ)XZóàôK „T¯ÄV{§9  v´ü  )6˜Ý鼂t¾Ïml@ '0î÷a«ýò¡à
+¤é³o Þƒ‰c4
+
+K³Rc
+ë &‰> b†X#;‰o
+5µ[©€ ó Œ l þ¿œ7•ŒL· +µ „‡‡0Áòï¾h ĉìHÒ‡°×ƒï  p¥\ á 8«ü W/À T ]TI
+ç^¬ß€Q·K# e„£££ 𥠙É*š êu
+ßh ¼Ð 3YÙ,óÑ=[ ÿÕ 3Éú³(æ§   Ì u8P ¯¿    IEND®B`‚
=======================================
--- /dev/null   
+++ /trunk/modules/discopower/www/icons/magnify.png     Mon Sep 28 08:19:51 2009
Binary file, no diff available.
=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/icons/star.png        Mon Sep 28 08:19:51 2009
@@ -0,0 +1,15 @@
+‰PNG
+ 
+   
+IHDR              óÿa    tEXtSoftware Adobe  
ImageReadyqÉe<    IDATxÚ¤SÁK q þf” Óe†q“ g™Ù  µ!^ê  dÛÖE”.æ%èVtëf䡃 A yð$"(„PB¬
+¶n¦R
+6q7[· YZhÛ-Ì VÇ÷f†ÚÀ Ä  ßoÞ|ß÷Þ›÷Fx7Û  ?+—¾<æSQã~ ñ r» á ;ß -...@ö(röæ        
 
v xx( Êxž2ŸjQÂh‘à  º8¶ ¶±Ž$ÓÑCà;tšú™þx[ø
+` úéþx65·\.åïR`‚Þ  ïRaž  ?6DÙž44J­ÍJ Ú ‹¨n— uÆ ‰YG ºk  
�...@jrqȾÅÖ  ;µê7 ö}®`•¼ ‰ p&·
+"a{ øù
+Ø ¤æ8º¢CN\‹\C.= ôêd ¹"•’"¥ ™÷Ó¹ÜÚ...@q ¨ ™!üÌwkÌ °6“LþNœ+Ì ½9 ¢À ôÊä/ës  ޏDv 
ùC
+  •Mâãҳ߄
+`ò Sð*¹n¦ þ‘Ùw¼–ÈÍ  :ì aßø ñ²ÜÚí DƒTo *yƒáˆ C½   ôÝ �...@1\ à0
+E
+¯ Ð6ìĤ¦“ŒÒ÷Ý ÏBÇ% ›ë/ §r«[Åç
+ÜX› Ôô« È  s @´h.R¯‰×Ôë=êuÝ[²îLjêi‡
+ës—­®êú¿±RÊ—©Ò9EÕnû¬øKjó’¬j ¿ ¶mã(¶'À % ÎwTê –    IEND®B`‚
=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/js/jquery.livesearch.js       Mon Sep 28  
08:19:51 2009
@@ -0,0 +1,37 @@
+jQuery.fn.liveUpdate = function(list){
+       list = jQuery(list);
+
+       if ( list.length ) {
+               var rows = list.children('li'),
+                       cache = rows.map(function(){
+                               return jQuery(this).text().toLowerCase();
+                       });
+
+               this
+                       .keyup(filter).keyup()
+                       .parents('form').submit(function(){
+                               return false;
+                       });
+       }
+
+       return this;
+
+       function filter(){
+               var term = jQuery.trim( jQuery(this).val().toLowerCase() ), 
scores = [];
+
+               if ( !term ) {
+                       rows.show();
+               } else {
+                       rows.hide();
+
+                       cache.each(function(i){
+                               var score = this.score(term);
+                               if (score > 0) { scores.push([score, i]); }
+                       });
+
+                       jQuery.each(scores.sort(function(a, b){return b[0] - 
a[0];}),  
function(){
+                               jQuery(rows[ this[1] ]).show();
+                       });
+               }
+       }
+};
=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/js/quicksilver.js     Mon Sep 28 08:19:51 2009
@@ -0,0 +1,95 @@
+// qs_score - Quicksilver Score
+//
+// A port of the Quicksilver string ranking algorithm
+//
+// "hello world".score("axl") //=> 0.0
+// "hello world".score("ow") //=> 0.6
+// "hello world".score("hello world") //=> 1.0
+//
+// Tested in Firefox 2 and Safari 3
+//
+// The Quicksilver code is available here
+// http://code.google.com/p/blacktree-alchemy/
+//  
http://blacktree-alchemy.googlecode.com/svn/trunk/Crucible/Code/NSString+BLTRRanking.m
+//
+// The MIT License
+//
+// Copyright (c) 2008 Lachie Cox
+//
+// Permission is hereby granted, free of charge, to any person obtaining a  
copy
+// of this software and associated documentation files (the "Software"),  
to deal
+// in the Software without restriction, including without limitation the  
rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or  
sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included  
in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  
OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  
THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  
FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS  
IN
+// THE SOFTWARE.
+
+
+String.prototype.score = function(abbreviation,offset) {
+  offset = offset || 0 // TODO: I think this is unused... remove
+
+  if(abbreviation.length == 0) return 0.9
+  if(abbreviation.length > this.length) return 0.0
+
+  for (var i = abbreviation.length; i > 0; i--) {
+    var sub_abbreviation = abbreviation.substring(0,i)
+    var index = this.indexOf(sub_abbreviation)
+
+
+    if(index < 0) continue;
+    if(index + abbreviation.length > this.length + offset) continue;
+
+    var next_string       = this.substring(index+sub_abbreviation.length)
+    var next_abbreviation = null
+
+    if(i >= abbreviation.length)
+      next_abbreviation = ''
+    else
+      next_abbreviation = abbreviation.substring(i)
+
+    var remaining_score   =  
next_string.score(next_abbreviation,offset+index)
+
+    if (remaining_score > 0) {
+      var score = this.length-next_string.length;
+
+      if(index != 0) {
+        var j = 0;
+
+        var c = this.charCodeAt(index-1)
+        if(c==32 || c == 9) {
+          for(var j=(index-2); j >= 0; j--) {
+            c = this.charCodeAt(j)
+            score -= ((c == 32 || c == 9) ? 1 : 0.15)
+          }
+
+          // XXX maybe not port this heuristic
+          //
+          //          } else if ([[NSCharacterSet  
uppercaseLetterCharacterSet] characterIsMember:[self  
characterAtIndex:matchedRange.location]]) {
+          //            for (j = matchedRange.location-1; j >= (int)  
searchRange.location; j--) {
+          //              if ([[NSCharacterSet  
uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:j]])
+          //                score--;
+          //              else
+          //                score -= 0.15;
+          //            }
+        } else {
+          score -= index
+        }
+      }
+
+      score += remaining_score * next_string.length
+      score /= this.length;
+      return score
+    }
+  }
+  return 0.0
+}
=======================================
--- /dev/null
+++ /trunk/modules/discopower/www/style.css     Mon Sep 28 08:19:51 2009
@@ -0,0 +1,53 @@
+.inlinesearch:hover {
+
+}
+.inlinesearch {
+       float: right;
+       margin: 0em 3px .5em 1em;
+
+/*     padding: .3em;*/
+}
+.inlinesearch p {
+       font-size: 94%;
+       color: #aaa;
+
+}
+.inlinesearch input {
+       background-image:url('icons/magnify.png');
+       background-repeat:no-repeat;
+       background-position:center left;
+       border: 1px solid #ccc;
+       padding: 2px 2px 2px 20px;
+       margin: 0px 2px 0px 0px;
+}
+.inlinesearch * {
+       margin: 0px;
+       padding: 0px;
+}
+ul.metalist {
+       clear: both;
+       list-style: none;
+       margin: 1em 2px .5em 2px;
+       padding: 0px;
+}
+li.metaentry {
+       border: 1px solid #ccc;
+       margin: 0px 0px -1px 0px;
+       padding: .2em 1em .2em 20px;
+       cursor: pointer;
+       cursor: hand;
+}
+li.metaentry.favourite {
+       background-image:url('icons/heart.png');
+       background-repeat:no-repeat;
+       background-position:center left;
+
+}
+li.metaentry:hover {
+       border: 1px solid #ccc;
+       background: #eee;
+
+       background-image:url('icons/star.png');
+       background-repeat:no-repeat;
+       background-position:center left;
+}
=======================================
--- /trunk/modules/discopower/dictionaries/tabs.php     Thu Sep 24 00:22:04 2009
+++ /trunk/modules/discopower/dictionaries/tabs.php     Mon Sep 28 08:19:51 2009
@@ -41,6 +41,8 @@
                'no' => 'Andre',
                'en' => 'Miscellaneous',
        ),
+       'incommon' => array('en' => 'InCommon'),
+       'ukacessfederation' => array('en' => 'UK Access Federation'),

  );

=======================================
--- /trunk/modules/discopower/lib/PowerIdPDisco.php     Wed Aug 19 01:30:48 2009
+++ /trunk/modules/discopower/lib/PowerIdPDisco.php     Mon Sep 28 08:19:51 2009
@@ -44,12 +44,21 @@
        protected function log($message) {
                SimpleSAML_Logger::info('PowerIdPDisco.' . $this->instance . ': 
' .  
$message);
        }
+
+
+       public static function mcmp($a, $b) {
+#              echo 'aort'; exit;
+           if ($a['name']['en'] == $b['name']['en']) {
+               return 0;
+           }
+           return ($a['name']['en'] < $b['name']['en']) ? -1 : 1;
+       }

        /*
         * This function will structure the idp list in a hierarchy based upon  
the tags.
         */
        protected function idplistStructured($list) {
-#              echo '<pre>'; print_r($list); exit;
+               # echo '<pre>'; print_r($list); exit;
                $slist = array();

                $order = $this->discoconfig->getValue('taborder');
@@ -71,6 +80,11 @@
                                $slist[$tag][$key] = $val;
                        }
                }
+
+               foreach($slist AS $tab => $tbslist) {
+                       uasort($slist[$tab], 
array('sspmod_discopower_PowerIdPDisco', 'mcmp'));
+               }
+
                return $slist;
        }

=======================================
--- /trunk/modules/discopower/templates/disco-tpl.php   Mon Jan 26 13:36:44  
2009
+++ /trunk/modules/discopower/templates/disco-tpl.php   Mon Sep 28 08:19:51  
2009
@@ -4,24 +4,36 @@
        $this->data['header'] = 'selectidp';
  }
  $this->data['header'] = $this->t($this->data['header']);
-
-$this->data['head']  = '<script type="text/javascript" src="/' .  
$this->data['baseurlpath'] . 'resources/jquery.js"></script>';
-$this->data['head'] .= '<script type="text/javascript" src="/' .  
$this->data['baseurlpath'] . 'resources/jquery-ui.js"></script>';
-$this->data['head'] .= '<link rel="stylesheet" media="screen"  
type="text/css" href="/' .  
$this->data['baseurlpath'] . 'resources/uitheme/jquery-ui-themeroller.css"  
/>';
+$this->data['jquery'] = array('version' => '1.6', 'core' => TRUE, 'ui' =>  
TRUE, 'css' => TRUE);
+
+$this->data['head'] .= '<link rel="stylesheet" media="screen"  
type="text/css" href="' .  
SimpleSAML_Module::getModuleUrl('discopower/style.css')  . '" />';
+
+$this->data['head'] .= '<script type="text/javascript" src="' .  
SimpleSAML_Module::getModuleUrl('discopower/js/jquery.livesearch.js')  . 
'"></script>';
+$this->data['head'] .= '<script type="text/javascript" src="' .  
SimpleSAML_Module::getModuleUrl('discopower/js/quicksilver.js')  . 
'"></script>';

  $this->data['head'] .= '<script type="text/javascript">

  $(document).ready(function() {
-       $("#discotabs > ul").tabs({ selected: ' . $this->data['defaulttab'] . ' 
 
});
-       /*
-               $("#foodledescr").resizable({
-                       handles: "all"
-               });
-       */
+       $("#discotabs").tabs({ selected: ' . $this->data['defaulttab'] . ' }); 
';
+$i = 0;
+foreach ($this->data['idplist'] AS $tab => $slist) {
+       $this->data['head'] .= '$("#query_' . $tab . '").liveUpdate("#list_' .  
$tab . '")' .
+               ($i++ == 0 ? '.focus()' : '') .
+               ';';
+}
+
+$this->data['head'] .= '
  });
+
+       function chooseidp(idp) {
+               $("#chosenidp").attr(\'name\', \'idp_\' + idp);
+               $("#idpselectform").submit();
+       }
+
+
  </script>';

-$this->data['autofocus'] = 'preferredidp';
+# $this->data['autofocus'] = 'preferredidp';

  $this->includeAtTemplateBase('includes/header.php');

@@ -33,18 +45,57 @@
                        $this->includeInlineTranslation('idpdesc_' . 
$idpentry['entityid'],  
$idpentry['description']);
        }
  }
+
+
+
+function showEntry($t, $metadata, $favourite = FALSE) {
+       $extra = ($favourite ? ' favourite' : '');
+       $html = '<li class="metaentry' . $extra . '" onclick="chooseidp(\'' .  
htmlspecialchars($metadata['entityid']) . '\')">';
+
+       $html .= '' . htmlspecialchars($t->t('idpname_' .  
$metadata['entityid'])) . '';
+
+       #print_r($metadata['scopes']);
+
+       // if (!empty($idpentry['description'])) {
+       //      $html .= '      <p>' . htmlspecialchars($t->t('idpdesc_' .  
$metadata['entityid'])) . '<br />';
+       // }
+
+       if(array_key_exists('icon', $metadata) && $metadata['icon'] !== NULL) {
+               $iconUrl = SimpleSAML_Utilities::resolveURL($metadata['icon']);
+               $html .= '<img style="clear: both; float: left; margin: 1em; 
padding:  
3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />';
+       }
+
+       // $html .= '<input id="preferredidp" type="submit" name="idp_' .
+       //      htmlspecialchars($metadata['entityid']) . '" value="' .
+       //      $t->t('select') . '" /></p>';
+
+       $html .= '</li>';
+
+       return $html;
+}
+
+


  ?>


-       <h2><?php echo $this->data['header']; ?></h2>
-
-       <form method="get" action="<?php echo $this->data['urlpattern']; ?>">
+
+
+
+
+
+
+       <!-- <h2><?php echo $this->data['header']; ?></h2> -->
+
+       <form id="idpselectform" method="get" action="<?php echo  
$this->data['urlpattern']; ?>">
        <input type="hidden" name="entityID" value="<?php echo  
htmlspecialchars($this->data['entityID']); ?>" />
        <input type="hidden" name="return" value="<?php echo  
htmlspecialchars($this->data['return']); ?>" />
        <input type="hidden" name="returnIDParam" value="<?php echo  
htmlspecialchars($this->data['returnIDParam']); ?>" />

+       <input id="chosenidp" type="hidden" name="<?php echo  
htmlspecialchars($this->data['returnIDParam']); ?>" value="1" />
+       <!-- <input type="submit" style="" name="formsubmit" id="formsubmit"  
value="Submit" /> -->
+       </form>
        <p><?php

        $checked = '';
@@ -60,7 +111,7 @@

  <div id="discotabs">

-    <ul>
+    <ul class="tabset_tabs">
        <?php

                $tabs = array_keys( $this->data['idplist']);
@@ -75,49 +126,37 @@
                <?php


+
+
        foreach( $this->data['idplist'] AS $tab => $slist) {

                echo '<div id="' . $tab . '">';

-
-               if (!empty($this->data['preferredidp']) &&  
array_key_exists($this->data['preferredidp'], $slist)) {
-                       $idpentry = $slist[$this->data['preferredidp']];
-                       echo '<div class="preferredidp">';
-                       echo '  <img src="/' .  
$this->data['baseurlpath'] .'resources/icons/star.png" style="float: right"  
/>';
-
-                       if(array_key_exists('icon', $idpentry) && 
$idpentry['icon'] !== NULL) {
-                               $iconUrl = 
SimpleSAML_Utilities::resolveURL($idpentry['icon']);
-                               echo '<img style="float: left; margin: 1em; 
padding: 3px; border: 1px  
solid #999" src="' . htmlspecialchars($iconUrl) . '" />';
-                       }
-                       echo '<h3 style="margin-top: 8px">' .  
htmlspecialchars($this->t('idpname_' . $idpentry['entityid'])) . '</h3>';
-
-                       if (!empty($idpentry['description'])) {
-                               echo '  <p>' . 
htmlspecialchars($this->t('idpdesc_' .  
$idpentry['entityid'])) . '<br />';
-                       }
-                       echo('<input id="preferredidp" type="submit" 
name="idp_' .
-                               htmlspecialchars($idpentry['entityid']) . '" 
value="' .
-                               $this->t('select') . '" /></p>');
-                       echo '</div>';
-               }
-
-
-               foreach ($slist AS $idpentry) {
-                       if ($idpentry['entityid'] != 
$this->data['preferredidp']) {
-
-                               if(array_key_exists('icon', $idpentry) && 
$idpentry['icon'] !== NULL) {
-                                       $iconUrl = 
SimpleSAML_Utilities::resolveURL($idpentry['icon']);
-                                       echo '<img style="clear: both; float: 
left; margin: 1em; padding:  
3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />';
-                               }
-                               echo '  <h3 style="margin-top: 8px">' .  
htmlspecialchars($this->t('idpname_' . $idpentry['entityid'])) . '</h3>';
-
-                               if (!empty($idpentry['description'])) {
-
-                                       echo '  <p>' . 
htmlspecialchars($this->t('idpdesc_' .  
$idpentry['entityid'])) . '<br />';
-                               }
-                               echo('<input id="preferredidp" type="submit" 
name="idp_' .
-                                       htmlspecialchars($idpentry['entityid']) 
. '" value="' .
-                                       $this->t('select') . '" /></p>');
-                       }
+               if (!empty($slist)) {
+
+                       // echo 'Favourite :: ' . $this->data['preferredidp'];
+                       // echo '<pre>';
+                       // print_r($slist); exit;
+
+
+
+                       echo('  <div class="inlinesearch">');
+                       echo('  <p>Incremental search...</p>');
+                       echo('  <input class="inlinesearchf" type="text" 
value=""  
name="query_' . $tab . '" id="query_' . $tab . '" />');
+                       echo('  </div>');
+
+                       echo('  <ul class="metalist" id="list_' . $tab  . '">');
+                       if (!empty($this->data['preferredidp']) &&  
array_key_exists($this->data['preferredidp'], $slist)) {
+                               $idpentry = $slist[$this->data['preferredidp']];
+                               echo (showEntry($this, $idpentry, TRUE));
+                       }
+
+                       foreach ($slist AS $idpentry) {
+                               if ($idpentry['entityid'] != 
$this->data['preferredidp']) {
+                                       echo (showEntry($this, $idpentry));
+                               }
+                       }
+                       echo('  </ul>');
                }
                echo '</div>';

@@ -128,7 +167,6 @@


  </div>
-
-               </form>
+

  <?php $this->includeAtTemplateBase('includes/footer.php'); ?>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to