update
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
3b4f1e024f
commit
3faebabce1
File diff suppressed because one or more lines are too long
@ -14,13 +14,10 @@ MaterioBaseMod = function(){
|
|||||||
function init(){
|
function init(){
|
||||||
trace('init module');
|
trace('init module');
|
||||||
|
|
||||||
// $('#root').bind('resultsupdated', function(event) {
|
|
||||||
// alert('HO');
|
|
||||||
// });
|
|
||||||
$(window).trigger('resultsupdated');
|
|
||||||
initSearchAjax();
|
initSearchAjax();
|
||||||
initHistoryNav();
|
initHistoryNav();
|
||||||
initViewMode();
|
initViewMode();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,14 +25,12 @@ MaterioBaseMod = function(){
|
|||||||
*/
|
*/
|
||||||
function initSearchAjax(){
|
function initSearchAjax(){
|
||||||
// trace('initSearchAjax');
|
// trace('initSearchAjax');
|
||||||
$('#edit-searchfield').focus();
|
// $('#edit-searchfield').focus();
|
||||||
|
|
||||||
|
|
||||||
$('#materio-search-api-search-form').bind('submit', function(event) {
|
$('#materio-search-api-search-form').bind('submit', function(event) {
|
||||||
// trace('search submited', event);
|
// trace('search submited', event);
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
// trace('submit load');
|
|
||||||
loadResults(getSearchKeys());
|
loadResults(getSearchKeys());
|
||||||
},10);
|
},10);
|
||||||
return false;
|
return false;
|
||||||
@ -44,13 +39,11 @@ MaterioBaseMod = function(){
|
|||||||
|
|
||||||
// /!\ AUTOCOMPLETE SELECT EVENT need a patch http://drupal.org/node/365241#comment-5374686
|
// /!\ AUTOCOMPLETE SELECT EVENT need a patch http://drupal.org/node/365241#comment-5374686
|
||||||
$("#edit-searchfield").bind('autocompleteSelect', function(event) {
|
$("#edit-searchfield").bind('autocompleteSelect', function(event) {
|
||||||
// trace('autocompleteSelect - event', event);
|
setTimeout(function(){
|
||||||
// trace('val', $(this).val());
|
loadResults(getSearchKeys());
|
||||||
// var $form = $(this).parents('form');
|
},10);
|
||||||
// setTimeout(function(){
|
|
||||||
// $form.submit();
|
// loadResults($(this).val());
|
||||||
// }, 10);
|
|
||||||
loadResults($(this).val());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -67,19 +60,32 @@ MaterioBaseMod = function(){
|
|||||||
loadNextResultsPage();
|
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){
|
function loadResults(keys){
|
||||||
// trace('keys', keys);
|
// trace('keys', keys);
|
||||||
if(keys !== undefined){
|
if(keys !== undefined){
|
||||||
keys = keys.replace('/', ' ');
|
keys = keys.replace('/', ' ');
|
||||||
if(!_isloadingresults){
|
if(!_isloadingresults){
|
||||||
_isloadingresults = true;
|
_isloadingresults = true;
|
||||||
|
$('#materio-search-api-search-form').addClass('loading');
|
||||||
// TODO: record ajax path in a variable from materio_search_api_ajax_init
|
// TODO: record ajax path in a variable from materio_search_api_ajax_init
|
||||||
$.getJSON('/materio_search_api_ajax/search/'+keys, function(json){
|
$.getJSON('/materio_search_api_ajax/search/'+keys, function(json){
|
||||||
// trace('json', json);
|
// trace('json', json);
|
||||||
$(window).trigger('resultsloaded');
|
$(window).trigger('resultsloaded');
|
||||||
_isloadingresults = false;
|
_isloadingresults = false;
|
||||||
|
$('#materio-search-api-search-form').removeClass('loading');
|
||||||
updateContent(json);
|
updateContent(json);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -104,16 +110,16 @@ MaterioBaseMod = function(){
|
|||||||
// },300);
|
// },300);
|
||||||
|
|
||||||
|
|
||||||
|
_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');
|
var event = jQuery.Event('resultsupdated');
|
||||||
event.container = $('.search-results', _$content);
|
event.container = $('.search-results', _$content);
|
||||||
$(window).trigger(event);
|
$(window).trigger(event);
|
||||||
|
|
||||||
_History.pushState({content:json.return}, json.keys, '/'+json.search_path + '/' +json.keys);
|
|
||||||
// navigate({content:json.return}, '', '/'+json.page.path + '/' +json.keys);
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
alert('no results');
|
trace('no results');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -134,9 +140,11 @@ MaterioBaseMod = function(){
|
|||||||
|
|
||||||
if(!_isloadingresults){
|
if(!_isloadingresults){
|
||||||
_isloadingresults = true;
|
_isloadingresults = true;
|
||||||
|
$('.materiobase-results', _$content).addClass('loading');
|
||||||
$.getJSON('/materio_search_api_ajax/search/'+keys[1]+'/'+page[1], function(json){
|
$.getJSON('/materio_search_api_ajax/search/'+keys[1]+'/'+page[1], function(json){
|
||||||
// trace('json', json);
|
// trace('json', json);
|
||||||
_isloadingresults = false;
|
_isloadingresults = false;
|
||||||
|
$('.materiobase-results', _$content).removeClass('loading');
|
||||||
addNextpage(json);
|
addNextpage(json);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -147,12 +155,20 @@ MaterioBaseMod = function(){
|
|||||||
|
|
||||||
function addNextpage(json){
|
function addNextpage(json){
|
||||||
var $newcontent = $(json.return),
|
var $newcontent = $(json.return),
|
||||||
$newresults = $('.search-results article', $newcontent),
|
$newresults = $('.search-results', $newcontent).children('article').addClass('just-added'),
|
||||||
$newpager = $('ul.pager', $newcontent);
|
$newpager = $('ul.pager', $newcontent);
|
||||||
|
|
||||||
$('.search-results', _$content).append($newresults);
|
$('.search-results', _$content).append($newresults);
|
||||||
$('ul.pager', _$content).replaceWith($newpager);
|
$('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');
|
var event = jQuery.Event('resultscompleted');
|
||||||
event.container = $('.search-results', _$content);
|
event.container = $('.search-results', _$content);
|
||||||
$(window).trigger(event);
|
$(window).trigger(event);
|
||||||
|
@ -151,6 +151,7 @@ function materio_search_api_results_search(){//, $limit = 20, $page = 0
|
|||||||
|
|
||||||
if ($keys) {
|
if ($keys) {
|
||||||
try {
|
try {
|
||||||
|
// TODO: change limit function of viewmode small card -> many items, big cards -> few items
|
||||||
$limit = 15;
|
$limit = 15;
|
||||||
$offset = pager_find_page() * $limit; //$page*$limit;//
|
$offset = pager_find_page() * $limit; //$page*$limit;//
|
||||||
|
|
||||||
|
@ -12,6 +12,14 @@
|
|||||||
* Implements hook_init().
|
* Implements hook_init().
|
||||||
*/
|
*/
|
||||||
function materio_search_api_ajax_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/libraries/jquery.history.js');
|
||||||
drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/materio_search_api_ajax-ck.js');
|
drupal_add_js(drupal_get_path('module', 'materio_search_api_ajax').'/js/materio_search_api_ajax-ck.js');
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<?php //dsm($index, 'index'); ?>
|
||||||
|
<?php //dsm($items, 'items'); ?>
|
||||||
|
|
||||||
<?php if (!empty($result_count)) : ?>
|
<?php if (!empty($result_count)) : ?>
|
||||||
<div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
|
<div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
|
||||||
<?php if ($result_count) : ?>
|
<?php if ($result_count) : ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user