bookmarks fixing
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
454adf9478
commit
06a4d254c2
File diff suppressed because one or more lines are too long
@ -52,40 +52,48 @@ MaterioFlag = function(){
|
|||||||
var block = '#block-materio-flag-materio-flag-mylists';
|
var block = '#block-materio-flag-materio-flag-mylists';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == 'lists'){
|
switch(type){
|
||||||
|
case 'bookmarks':
|
||||||
|
var name = type;
|
||||||
|
$('h2 .listname', block).attr('name', name).bind('click', onClickShowPreview);
|
||||||
|
$('<i class="icon-remove"></i>').appendTo($('h2', block)).attr('name', name).bind('click', onClickClosePreview);
|
||||||
|
// $('<span class="preview"><i class="icon-eye-open"></i></span>').appendTo($('h2', block)).bind('click', onClickShowPreview);
|
||||||
|
// if(!readCookie('materiobookmarkspreviewopened')){
|
||||||
|
// showPreview('bookmarks', block);
|
||||||
|
// }else{
|
||||||
|
// }
|
||||||
|
break;
|
||||||
|
case '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');
|
||||||
|
|
||||||
// nav block
|
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
||||||
$('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
|
// trace('MaterioFlag :: name', name);
|
||||||
$this = $(this)
|
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
||||||
.bind('click', onClickOpenLink)
|
});
|
||||||
.addClass('ajax-processed');
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
$('a.open-list', this).bind('click', onClickOpenLink);
|
||||||
// trace('MaterioFlag :: name', name);
|
|
||||||
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
|
||||||
});
|
|
||||||
|
|
||||||
// preview block
|
}).addClass('ajax-processed');
|
||||||
$('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
|
break;
|
||||||
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);
|
|
||||||
|
|
||||||
}).addClass('ajax-processed');
|
|
||||||
|
|
||||||
// trigger refresh block event for enabling lazyload images
|
|
||||||
setTimeout(function(){
|
|
||||||
$.event.trigger({
|
|
||||||
type : 'my'+type+'-block-builded',
|
|
||||||
block : block,
|
|
||||||
name : name
|
|
||||||
});
|
|
||||||
},10);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trigger refresh block event for enabling lazyload images
|
||||||
|
setTimeout(function(){
|
||||||
|
$.event.trigger({
|
||||||
|
type : 'my'+type+'-block-builded',
|
||||||
|
block : block,
|
||||||
|
name : name
|
||||||
|
});
|
||||||
|
},10);
|
||||||
|
|
||||||
// trace('MaterioFlag :: activename', activename);
|
// trace('MaterioFlag :: activename', activename);
|
||||||
if(activename == undefined)
|
if(activename == undefined)
|
||||||
@ -93,9 +101,7 @@ MaterioFlag = function(){
|
|||||||
|
|
||||||
// trace('MaterioFlag :: activename', activename);
|
// trace('MaterioFlag :: activename', activename);
|
||||||
if(activename)
|
if(activename)
|
||||||
showPreview(activename);
|
showPreview(activename, block);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function refreshBlocks(name){
|
function refreshBlocks(name){
|
||||||
@ -136,6 +142,14 @@ MaterioFlag = function(){
|
|||||||
if (typeof Drupal.flagLink != 'undefined')
|
if (typeof Drupal.flagLink != 'undefined')
|
||||||
Drupal.flagLink(container);
|
Drupal.flagLink(container);
|
||||||
|
|
||||||
|
if(isList()){
|
||||||
|
var fid = $('.materio-flags-list', '#content').attr('fid');
|
||||||
|
$('li.unflag-action.fid-'+fid+' a:not(.ajax-processed), li.flag-bookmarks a.unflag-action:not(.ajax-processed)')
|
||||||
|
.bind('click', onUnflagList)
|
||||||
|
.addClass('ajax-processed');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$('a.flag-lists-create:not(.ajax-processed)', container)
|
$('a.flag-lists-create:not(.ajax-processed)', container)
|
||||||
.bind('click', onClickCreatLink)
|
.bind('click', onClickCreatLink)
|
||||||
.addClass('ajax-processed');
|
.addClass('ajax-processed');
|
||||||
@ -150,12 +164,12 @@ MaterioFlag = function(){
|
|||||||
*/
|
*/
|
||||||
function onClickShowPreview(event){
|
function onClickShowPreview(event){
|
||||||
//trace('MaterioFlag :: onClickShowPreview', event);
|
//trace('MaterioFlag :: onClickShowPreview', event);
|
||||||
showPreview($(this).attr('name'));
|
showPreview($(this).attr('name'), $(this).parent('.block').attr('id'));
|
||||||
};
|
};
|
||||||
|
|
||||||
function showPreview(name){
|
function showPreview(name, block){
|
||||||
//trace('MaterioFlag :: showPreview', name);
|
//trace('MaterioFlag :: showPreview', name);
|
||||||
$('section.'+name, '#block-materio-flag-materio-flag-mylists').addClass('active')
|
$('section.'+name, block).addClass('active')
|
||||||
.siblings('section').removeClass('active');
|
.siblings('section').removeClass('active');
|
||||||
|
|
||||||
createCookie('materiomyflaglistsopened', name, 1);
|
createCookie('materiomyflaglistsopened', name, 1);
|
||||||
@ -166,7 +180,11 @@ 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');
|
if($(this).attr('name') == 'bookmarks'){
|
||||||
|
$(this).parents('.block').find('section.bookmarks').removeClass('active');
|
||||||
|
}else{
|
||||||
|
$(this).parents('section.flag-list').removeClass('active');
|
||||||
|
}
|
||||||
|
|
||||||
$.event.trigger('init-layout');
|
$.event.trigger('init-layout');
|
||||||
};
|
};
|
||||||
@ -321,8 +339,13 @@ MaterioFlag = function(){
|
|||||||
// $('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);
|
||||||
|
if($link.attr('nid') && $link.attr('token')){
|
||||||
|
flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
|
||||||
|
}else{
|
||||||
|
refreshBlocks(data.flag.name);
|
||||||
|
refreshNodeLinks();
|
||||||
|
}
|
||||||
|
|
||||||
flagEntityWithList(data.flag.name, $link.attr('nid'), $link.attr('token'));
|
|
||||||
$modal.remove();
|
$modal.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -523,7 +546,16 @@ MaterioFlag = function(){
|
|||||||
$modal.remove();
|
$modal.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onUnflagList()
|
||||||
|
*/
|
||||||
|
function onUnflagList(event){
|
||||||
|
//trace('onUnflagList', event);
|
||||||
|
$(this).parents('article.node').addClass('removed');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -37,13 +37,18 @@ function materio_flag_menu() {
|
|||||||
'file' => 'materio_flag.pages.inc',
|
'file' => 'materio_flag.pages.inc',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$items['materioflag/refresh/block/bookmarks'] = $base+array(
|
$items['materioflag/refresh/block/bookmarks'] = $base+array(
|
||||||
'access arguments' => array('flag bookmarks'),
|
'access arguments' => array('flag bookmarks'),
|
||||||
'page callback' => 'materio_flag_refresh_block',
|
'page callback' => 'materio_flag_refresh_block',
|
||||||
'page arguments' => array(3),
|
'page arguments' => array(3),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$items['bookmarks'] = $base+array(
|
||||||
|
'access arguments' => array('flag bookmarks'),
|
||||||
|
'page callback' => 'materio_flag_user_bookmarks',
|
||||||
|
'page arguments' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
$items['materioflag/refresh/block/lists'] = $base+array(
|
$items['materioflag/refresh/block/lists'] = $base+array(
|
||||||
'access arguments' => array('create flag lists'),
|
'access arguments' => array('create flag lists'),
|
||||||
'page callback' => 'materio_flag_refresh_block',
|
'page callback' => 'materio_flag_refresh_block',
|
||||||
@ -156,7 +161,9 @@ function materio_flag_block_view($delta = '') {
|
|||||||
foreach ($userflags['bookmarks'] as $nid => $flag) {
|
foreach ($userflags['bookmarks'] as $nid => $flag) {
|
||||||
$userbookmarks[] = node_load($nid);
|
$userbookmarks[] = node_load($nid);
|
||||||
}
|
}
|
||||||
$block['subject'] = t('My bookmarks (@len)', array("@len"=>count($userbookmarks)));
|
// TODO: put this title generation on a theme function
|
||||||
|
$subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
|
||||||
|
$block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); //
|
||||||
$block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
|
$block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
|
||||||
}else{
|
}else{
|
||||||
$block['subject'] = t('My bookmarks');
|
$block['subject'] = t('My bookmarks');
|
||||||
@ -215,16 +222,17 @@ function materio_flag_block_view($delta = '') {
|
|||||||
$flag->flaged_content = $flaged_content;
|
$flag->flaged_content = $flaged_content;
|
||||||
$flags[$name] = $flag;
|
$flags[$name] = $flag;
|
||||||
}
|
}
|
||||||
if($flags){
|
// if($flags){
|
||||||
// $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
|
// $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
|
||||||
$block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
|
$block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
|
||||||
|
|
||||||
$block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
|
$block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
|
||||||
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
|
// $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
|
||||||
}
|
// }
|
||||||
# what happend if no flags yet
|
# what happend if no flags yet
|
||||||
// else{
|
// else{
|
||||||
// $block['content'] = t('No !listname yet. Add !listname on clicking on results star', array('!listname'=>variable_get('flag_lists_name', 'list')));
|
// $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
|
||||||
|
// // $block['content'] = t('No !listname yet. Add !listname on clicking on results star', array('!listname'=>variable_get('flag_lists_name', 'list')));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -339,7 +347,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
|
|||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'data' => $link,
|
'data' => $link,
|
||||||
'class' => array('flag-lists-link', $action.'-action'),
|
'class' => array('flag-lists-link', $action.'-action', 'fid-'.$flag->fid),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -333,6 +333,54 @@ function materio_flag_nodelinks(){
|
|||||||
drupal_json_output($rep);
|
drupal_json_output($rep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function materio_flag_user_bookmarks(){
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
drupal_set_title(t('My bookmarks'), PASS_THROUGH);
|
||||||
|
|
||||||
|
$flaged = flag_get_user_flags('node');
|
||||||
|
// dsm($flaged, 'flaged');
|
||||||
|
|
||||||
|
$flag = flag_get_flag('bookmarks');
|
||||||
|
$flaged_content = $flaged['bookmarks'];
|
||||||
|
// dsm($flaged_content, 'flaged_content');
|
||||||
|
|
||||||
|
$viewmode = isset($user->data['materiosearchapi_viewmode']) ? $user->data['materiosearchapi_viewmode'] : variable_get('defaultviewmode', 'full');
|
||||||
|
|
||||||
|
$limit = variable_get($viewmode.'_limite', '10');
|
||||||
|
$offset = pager_find_page() * $limit;
|
||||||
|
$count = count($flaged_content);
|
||||||
|
$max = $offset+$limit > $count ? $count : $offset+$limit;
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($flaged_content as $id => $item) {
|
||||||
|
if($i >= $offset){
|
||||||
|
if($i < $max){
|
||||||
|
if($item->entity_type == 'node'){
|
||||||
|
$items[] = node_load($id);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret['#items'] = $items;
|
||||||
|
$ret['#theme'] = 'materio_flag_mylists_list';
|
||||||
|
$ret['#view_mode'] = $viewmode;
|
||||||
|
$ret['#fid'] = $flag->fid;
|
||||||
|
$ret['#count'] = $count;
|
||||||
|
$ret['#name'] = variable_get('flag_lists_name', 'list');
|
||||||
|
$ret['#title'] = $flag->title;
|
||||||
|
|
||||||
|
pager_default_initialize($count, $limit);
|
||||||
|
$ret['#pager'] = theme('pager');
|
||||||
|
|
||||||
|
drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag-ck.js');
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
function materio_flag_user_lists($fid){
|
function materio_flag_user_lists($fid){
|
||||||
global $user;
|
global $user;
|
||||||
$flag = flag_lists_get_flag($fid);
|
$flag = flag_lists_get_flag($fid);
|
||||||
@ -368,7 +416,6 @@ function materio_flag_user_lists($fid){
|
|||||||
$ret['#pager'] = theme('pager');
|
$ret['#pager'] = theme('pager');
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function materio_flag_ajax_list($fid, $page = 0){
|
function materio_flag_ajax_list($fid, $page = 0){
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
<section class="mybookmarks">
|
<section class="bookmarks">
|
||||||
<?php print render(entity_view('node', $bookmarks, $viewmode)); ?>
|
<?php print render(entity_view('node', $bookmarks, $viewmode)); ?>
|
||||||
</section>
|
</section>
|
@ -1,21 +1,39 @@
|
|||||||
<section class="mylists">
|
<section class="mylists">
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach ($flags as $name => $flag): ?>
|
<?php if($flags): ?>
|
||||||
<?php //dsm($flag, 'flag') ;?>
|
<?php foreach ($flags as $name => $flag): ?>
|
||||||
<li class="flaglist <?php print $flag->name; ?>">
|
<?php //dsm($flag, 'flag') ;?>
|
||||||
<?php print l($flag->title . '<span class="count">('.count($flag->flaged_content).')</span>', 'lists/'.$flag->fid, array('html'=>true,'attributes'=>array('class'=>array('open-list', $flag->name)))); ?>
|
<li class="flaglist <?php print $flag->name; ?>">
|
||||||
<?php if(flag_lists_is_owner('edit', $flag->fid)): ?>
|
<?php print l($flag->title . '<span class="count">('.count($flag->flaged_content).')</span>', 'lists/'.$flag->fid, array('html'=>true,'attributes'=>array('class'=>array('open-list', $flag->name)))); ?>
|
||||||
<?php
|
<?php if(flag_lists_is_owner('edit', $flag->fid)): ?>
|
||||||
print l('<i class="icon-wrench"></i>',
|
<?php
|
||||||
'flags/lists/edit/'.$flag->fid,
|
print l('<i class="icon-wrench"></i>',
|
||||||
array(
|
'flags/lists/edit/'.$flag->fid,
|
||||||
'html'=>true,
|
array(
|
||||||
'attributes'=>array('class'=>array('edit-list', $flag->name)),
|
'html'=>true,
|
||||||
)
|
'attributes'=>array('class'=>array('edit-list', $flag->name)),
|
||||||
);
|
)
|
||||||
?>
|
);
|
||||||
<?php endif; ?>
|
?>
|
||||||
</li>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php
|
||||||
|
#create new list
|
||||||
|
$create_link = l(
|
||||||
|
'<i class="icon-plus"></i> <span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
|
||||||
|
'flag-lists/add/materiau',
|
||||||
|
array(
|
||||||
|
'attributes' => array(
|
||||||
|
'class' => array('flag-lists-create'),
|
||||||
|
'title' => t('create a new @name.', array('@name'=>t(variable_get('flag_lists_name', 'list')))),
|
||||||
|
),
|
||||||
|
'html' => TRUE,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<li class="flag-lists-create"><?php print $create_link; ?> </li>
|
||||||
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
Loading…
x
Reference in New Issue
Block a user