conjunction OR ++
ajax : keys aren't args any more, because of a+b+c Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
2601c718c2
commit
bcf209570a
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ MaterioFlag = function(){
|
|||||||
* init()
|
* init()
|
||||||
*/
|
*/
|
||||||
function init(){
|
function init(){
|
||||||
trace('MaterioFlag :: init MaterioFlag');
|
//trace('MaterioFlag :: init MaterioFlag');
|
||||||
|
|
||||||
buildBlocks();
|
buildBlocks();
|
||||||
|
|
||||||
@ -32,36 +32,60 @@ MaterioFlag = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onFlaging(event){
|
function onFlaging(event){
|
||||||
trace('MaterioFlag :: onFlaging', event);
|
//trace('MaterioFlag :: onFlaging', event);
|
||||||
refreshBlocks();
|
refreshBlocks();
|
||||||
};
|
};
|
||||||
|
|
||||||
function onResultsUpdated(event){
|
function onResultsUpdated(event){
|
||||||
trace('MaterioFlag :: onResultsUpdated', event);
|
//trace('MaterioFlag :: onResultsUpdated', event);
|
||||||
ajaxifyLinks(event.container);
|
ajaxifyLinks(event.container);
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildBlocks(activename){
|
function buildBlocks(activename){
|
||||||
trace('MaterioFlag :: buildBlocks', activename);
|
//trace('MaterioFlag :: buildBlocks', activename);
|
||||||
// nav block
|
|
||||||
$('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
|
|
||||||
$this = $(this)
|
|
||||||
.bind('click', onClickOpenLink)
|
|
||||||
.addClass('ajax-processed');
|
|
||||||
|
|
||||||
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
if($('#block-materio-flag-materio-flag-mybookmarks').length){
|
||||||
// trace('MaterioFlag :: name', name);
|
var type = 'bookmarks';
|
||||||
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
var block = '#block-materio-flag-materio-flag-mybookmarks';
|
||||||
});
|
}else if($('#block-materio-flag-materio-flag-mylists').length){
|
||||||
|
var type = 'lists';
|
||||||
|
var block = '#block-materio-flag-materio-flag-mylists';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type == 'lists'){
|
||||||
|
|
||||||
|
// nav block
|
||||||
|
$('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
|
||||||
|
$this = $(this)
|
||||||
|
.bind('click', onClickOpenLink)
|
||||||
|
.addClass('ajax-processed');
|
||||||
|
|
||||||
|
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
||||||
|
// trace('MaterioFlag :: name', name);
|
||||||
|
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
||||||
|
});
|
||||||
|
|
||||||
|
// preview block
|
||||||
|
$('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
|
||||||
|
var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
||||||
|
$('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
|
||||||
|
|
||||||
|
$('a.open-list', this).bind('click', onClickOpenLink);
|
||||||
|
|
||||||
// preview block
|
}).addClass('ajax-processed');
|
||||||
$('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
|
|
||||||
var name = $(this).attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
// trigger refresh block event for enabling lazyload images
|
||||||
$('<i class="icon-remove"></i>').appendTo($('h2.listname', this)).attr('name', name).bind('click', onClickClosePreview);
|
setTimeout(function(){
|
||||||
|
$.event.trigger({
|
||||||
|
type : 'my'+type+'-block-builded',
|
||||||
|
block : block,
|
||||||
|
name : name
|
||||||
|
});
|
||||||
|
},10);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$('a.open-list', this).bind('click', onClickOpenLink);
|
|
||||||
|
|
||||||
}).addClass('ajax-processed');
|
|
||||||
|
|
||||||
// trace('MaterioFlag :: activename', activename);
|
// trace('MaterioFlag :: activename', activename);
|
||||||
if(activename == undefined)
|
if(activename == undefined)
|
||||||
@ -70,10 +94,12 @@ MaterioFlag = function(){
|
|||||||
// trace('MaterioFlag :: activename', activename);
|
// trace('MaterioFlag :: activename', activename);
|
||||||
if(activename)
|
if(activename)
|
||||||
showPreview(activename);
|
showPreview(activename);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function refreshBlocks(name){
|
function refreshBlocks(name){
|
||||||
trace('MaterioFlag :: refreshBlocks | name', name);
|
//trace('MaterioFlag :: refreshBlocks | name', name);
|
||||||
if($('#block-materio-flag-materio-flag-mybookmarks').length){
|
if($('#block-materio-flag-materio-flag-mybookmarks').length){
|
||||||
var type = 'bookmarks';
|
var type = 'bookmarks';
|
||||||
}else if($('#block-materio-flag-materio-flag-mylists').length){
|
}else if($('#block-materio-flag-materio-flag-mylists').length){
|
||||||
@ -84,7 +110,7 @@ MaterioFlag = function(){
|
|||||||
var id = '#block-materio-flag-materio-flag-my'+type;
|
var id = '#block-materio-flag-materio-flag-my'+type;
|
||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
|
||||||
$.getJSON(url, function(json){
|
$.getJSON(url, function(json){
|
||||||
trace('MaterioFlag :: block refreshed '+type, json);
|
//trace('MaterioFlag :: block refreshed '+type, json);
|
||||||
|
|
||||||
$(id).replaceWith(json.block);
|
$(id).replaceWith(json.block);
|
||||||
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
|
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
|
||||||
@ -102,7 +128,7 @@ MaterioFlag = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function ajaxifyLinks(container){
|
function ajaxifyLinks(container){
|
||||||
trace('MaterioFlag :: ajaxifyLinks', container);
|
//trace('MaterioFlag :: ajaxifyLinks', container);
|
||||||
|
|
||||||
container = ((container != null) ? container : 'body');
|
container = ((container != null) ? container : 'body');
|
||||||
|
|
||||||
@ -123,12 +149,12 @@ MaterioFlag = function(){
|
|||||||
* show hide preview
|
* show hide preview
|
||||||
*/
|
*/
|
||||||
function onClickShowPreview(event){
|
function onClickShowPreview(event){
|
||||||
trace('MaterioFlag :: onClickShowPreview', event);
|
//trace('MaterioFlag :: onClickShowPreview', event);
|
||||||
showPreview($(this).attr('name'));
|
showPreview($(this).attr('name'));
|
||||||
};
|
};
|
||||||
|
|
||||||
function showPreview(name){
|
function showPreview(name){
|
||||||
trace('MaterioFlag :: showPreview', name);
|
//trace('MaterioFlag :: showPreview', name);
|
||||||
$('section.'+name, '#block-materio-flag-materio-flag-mylists').addClass('active')
|
$('section.'+name, '#block-materio-flag-materio-flag-mylists').addClass('active')
|
||||||
.siblings('section').removeClass('active');
|
.siblings('section').removeClass('active');
|
||||||
|
|
||||||
@ -138,7 +164,7 @@ MaterioFlag = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onClickClosePreview(event){
|
function onClickClosePreview(event){
|
||||||
trace('MaterioFlag :: onClickClosePreview', event);
|
//trace('MaterioFlag :: onClickClosePreview', event);
|
||||||
eraseCookie('materiomyflaglistsopened');
|
eraseCookie('materiomyflaglistsopened');
|
||||||
$(this).parents('section.flag-list').removeClass('active');
|
$(this).parents('section.flag-list').removeClass('active');
|
||||||
|
|
||||||
@ -163,7 +189,7 @@ MaterioFlag = function(){
|
|||||||
$.event.trigger('loading-content');
|
$.event.trigger('loading-content');
|
||||||
|
|
||||||
$.getJSON(url, {'current_path':document.location.href},function(json){
|
$.getJSON(url, {'current_path':document.location.href},function(json){
|
||||||
trace('MaterioFlag :: json', json);
|
//trace('MaterioFlag :: json', json);
|
||||||
if(json.redirect){
|
if(json.redirect){
|
||||||
window.location = json.redirect;
|
window.location = json.redirect;
|
||||||
}else{
|
}else{
|
||||||
@ -200,7 +226,7 @@ MaterioFlag = function(){
|
|||||||
triggerContentChanged();
|
triggerContentChanged();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
trace('MaterioFlag :: no results');
|
//trace('MaterioFlag :: no results');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -222,7 +248,7 @@ MaterioFlag = function(){
|
|||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
|
||||||
|
|
||||||
$.getJSON(url, function(json){
|
$.getJSON(url, function(json){
|
||||||
trace('MaterioFlag :: creat list : json', json);
|
//trace('MaterioFlag :: creat list : json', json);
|
||||||
showCreateListForm(json, $link);
|
showCreateListForm(json, $link);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@ -250,7 +276,7 @@ MaterioFlag = function(){
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
switch($(this).attr('name')){
|
switch($(this).attr('name')){
|
||||||
case 'cancel':
|
case 'cancel':
|
||||||
trace('MaterioFlag :: cancel',event);
|
//trace('MaterioFlag :: cancel',event);
|
||||||
$(this).parents('#modal').remove();
|
$(this).parents('#modal').remove();
|
||||||
|
|
||||||
// google analytics
|
// google analytics
|
||||||
@ -262,7 +288,7 @@ MaterioFlag = function(){
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'create':
|
case 'create':
|
||||||
trace('MaterioFlag :: create',event);
|
//trace('MaterioFlag :: create',event);
|
||||||
var title = $(this).parents('form').find('input[name*="flag-lists-name"]').val();
|
var title = $(this).parents('form').find('input[name*="flag-lists-name"]').val();
|
||||||
var type = $(this).parents('form').find('input[name*="type"]').val();
|
var type = $(this).parents('form').find('input[name*="type"]').val();
|
||||||
|
|
||||||
@ -288,13 +314,13 @@ MaterioFlag = function(){
|
|||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/add/'+type+'/js';
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/add/'+type+'/js';
|
||||||
$.getJSON(url, {name:title}, function(data) {
|
$.getJSON(url, {name:title}, function(data) {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
trace(data.error);
|
//trace(data.error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// select.append('<option value="'+data.flag.fid+'">'+data.flag.title+'</option>');
|
// select.append('<option value="'+data.flag.fid+'">'+data.flag.title+'</option>');
|
||||||
// $('input.name', $(this)).val('');
|
// $('input.name', $(this)).val('');
|
||||||
// dialog.dialog('close');
|
// dialog.dialog('close');
|
||||||
trace('MaterioFlag :: created list : data', data);
|
//trace('MaterioFlag :: created list : data', data);
|
||||||
|
|
||||||
flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
|
flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
|
||||||
$modal.remove();
|
$modal.remove();
|
||||||
@ -311,7 +337,7 @@ MaterioFlag = function(){
|
|||||||
data: { js: true, token: token },
|
data: { js: true, token: token },
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data2) {
|
success: function (data2) {
|
||||||
trace('MaterioFlag :: node taged with newly created list : data2', data2)
|
//trace('MaterioFlag :: node taged with newly created list : data2', data2)
|
||||||
if (data2.status) {
|
if (data2.status) {
|
||||||
|
|
||||||
// google analytics
|
// google analytics
|
||||||
@ -379,7 +405,7 @@ MaterioFlag = function(){
|
|||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
|
||||||
|
|
||||||
$.getJSON(url, function(json){
|
$.getJSON(url, function(json){
|
||||||
trace('MaterioFlag :: editlist : json', json);
|
//trace('MaterioFlag :: editlist : json', json);
|
||||||
showEditListForm(json, $link);
|
showEditListForm(json, $link);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@ -413,7 +439,7 @@ MaterioFlag = function(){
|
|||||||
|
|
||||||
switch($(this).attr('name')){
|
switch($(this).attr('name')){
|
||||||
case 'cancel':
|
case 'cancel':
|
||||||
trace('MaterioFlag :: cancel',event);
|
//trace('MaterioFlag :: cancel',event);
|
||||||
$(this).parents('#modal').remove();
|
$(this).parents('#modal').remove();
|
||||||
|
|
||||||
// google analytics
|
// google analytics
|
||||||
@ -421,7 +447,7 @@ MaterioFlag = function(){
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'save':
|
case 'save':
|
||||||
trace('MaterioFlag :: create',event);
|
//trace('MaterioFlag :: create',event);
|
||||||
|
|
||||||
// google analytics
|
// google analytics
|
||||||
var action = "submit edit form";
|
var action = "submit edit form";
|
||||||
@ -429,7 +455,7 @@ MaterioFlag = function(){
|
|||||||
editList($modal, fid, name, title);
|
editList($modal, fid, name, title);
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
trace('MaterioFlag :: delete',event);
|
//trace('MaterioFlag :: delete',event);
|
||||||
|
|
||||||
if(confirm('Do you realy want to delete the folder '+title+'?')){
|
if(confirm('Do you realy want to delete the folder '+title+'?')){
|
||||||
var action = "submit delete form";
|
var action = "submit delete form";
|
||||||
@ -463,7 +489,7 @@ MaterioFlag = function(){
|
|||||||
alert(data.message);
|
alert(data.message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace('MaterioFlag :: saved list : data', data);
|
//trace('MaterioFlag :: saved list : data', data);
|
||||||
|
|
||||||
$.event.trigger({
|
$.event.trigger({
|
||||||
type : 'list-edited',
|
type : 'list-edited',
|
||||||
@ -489,7 +515,7 @@ MaterioFlag = function(){
|
|||||||
alert(data.message);
|
alert(data.message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace('MaterioFlag :: deleted list : data', data);
|
//trace('MaterioFlag :: deleted list : data', data);
|
||||||
|
|
||||||
refreshBlocks();
|
refreshBlocks();
|
||||||
refreshNodeLinks();
|
refreshNodeLinks();
|
||||||
@ -527,11 +553,11 @@ MaterioFlag = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function loadNextPage(url, $container, target){
|
function loadNextPage(url, $container, target){
|
||||||
trace('MaterioFlag :: loadNextPage');
|
//trace('MaterioFlag :: loadNextPage');
|
||||||
_isLoadingList = true;
|
_isLoadingList = true;
|
||||||
$container.addClass('loading');
|
$container.addClass('loading');
|
||||||
$.getJSON(url, function(json){
|
$.getJSON(url, function(json){
|
||||||
trace('json', json);
|
//trace('json', json);
|
||||||
_isLoadingList = false;
|
_isLoadingList = false;
|
||||||
$container.removeClass('loading');
|
$container.removeClass('loading');
|
||||||
addNextpage(json, target);
|
addNextpage(json, target);
|
||||||
|
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
* init()
|
* init()
|
||||||
*/
|
*/
|
||||||
function init(){
|
function init(){
|
||||||
trace('init MaterioSearchApiAjax');
|
//trace('init MaterioSearchApiAjax');
|
||||||
|
|
||||||
initSearchAjax();
|
initSearchAjax();
|
||||||
initViewMode();
|
initViewMode();
|
||||||
@ -49,7 +49,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
// trigger updated event for direct html loading
|
// trigger updated event for direct html loading
|
||||||
if( isActuality() || isExplore() ){
|
if( isActuality() || isExplore() ){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
trace('MaterioSearchApiAjax :: initSearchAjax :: triggering resultschanged')
|
//trace('MaterioSearchApiAjax :: initSearchAjax :: triggering resultschanged')
|
||||||
$.event.trigger({
|
$.event.trigger({
|
||||||
type : 'resultschanged',
|
type : 'resultschanged',
|
||||||
container : isActuality() ? '#content .actuality-items' : '#content .search-results'
|
container : isActuality() ? '#content .actuality-items' : '#content .search-results'
|
||||||
@ -63,8 +63,8 @@ MaterioSearchApiAjax = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function loadResults(keys){
|
function loadResults(keys){
|
||||||
// trace('keys', keys);
|
trace('keys', keys);
|
||||||
if(keys !== undefined){
|
if(keys !== undefined && keys !== '' && keys.length >= 2){
|
||||||
keys = keys.replace('/', ' ');
|
keys = keys.replace('/', ' ');
|
||||||
|
|
||||||
var types = {}, stringTypes = [];
|
var types = {}, stringTypes = [];
|
||||||
@ -74,7 +74,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
stringTypes.push($this.val());
|
stringTypes.push($this.val());
|
||||||
types[$this.val()] = $this.attr('checked');
|
types[$this.val()] = $this.attr('checked');
|
||||||
});
|
});
|
||||||
trace('types', types);
|
//trace('types', types);
|
||||||
|
|
||||||
|
|
||||||
if(!_isloadingresults){
|
if(!_isloadingresults){
|
||||||
@ -83,14 +83,11 @@ MaterioSearchApiAjax = function(){
|
|||||||
$('#materio-search-api-search-form').addClass('loading');
|
$('#materio-search-api-search-form').addClass('loading');
|
||||||
// trace('window.location.href',window.location.href);
|
// trace('window.location.href',window.location.href);
|
||||||
// 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(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys,
|
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/',
|
||||||
{'types':types,'current_path':document.location.href},
|
{'types':types,'current_path':document.location.href, keys:keys},
|
||||||
function(json){
|
function(json){
|
||||||
trace('json', json);
|
//trace('json', json);
|
||||||
$.event.trigger('loaded-content');
|
|
||||||
_isloadingresults = false;
|
|
||||||
$('#materio-search-api-search-form').removeClass('loading');
|
|
||||||
|
|
||||||
// google analytics
|
// google analytics
|
||||||
$.event.trigger({
|
$.event.trigger({
|
||||||
type : "record-stat",
|
type : "record-stat",
|
||||||
@ -99,9 +96,13 @@ MaterioSearchApiAjax = function(){
|
|||||||
label : 'filters : '+ stringTypes.join(' ,'),
|
label : 'filters : '+ stringTypes.join(' ,'),
|
||||||
value : json.count
|
value : json.count
|
||||||
});
|
});
|
||||||
|
|
||||||
if(json.redirect){
|
if(json.redirect){
|
||||||
window.location = json.redirect;
|
window.location = json.redirect;
|
||||||
}else{
|
}else{
|
||||||
|
$.event.trigger('loaded-content');
|
||||||
|
_isloadingresults = false;
|
||||||
|
$('#materio-search-api-search-form').removeClass('loading');
|
||||||
changeContent(json);
|
changeContent(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality';
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality';
|
||||||
$.getJSON(url,
|
$.getJSON(url,
|
||||||
function(json){
|
function(json){
|
||||||
trace('json', json);
|
//trace('json', json);
|
||||||
$.event.trigger('resultsloaded');
|
$.event.trigger('resultsloaded');
|
||||||
_isloadingresults = false;
|
_isloadingresults = false;
|
||||||
$('#materio-search-api-search-form').removeClass('loading');
|
$('#materio-search-api-search-form').removeClass('loading');
|
||||||
@ -136,7 +137,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
$('.inner-content',_$content).html(json.return).find('ul.pager').hide();
|
$('.inner-content',_$content).html(json.return).find('ul.pager').hide();
|
||||||
triggerContentChanged();
|
triggerContentChanged();
|
||||||
}else{
|
}else{
|
||||||
trace('no results');
|
//trace('no results');
|
||||||
}
|
}
|
||||||
|
|
||||||
$.event.trigger({
|
$.event.trigger({
|
||||||
@ -153,7 +154,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function triggerContentChanged(){
|
function triggerContentChanged(){
|
||||||
trace('MaterioSearchApiAjax :: triggerContentChanged');
|
//trace('MaterioSearchApiAjax :: triggerContentChanged');
|
||||||
$.event.trigger({
|
$.event.trigger({
|
||||||
type : 'resultschanged',
|
type : 'resultschanged',
|
||||||
container : '#content .search-results, #content .actuality-items'
|
container : '#content .search-results, #content .actuality-items'
|
||||||
@ -179,9 +180,9 @@ MaterioSearchApiAjax = function(){
|
|||||||
// trace('loadNextResultsPage');
|
// trace('loadNextResultsPage');
|
||||||
var keys = href.match(/explore\/([^\/|\?]+)/);
|
var keys = href.match(/explore\/([^\/|\?]+)/);
|
||||||
var page = href.match(/\?page=([0-9]+)/);
|
var page = href.match(/\?page=([0-9]+)/);
|
||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys[1]+'/'+page[1];
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+page[1];
|
||||||
|
|
||||||
loadNextPage(url, $('.materiobase-results', _$content), '.search-results');
|
loadNextPage(url, keys[1], $('.materiobase-results', _$content), '.search-results');
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadNextActualityPage(href){
|
function loadNextActualityPage(href){
|
||||||
@ -189,15 +190,15 @@ MaterioSearchApiAjax = function(){
|
|||||||
var page = href.match(/\?page=([0-9]+)/);
|
var page = href.match(/\?page=([0-9]+)/);
|
||||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
|
||||||
|
|
||||||
loadNextPage(url, $('.materiobase-actuality', _$content), '.actuality-items');
|
loadNextPage(url, '', $('.materiobase-actuality', _$content), '.actuality-items');
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadNextPage(url, $container, target){
|
function loadNextPage(url, keys, $container, target){
|
||||||
trace('MaterioSearchApiAjax :: loadNextPage()');
|
//trace('MaterioSearchApiAjax :: loadNextPage()');
|
||||||
_isloadingresults = true;
|
_isloadingresults = true;
|
||||||
$container.addClass('loading');
|
$container.addClass('loading');
|
||||||
$.getJSON(url, function(json){
|
$.getJSON(url, {'keys':keys}, function(json){
|
||||||
trace('json', json);
|
//trace('json', json);
|
||||||
$container.removeClass('loading');
|
$container.removeClass('loading');
|
||||||
addNextpage(json, target);
|
addNextpage(json, target);
|
||||||
// addNextpageItemByItem($(json.return), target);
|
// addNextpageItemByItem($(json.return), target);
|
||||||
@ -229,7 +230,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
|
|
||||||
// TEST not used
|
// TEST not used
|
||||||
function addNextpageItemByItem($newcontent, container_class){
|
function addNextpageItemByItem($newcontent, container_class){
|
||||||
trace('MaterioSearchApiAjax :: addNextpageItemByItem()');
|
//trace('MaterioSearchApiAjax :: addNextpageItemByItem()');
|
||||||
$('ul.pager', _$content).remove();
|
$('ul.pager', _$content).remove();
|
||||||
$(container_class, _$content).append($(container_class, $newcontent).children('article').eq(0));
|
$(container_class, _$content).append($(container_class, $newcontent).children('article').eq(0));
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
if(!_isloadingresults){
|
if(!_isloadingresults){
|
||||||
_isloadingresults = true;
|
_isloadingresults = true;
|
||||||
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
|
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
|
||||||
trace('viewmode json', json);
|
//trace('viewmode json', json);
|
||||||
_isloadingresults = false;
|
_isloadingresults = false;
|
||||||
if (json.statut == "saved"){
|
if (json.statut == "saved"){
|
||||||
|
|
||||||
@ -314,11 +315,7 @@ MaterioSearchApiAjax = function(){
|
|||||||
return $('.actuality-items', '#content').length;
|
return $('.actuality-items', '#content').length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var materiosearchapiajax = new MaterioSearchApiAjax();
|
var materiosearchapiajax = new MaterioSearchApiAjax();
|
||||||
|
@ -343,12 +343,12 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
|
|||||||
|
|
||||||
#create new list
|
#create new list
|
||||||
$link = l(
|
$link = l(
|
||||||
'<span>' . t('New @name', array('@name' => variable_get('flag_lists_name', t('list')))) . '</span> <i class="icon-plus"></i>',
|
'<i class="icon-plus"></i> <span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
|
||||||
'flag-lists/add/' . $entity->type,
|
'flag-lists/add/' . $entity->type,
|
||||||
array(
|
array(
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'class' => array('flag-lists-create'),
|
'class' => array('flag-lists-create'),
|
||||||
'title' => t('create a new @name and use it.', array('@name'=>variable_get('flag_lists_name', t('list')))),
|
'title' => t('create a new @name and use it.', array('@name'=>t(variable_get('flag_lists_name', 'list')))),
|
||||||
'nid' => $entity->nid,
|
'nid' => $entity->nid,
|
||||||
'token' => flag_get_token($entity->nid),
|
'token' => flag_get_token($entity->nid),
|
||||||
),
|
),
|
||||||
@ -481,7 +481,7 @@ function template_preprocess_materio_flag_mylists_list(&$vars) {
|
|||||||
'@name @title contains 1 item.', // in @sec seconds
|
'@name @title contains 1 item.', // in @sec seconds
|
||||||
'@name @title contains @count items.', // in @sec seconds
|
'@name @title contains @count items.', // in @sec seconds
|
||||||
array(
|
array(
|
||||||
'@name' => $vars['name'],
|
'@name' => t($vars['name']),
|
||||||
'@title' => $vars['title'],
|
'@title' => $vars['title'],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -519,7 +519,8 @@ function template_preprocess_materio_search_api_results(array &$variables) {
|
|||||||
function template_preprocess_materio_search_api_actuality(&$vars){
|
function template_preprocess_materio_search_api_actuality(&$vars){
|
||||||
// dsm($vars, 'template_preprocess_materio_search_api_actuality | vars');
|
// dsm($vars, 'template_preprocess_materio_search_api_actuality | vars');
|
||||||
|
|
||||||
$vars['actualities_infos'] = t('Actualities by materiO\'');
|
// $vars['actualities_infos'] = t('Actualities by materiO\'');
|
||||||
|
$vars['actualities_infos'] = t('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,10 +78,13 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|||||||
// build the query
|
// build the query
|
||||||
$index_machine_name = variable_get('autocompletesearchindex', -1);
|
$index_machine_name = variable_get('autocompletesearchindex', -1);
|
||||||
$query = search_api_query($index_machine_name);
|
$query = search_api_query($index_machine_name);
|
||||||
$query_filter = $query->createFilter();
|
|
||||||
$query_filter->condition('name', $tosearch);
|
// $query_filter = $query->createFilter();
|
||||||
|
// $query_filter->condition('name', $tosearch);
|
||||||
// $query_filter->condition('type', 'article');
|
// $query_filter->condition('type', 'article');
|
||||||
$query->filter($query_filter);
|
// $query->filter($query_filter);
|
||||||
|
$query->keys($tosearch);
|
||||||
|
|
||||||
$tags_return = $query->execute();
|
$tags_return = $query->execute();
|
||||||
// dsm($tags_return, '$tags_return');
|
// dsm($tags_return, '$tags_return');
|
||||||
|
|
||||||
@ -90,7 +93,7 @@ function materio_search_api_autocomplete_searchapi($typed = ''){
|
|||||||
$index = search_api_index_load($index_machine_name);
|
$index = search_api_index_load($index_machine_name);
|
||||||
$delta = 0;
|
$delta = 0;
|
||||||
foreach ($index->loadItems(array_keys($tags_return['results'])) as $item) {
|
foreach ($index->loadItems(array_keys($tags_return['results'])) as $item) {
|
||||||
// dsm($item, '$item');
|
//dsm($item, '$item');
|
||||||
//$term_matches[$item->tid] = check_plain($item->name);
|
//$term_matches[$item->tid] = check_plain($item->name);
|
||||||
// $term_matches[check_plain($item->name)] = check_plain($item->name);
|
// $term_matches[check_plain($item->name)] = check_plain($item->name);
|
||||||
// TODO: leave tags with nodes
|
// TODO: leave tags with nodes
|
||||||
@ -125,7 +128,8 @@ function materio_search_api_results_search(){
|
|||||||
//dsm("materio_search_api_results_search");
|
//dsm("materio_search_api_results_search");
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$typed = implode('/', $args);
|
$typed = implode('/', $args);
|
||||||
|
// dsm($typed, 'typed');
|
||||||
|
|
||||||
preg_match_all('/\?page=([0-9]+)/', $typed, $pages);
|
preg_match_all('/\?page=([0-9]+)/', $typed, $pages);
|
||||||
//dsm($pages, '$pages');
|
//dsm($pages, '$pages');
|
||||||
if($pages[0]){
|
if($pages[0]){
|
||||||
@ -140,12 +144,17 @@ function materio_search_api_results_search(){
|
|||||||
preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
|
preg_match_all('/\s?[^\s]+\s?/', $typed, $words);
|
||||||
// dsm($words, "words");
|
// dsm($words, "words");
|
||||||
|
|
||||||
// $escaper = array("+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", '"', "~", "*", "?", ":", '\\');
|
|
||||||
|
// $match = array('\\', '+', '-', '&', '|', '!', '(', ')', '{', '}', '[', ']', '^', '~', '*', '?', ':', '"', ';', ' ');
|
||||||
|
// $replace = array('\\\\', '\\+', '\\-', '\\&', '\\|', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\~', '\\*', '\\?', '\\:', '\\"', '\\;', '\\ ');
|
||||||
foreach ($words[0] as $word) {
|
foreach ($words[0] as $word) {
|
||||||
// $word = preg_replace('/\b-/', '\-', trim($word));
|
|
||||||
// dsm($word);
|
// dsm($word);
|
||||||
$keys[] = trim($word);
|
$word = trim($word);
|
||||||
|
// $word = str_replace($match, $replace, $word);
|
||||||
|
// dsm($word, 'word');
|
||||||
|
$keys[] = $word;
|
||||||
}
|
}
|
||||||
|
// dsm($keys, 'keys');
|
||||||
|
|
||||||
$index_machine_name = variable_get('mainsearchindex', -1);
|
$index_machine_name = variable_get('mainsearchindex', -1);
|
||||||
$index = search_api_index_load($index_machine_name);
|
$index = search_api_index_load($index_machine_name);
|
||||||
@ -160,11 +169,12 @@ function materio_search_api_results_search(){
|
|||||||
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
|
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
|
||||||
|
|
||||||
if ($keys) {
|
if ($keys) {
|
||||||
|
// TODO: cache the results with cache graceful : http://drupal.org/project/cache_graceful
|
||||||
try {
|
try {
|
||||||
$limit = variable_get($viewmode.'_limite', '10');
|
$limit = variable_get($viewmode.'_limite', '10');
|
||||||
$offset = pager_find_page() * $limit; //$page*$limit;//
|
$offset = pager_find_page() * $limit; //$page*$limit;//
|
||||||
|
|
||||||
$query = search_api_query($index_machine_name, array('parse mode'=>'direct'))
|
$query = search_api_query($index_machine_name, array('conjunction'=>'OR', 'parse mode'=>'direct'))
|
||||||
->keys(implode(' ', $keys))
|
->keys(implode(' ', $keys))
|
||||||
->range($offset, $limit);
|
->range($offset, $limit);
|
||||||
|
|
||||||
@ -174,10 +184,6 @@ function materio_search_api_results_search(){
|
|||||||
}
|
}
|
||||||
// dsm($filter, 'filter');
|
// dsm($filter, 'filter');
|
||||||
$query->filter($filter);
|
$query->filter($filter);
|
||||||
|
|
||||||
// $bundle_query_filter = $query->createFilter();
|
|
||||||
// $bundle_query_filter->condition('type', 'materiau');//$bundles_filter);
|
|
||||||
// $query->filter($bundle_query_filter);
|
|
||||||
|
|
||||||
$results = $query->execute();
|
$results = $query->execute();
|
||||||
}
|
}
|
||||||
@ -314,7 +320,8 @@ function materio_search_api_actuality(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drupal_set_title(t('Actualities'));
|
// drupal_set_title(t('Actualities'));
|
||||||
|
drupal_set_title(t(''));
|
||||||
|
|
||||||
return theme('materio_search_api_actuality', array(
|
return theme('materio_search_api_actuality', array(
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
@ -326,12 +333,11 @@ function materio_search_api_actuality(){
|
|||||||
|
|
||||||
|
|
||||||
function materio_search_api_viewmode_change($vm){
|
function materio_search_api_viewmode_change($vm){
|
||||||
dsm($vm, 'materio_search_api_viewmode_change');
|
//dsm($vm, 'materio_search_api_viewmode_change');
|
||||||
$rep = _materio_search_api_change_viewmode($vm);
|
$rep = _materio_search_api_change_viewmode($vm);
|
||||||
|
|
||||||
//return 'debug mode for materio_search_api_viewmode_change';
|
//return 'debug mode for materio_search_api_viewmode_change';
|
||||||
// drupal_json_output($rep);
|
// drupal_json_output($rep);
|
||||||
|
|
||||||
drupal_goto();
|
drupal_goto();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ function materio_search_api_ajax_init() {
|
|||||||
// ),
|
// ),
|
||||||
'languages' => isset($languages) ? $languages[1] : array(),
|
'languages' => isset($languages) ? $languages[1] : array(),
|
||||||
)), 'setting');
|
)), 'setting');
|
||||||
|
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +39,10 @@ function materio_search_api_ajax_menu() {
|
|||||||
'access arguments' => array('use materio search api'),
|
'access arguments' => array('use materio search api'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$items['materio_search_api_ajax/search/%'] = $base+array(
|
$items['materio_search_api_ajax/search'] = $base+array(
|
||||||
'title' => 'Matrio base ajax',
|
'title' => 'Matrio base ajax',
|
||||||
'page callback' => 'materio_search_api_ajax_search',
|
'page callback' => 'materio_search_api_ajax_search',
|
||||||
'page arguments' => array(2,3),
|
'page arguments' => array(2),
|
||||||
'access callback' => TRUE,
|
'access callback' => TRUE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
function materio_search_api_ajax_search($keys, $page = 0){
|
function materio_search_api_ajax_search($page = 0){
|
||||||
$debug = false;
|
$debug = false;
|
||||||
global $user, $base_url;
|
global $user, $base_url;
|
||||||
// TODO: set research path configurable
|
// TODO: set research path configurable
|
||||||
@ -10,8 +10,15 @@ function materio_search_api_ajax_search($keys, $page = 0){
|
|||||||
# execute search
|
# execute search
|
||||||
$_GET['page'] = $page;
|
$_GET['page'] = $page;
|
||||||
|
|
||||||
$path = $search_path . '/' . $keys ;//. ($page ? '?page='.$page : '');
|
$keys = $_GET['keys'];
|
||||||
// dsm($menuhandler, 'menuhandler');
|
|
||||||
|
foreach(explode(' ', $keys) as $word){
|
||||||
|
$words[] = rawurlencode($word);
|
||||||
|
}
|
||||||
|
$keys_encoded = implode(' ', $words);
|
||||||
|
// dsm($words, 'words');
|
||||||
|
|
||||||
|
$path = $search_path . '/' . $keys;//. ($page ? '?page='.$page : '');
|
||||||
|
|
||||||
// check if request is ajax, if not rediret to search_api_page page with right keys
|
// check if request is ajax, if not rediret to search_api_page page with right keys
|
||||||
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
|
if (!$debug && (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')) {
|
||||||
@ -19,6 +26,8 @@ function materio_search_api_ajax_search($keys, $page = 0){
|
|||||||
exit ;
|
exit ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: if no permission, redirect to home
|
||||||
|
|
||||||
# content type filter s
|
# content type filter s
|
||||||
// $types = $_GET['types'];
|
// $types = $_GET['types'];
|
||||||
if(isset($_GET['types'])){
|
if(isset($_GET['types'])){
|
||||||
@ -64,6 +73,7 @@ function materio_search_api_ajax_search($keys, $page = 0){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dsm($path, 'path');
|
||||||
// get results
|
// get results
|
||||||
menu_set_active_item($path);
|
menu_set_active_item($path);
|
||||||
$return = menu_execute_active_handler($path, FALSE);
|
$return = menu_execute_active_handler($path, FALSE);
|
||||||
@ -91,8 +101,9 @@ function materio_search_api_ajax_search($keys, $page = 0){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rep = array(
|
$rep = array(
|
||||||
'path'=>$path,
|
'path'=>$search_path.'/'.$keys_encoded,
|
||||||
'keys'=>$keys,
|
'keys'=>$keys,
|
||||||
|
'keys_encoded'=>$keys_encoded,
|
||||||
'search_path'=>$search_path,
|
'search_path'=>$search_path,
|
||||||
'return'=>$return,
|
'return'=>$return,
|
||||||
'active_types'=>$active_types,
|
'active_types'=>$active_types,
|
||||||
@ -103,7 +114,7 @@ function materio_search_api_ajax_search($keys, $page = 0){
|
|||||||
$rep['count'] = $count;
|
$rep['count'] = $count;
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
dsm($rep, 'rep');
|
//dsm($rep, 'rep');
|
||||||
return "debug display";
|
return "debug display";
|
||||||
}else{
|
}else{
|
||||||
drupal_json_output($rep);
|
drupal_json_output($rep);
|
||||||
@ -202,7 +213,7 @@ function materio_search_api_ajax_actuality($page = 0){
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
dsm($rep, 'rep');
|
//dsm($rep, 'rep');
|
||||||
return "debug display";
|
return "debug display";
|
||||||
}else{
|
}else{
|
||||||
drupal_json_output($rep);
|
drupal_json_output($rep);
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
<?php //print render($spellcheck); ?>
|
<?php //print render($spellcheck); ?>
|
||||||
<div class="search-results">
|
<div class="search-results">
|
||||||
<?php //dsm($items, '$items'); ?>
|
<?php //dsm($items, '$items'); ?>
|
||||||
|
<?php
|
||||||
|
// TODO: use cache system to gain in speed, view http://drupal.org/node/930760
|
||||||
|
?>
|
||||||
<?php print render(entity_view($index->item_type, $items, $variables['view_mode'])); ?>
|
<?php print render(entity_view($index->item_type, $items, $variables['view_mode'])); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php print $pager; ?>
|
<?php print $pager; ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user