|
@@ -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);
|
|
|
|
- // 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);
|
|
|
|
- });
|
|
|
|
|
|
+ //trace('MaterioFlag :: buildBlocks', activename);
|
|
|
|
+
|
|
|
|
+ if($('#block-materio-flag-materio-flag-mybookmarks').length){
|
|
|
|
+ var type = 'bookmarks';
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ }).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);
|
|
|
|
|
|
- // 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');
|
|
|
|
|
|
|
|
// 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);
|