prettier player window,
[wolnelektury.git] / wolnelektury / static / js / base.js
index 36a85d0..33026ac 100755 (executable)
             $(this).addClass('short');
 
             if (button && short_text) button.html(short_text);
-            if (button) button.hover(
-                function() { $(this).css({background: '#F3F3F3', cursor: 'pointer'}); },
-                function() { $(this).css({background: '#EEE'}); }
-            ).click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
-            short_el.hover(
-                function() { $(this).css({background: '#F3F3F3', cursor: 'pointer'}); },
-                function() { $(this).css({background: '#FFF'}); }
-            ).click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
-            long_el.hover(
-                function() { $(this).css({background: '#F3F3F3', cursor: 'pointer'}); },
-                function() { $(this).css({background: '#FFF'}); }
-            ).click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
+            if (button) button.click(toggle_fun(cont, short_el, long_el, button, short_text, long_text));
         };
 
 
         // Fragments
-        $('.fragment-short-text').each(function() {
-            var fragment = $(this).closest('.fragment');
-            fragment.toggle_slide({
-                short_el: $(this),
-                long_el: fragment.find('.fragment-text')
+        $('.fragment-with-short').each(function() {
+            $(this).toggle_slide({
+                short_el: $('.fragment-short-text', this),
+                long_el: $('.fragment-long-text', this),
+                button: $('.toggle', this)
+            })
+        });
+        $('#description').each(function() {
+            $(this).toggle_slide({
+                short_el: $('#description-short', this),
+                long_el: $('#description-long', this),
+                button: $(this)
             })
         });
 
 
 
+               (function() {
+                       var $current = null;
+                       $('.hidden-box-wrapper').each(function() {
+                               var $hidden = $('.hidden-box', this);
+                               $('.hidden-box-trigger', this).click(function(event) {
+                                       event.preventDefault();
+                                       if ($current == $hidden) {
+                                               $current = null;
+                                               $hidden.hide('fast');
+                                       } else {
+                                               $current && $current.hide('fast');
+                                               $hidden.show('fast');
+                                               $current = $hidden;
+                                       } 
+                               });
+                       });
+                       $('body').click(function(e) {
+                               if ($current == null) return;
+                               var p = $(e.target);
+                               while (p.length) {
+                                       if (p == $current)
+                                               return;
+                                       if (p.hasClass('hidden-box-trigger'))
+                                               return;
+                                       p = p.parent();
+                               }
+                               $current.hide('fast');
+                               $current = null;
+                       });
+               })();
+               
 
 
 
@@ -74,7 +101,7 @@ $('.open-player').click(function(event) {
     event.preventDefault();
     window.open($(this).attr('href'),
         'player',
-        'width=420, height=500'
+        'width=422, height=500'
         );
 });
 
@@ -87,6 +114,8 @@ $('.open-player').click(function(event) {
             return false;
         });
 
+       $(function(){
+           $("#search").search();});
 
     });
 })(jQuery)