Procházet zdrojové kódy

update

Signed-off-by: bachy <git@g-u-i.net>
bachy před 12 roky
rodič
revize
3faebabce1

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
js/materio_search_api_ajax-ck.js


+ 37 - 21
js/materio_search_api_ajax.js

@@ -14,13 +14,10 @@ MaterioBaseMod = function(){
   function init(){
     trace('init module');
 
-    // $('#root').bind('resultsupdated', function(event) {
-    //   alert('HO');
-    // });
-    $(window).trigger('resultsupdated');
     initSearchAjax();
     initHistoryNav();
     initViewMode();
+
   };
 
   /**
@@ -28,14 +25,12 @@ MaterioBaseMod = function(){
   */
   function initSearchAjax(){
     // trace('initSearchAjax');
-    $('#edit-searchfield').focus();
-
+    // $('#edit-searchfield').focus();
 
     $('#materio-search-api-search-form').bind('submit', function(event) {
       // trace('search submited', event);
       var $this = $(this);
       setTimeout(function(){
-        // trace('submit load');
         loadResults(getSearchKeys());
       },10);
       return false;
@@ -44,13 +39,11 @@ MaterioBaseMod = function(){
 
     // /!\ AUTOCOMPLETE SELECT EVENT need a patch http://drupal.org/node/365241#comment-5374686
     $("#edit-searchfield").bind('autocompleteSelect', function(event) {
-      // trace('autocompleteSelect - event', event);
-      // trace('val', $(this).val());
-      // var $form = $(this).parents('form');
-      // setTimeout(function(){
-        // $form.submit();        
-      // }, 10);
-      loadResults($(this).val());
+      setTimeout(function(){
+        loadResults(getSearchKeys());
+      },10);
+
+      // loadResults($(this).val());
     });
 
     
@@ -67,19 +60,32 @@ MaterioBaseMod = function(){
             loadNextResultsPage();
       });
 
+    // trigger updated event on search results for direct html loading
+    if($('.search-results', _$content).length){
+      setTimeout(function(){
+        var event = jQuery.Event('resultsupdated');
+        event.container = $('.search-results', _$content);
+        $(window).trigger(event);  
+      }, 10);  
+    }
+    
+    
   };
-  
+
+
   function loadResults(keys){
     // trace('keys', keys);
     if(keys !== undefined){
       keys = keys.replace('/', ' ');
       if(!_isloadingresults){
         _isloadingresults = true;
+        $('#materio-search-api-search-form').addClass('loading');
         // TODO:  record ajax path in a variable from materio_search_api_ajax_init
         $.getJSON('/materio_search_api_ajax/search/'+keys, function(json){
             // trace('json', json);
             $(window).trigger('resultsloaded');      
             _isloadingresults = false;
+            $('#materio-search-api-search-form').removeClass('loading');
             updateContent(json);
         });
       }
@@ -103,17 +109,17 @@ MaterioBaseMod = function(){
       //   $('.node-materiau','#content').fadeIn(500);
       // },300);
           
-      
-      var event = jQuery.Event('resultsupdated');
-      event.container = $('.search-results', _$content);
-      $(window).trigger(event);
 
       _History.pushState({content:json.return}, json.keys, '/'+json.search_path + '/' +json.keys);
       // navigate({content:json.return}, '', '/'+json.page.path + '/' +json.keys);
 
+      var event = jQuery.Event('resultsupdated');
+      event.container = $('.search-results', _$content);
+      $(window).trigger(event);
+
 
     }else{
-      alert('no results');
+      trace('no results');
     }
   };
 
@@ -134,9 +140,11 @@ MaterioBaseMod = function(){
 
       if(!_isloadingresults){
         _isloadingresults = true;
+        $('.materiobase-results', _$content).addClass('loading');
         $.getJSON('/materio_search_api_ajax/search/'+keys[1]+'/'+page[1], function(json){
           // trace('json', json);
           _isloadingresults = false;
+          $('.materiobase-results', _$content).removeClass('loading');
           addNextpage(json);
         });
       }
@@ -147,12 +155,20 @@ MaterioBaseMod = function(){
 
   function addNextpage(json){
     var $newcontent = $(json.return),
-        $newresults = $('.search-results article', $newcontent),
+        $newresults = $('.search-results', $newcontent).children('article').addClass('just-added'),
         $newpager = $('ul.pager', $newcontent);
     
     $('.search-results', _$content).append($newresults);
     $('ul.pager', _$content).replaceWith($newpager);
 
+    $('.search-results', _$content).children('.just-added').each(function(i){
+      // $(this).delay(5000*i).removeClass('just-added');
+      var $this = $(this);
+      setTimeout(function(){
+        $this.removeClass('just-added');
+      }, 150*i);
+    });
+
     var event = jQuery.Event('resultscompleted');
     event.container = $('.search-results', _$content);
     $(window).trigger(event);

+ 1 - 0
materio_search_api.pages.inc

@@ -151,6 +151,7 @@ function materio_search_api_results_search(){//, $limit = 20, $page = 0
 
   if ($keys) {
     try {
+      // TODO:  change limit function of viewmode small card -> many items, big cards -> few items  
       $limit = 15;
       $offset = pager_find_page() * $limit; //$page*$limit;//
 

+ 8 - 0
materio_search_api_ajax.module

@@ -12,6 +12,14 @@
  * Implements hook_init().
  */
 function materio_search_api_ajax_init() {
+  drupal_add_js(array('materio_search_api_ajax' => array(
+    'module_path' => drupal_get_path('module', 'materio_search_api_ajax'),
+    // 'strings'=>array(
+    //   'sitetitle'=>,
+    //   'siteslogan'=>,
+    // ),
+  )), 'setting');
+
   drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/libraries/jquery.history.js');
   drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/materio_search_api_ajax-ck.js');
 }

+ 3 - 0
templates/materio-search-api-results.tpl.php

@@ -31,6 +31,9 @@
  */
 
 ?>
+<?php //dsm($index, 'index'); ?>
+<?php //dsm($items, 'items'); ?>
+
 <?php if (!empty($result_count)) : ?>
   <div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
     <?php if ($result_count) : ?>

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů