bookmarks fixing

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2013-03-07 19:04:15 +01:00
parent 454adf9478
commit 06a4d254c2
6 changed files with 169 additions and 64 deletions

File diff suppressed because one or more lines are too long

View File

@@ -52,40 +52,48 @@ MaterioFlag = function(){
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
$('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);
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);
});
$('a.open-list', this).bind('click', onClickOpenLink);
// 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);
}).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);
}).addClass('ajax-processed');
break;
}
// 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);
if(activename == undefined)
@@ -93,9 +101,7 @@ MaterioFlag = function(){
// trace('MaterioFlag :: activename', activename);
if(activename)
showPreview(activename);
showPreview(activename, block);
};
function refreshBlocks(name){
@@ -136,6 +142,14 @@ MaterioFlag = function(){
if (typeof Drupal.flagLink != 'undefined')
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)
.bind('click', onClickCreatLink)
.addClass('ajax-processed');
@@ -150,12 +164,12 @@ MaterioFlag = function(){
*/
function 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);
$('section.'+name, '#block-materio-flag-materio-flag-mylists').addClass('active')
$('section.'+name, block).addClass('active')
.siblings('section').removeClass('active');
createCookie('materiomyflaglistsopened', name, 1);
@@ -166,7 +180,11 @@ MaterioFlag = function(){
function onClickClosePreview(event){
//trace('MaterioFlag :: onClickClosePreview', event);
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');
};
@@ -321,8 +339,13 @@ MaterioFlag = function(){
// $('input.name', $(this)).val('');
// dialog.dialog('close');
//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();
}
});
@@ -523,7 +546,16 @@ MaterioFlag = function(){
$modal.remove();
}
});
}
};
/**
* onUnflagList()
*/
function onUnflagList(event){
//trace('onUnflagList', event);
$(this).parents('article.node').addClass('removed');
};
/**
*