|
@@ -17,7 +17,7 @@ MaterioFlag = function(){
|
|
|
|
|
|
$(document)
|
|
|
.bind('flagGlobalAfterLinkUpdate', onFlaging)
|
|
|
- .bind('resultscompleted resultschanged', onResultsUpdated)
|
|
|
+ .bind('resultscompleted resultschanged previewloaded', onResultsUpdated)
|
|
|
.bind('init-scroller-pager', onInitScrollerPager)
|
|
|
.bind('load-scroller-pager', onLoadScrollerPager)
|
|
|
.bind('view-mode-changed', onViewModeChanged)
|
|
@@ -87,14 +87,14 @@ MaterioFlag = function(){
|
|
|
.bind('click', onClickCreatLink)
|
|
|
.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);
|
|
|
|
|
|
$('a.open-list', this).bind('click', onClickOpenLink);
|
|
|
-
|
|
|
+
|
|
|
}).addClass('ajax-processed');
|
|
|
break;
|
|
|
}
|
|
@@ -106,7 +106,7 @@ MaterioFlag = function(){
|
|
|
type : 'my'+type+'-block-builded',
|
|
|
block : block,
|
|
|
name : name
|
|
|
- });
|
|
|
+ });
|
|
|
},10);
|
|
|
|
|
|
// trace('MaterioFlag :: activename', activename);
|
|
@@ -115,7 +115,7 @@ MaterioFlag = function(){
|
|
|
|
|
|
// trace('MaterioFlag :: activename', activename);
|
|
|
if(activename)
|
|
|
- showPreview(activename, block);
|
|
|
+ showPreview(activename, block);
|
|
|
};
|
|
|
|
|
|
function refreshBlocks(name){
|
|
@@ -125,17 +125,17 @@ MaterioFlag = function(){
|
|
|
}else if($('#block-materio-flag-materio-flag-mylists').length){
|
|
|
var type = 'lists';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(type != undefined){
|
|
|
var id = '#block-materio-flag-materio-flag-my'+type;
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/refresh/block/'+type;
|
|
|
$.getJSON(url, function(json){
|
|
|
//trace('MaterioFlag :: block refreshed '+type, json);
|
|
|
-
|
|
|
+
|
|
|
$(id).replaceWith(json.block);
|
|
|
$('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);
|
|
|
-
|
|
|
- buildBlocks(name);
|
|
|
+
|
|
|
+ buildBlocks(name);
|
|
|
|
|
|
$.event.trigger({
|
|
|
type : 'my'+type+'-block-updated',
|
|
@@ -150,7 +150,7 @@ MaterioFlag = function(){
|
|
|
//trace('MaterioFlag :: ajaxifyLinks', container);
|
|
|
|
|
|
container = ((container != null) ? container : 'body');
|
|
|
-
|
|
|
+
|
|
|
// trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
|
|
|
if (typeof Drupal.flagLink != 'undefined')
|
|
|
Drupal.flagLink(container);
|
|
@@ -161,12 +161,11 @@ MaterioFlag = function(){
|
|
|
.bind('click', onUnflagList)
|
|
|
.addClass('ajax-processed');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$('a.flag-lists-create:not(.ajax-processed)', container)
|
|
|
.bind('click', onClickCreatLink)
|
|
|
.addClass('ajax-processed');
|
|
|
-
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -191,9 +190,9 @@ MaterioFlag = function(){
|
|
|
//trace('MaterioFlag :: onClickClosePreview', event);
|
|
|
eraseCookie('materiomyflaglistsopened');
|
|
|
if($(this).attr('name') == 'bookmarks'){
|
|
|
- $(this).parents('.block').find('section.bookmarks').removeClass('active');
|
|
|
+ $(this).parents('.block').find('section.bookmarks').removeClass('active');
|
|
|
}else{
|
|
|
- $(this).parents('section.flag-list').removeClass('active');
|
|
|
+ $(this).parents('section.flag-list').removeClass('active');
|
|
|
}
|
|
|
|
|
|
$.event.trigger('init-layout');
|
|
@@ -214,7 +213,7 @@ MaterioFlag = function(){
|
|
|
function loadList(fid){
|
|
|
//trace('MaterioFlag :: loadList | fid', fid);
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/ajax/list/'+fid;
|
|
|
-
|
|
|
+
|
|
|
$.event.trigger('loading-content');
|
|
|
|
|
|
$.getJSON(url, {'current_path':document.location.href},function(json){
|
|
@@ -231,14 +230,14 @@ MaterioFlag = function(){
|
|
|
if(json.rendered){
|
|
|
|
|
|
$('.inner-content','#content').html(json.rendered);
|
|
|
-
|
|
|
+
|
|
|
$.event.trigger('loaded-content');
|
|
|
-
|
|
|
+
|
|
|
// no need of ajaxifylinks because it's triggered with resultschanged
|
|
|
// ajaxifyLinks('#content');
|
|
|
|
|
|
var path = Drupal.settings.basePath + Drupal.settings.pathPrefix + json.path;
|
|
|
-
|
|
|
+
|
|
|
$.event.trigger({
|
|
|
type : 'new-history-page',
|
|
|
path : path,
|
|
@@ -246,10 +245,10 @@ MaterioFlag = function(){
|
|
|
content : json.rendered
|
|
|
});
|
|
|
|
|
|
- // TODO: change language links for folders
|
|
|
+ // TODO: change language links for folders
|
|
|
// for (language in Drupal.settings.materio_search_api_ajax.languages) {
|
|
|
// var l = Drupal.settings.materio_search_api_ajax.languages[language];
|
|
|
- // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
|
|
|
+ // $('#block-locale-language li.'+language+' a').attr('href', Drupal.settings.basePath + l.prefix+'/' + json.search_path + '/' + json.keys)
|
|
|
// };
|
|
|
|
|
|
triggerContentChanged();
|
|
@@ -308,7 +307,7 @@ MaterioFlag = function(){
|
|
|
case 'cancel':
|
|
|
//trace('MaterioFlag :: cancel',event);
|
|
|
$(this).parents('#modal').remove();
|
|
|
-
|
|
|
+
|
|
|
// google analytics
|
|
|
$.event.trigger({
|
|
|
type:"record-stat",
|
|
@@ -333,11 +332,11 @@ MaterioFlag = function(){
|
|
|
createList($modal, type, title, $link);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return false;
|
|
|
})
|
|
|
.parents('form').find('input[type="text"]').focus();
|
|
|
- // TODO: esc keypressed close the form
|
|
|
+ // TODO: esc keypressed close the form
|
|
|
};
|
|
|
|
|
|
function createList($modal, type, title, $link){
|
|
@@ -365,7 +364,7 @@ MaterioFlag = function(){
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
function flagEntityWithList(name, nid, token){
|
|
|
//trace('MaterioFlag :: flagEntityWithList | name', name);
|
|
|
// var ret;
|
|
@@ -378,7 +377,7 @@ MaterioFlag = function(){
|
|
|
success: function (data2) {
|
|
|
//trace('MaterioFlag :: node taged with newly created list : data2', data2)
|
|
|
if (data2.status) {
|
|
|
-
|
|
|
+
|
|
|
// google analytics
|
|
|
$.event.trigger({
|
|
|
type : "record-stat",
|
|
@@ -410,7 +409,7 @@ MaterioFlag = function(){
|
|
|
nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
|
|
|
});
|
|
|
// trace('MaterioFlag :: nids', nids);
|
|
|
-
|
|
|
+
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
|
|
|
$.getJSON(url, {nids:nids.join(";")}, function(data) {
|
|
|
// trace('MaterioFlag :: data', data);
|
|
@@ -421,14 +420,14 @@ MaterioFlag = function(){
|
|
|
|
|
|
// trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
|
|
|
// if (typeof Drupal.flagLink != 'undefined')
|
|
|
- // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
|
|
|
-
|
|
|
+ // Drupal.flagLink($('.node-'+nid+' .flag-lists-entity-links'));
|
|
|
+
|
|
|
// TODO: sortir ajaxifyLinks de la boucle, je pense que ça prend trop de ressources
|
|
|
ajaxifyLinks('.node-'+nid+' .flag-lists-entity-links');
|
|
|
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$.event.trigger({
|
|
|
type : 'materioflag-nodelinks-updated',
|
|
|
nids : nids
|
|
@@ -440,12 +439,12 @@ MaterioFlag = function(){
|
|
|
*/
|
|
|
function onCLickEditList(event){
|
|
|
//trace('MaterioFlag :: onCLickEditList | event', event);
|
|
|
- // TODO: empécher le double formulaire
|
|
|
+ // TODO: empécher le double formulaire
|
|
|
event.preventDefault();
|
|
|
var $link = $(event.currentTarget);
|
|
|
var lid = $link.attr('href').match(/[^\/]*$/);
|
|
|
var type = 'materiau'; // this is cheap
|
|
|
-
|
|
|
+
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
|
|
|
|
|
|
$.getJSON(url, function(json){
|
|
@@ -485,14 +484,14 @@ MaterioFlag = function(){
|
|
|
case 'cancel':
|
|
|
//trace('MaterioFlag :: cancel',event);
|
|
|
$(this).parents('#modal').remove();
|
|
|
-
|
|
|
+
|
|
|
// google analytics
|
|
|
- var action = 'cancel edit form';
|
|
|
+ var action = 'cancel edit form';
|
|
|
|
|
|
break;
|
|
|
case 'save':
|
|
|
//trace('MaterioFlag :: create',event);
|
|
|
-
|
|
|
+
|
|
|
// google analytics
|
|
|
var action = "submit edit form";
|
|
|
|
|
@@ -503,14 +502,14 @@ MaterioFlag = function(){
|
|
|
|
|
|
if(confirm('Do you realy want to delete your '+title+' folder ?')){
|
|
|
var action = "submit delete form";
|
|
|
- deleteList($modal, fid);
|
|
|
+ deleteList($modal, fid);
|
|
|
}else{
|
|
|
var action = "cancel delete form";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// google analytics
|
|
|
$.event.trigger({
|
|
|
type:"record-stat",
|
|
@@ -521,7 +520,7 @@ MaterioFlag = function(){
|
|
|
return false;
|
|
|
})
|
|
|
.parents('form').find('input[type="text"]').focus();
|
|
|
- // TODO: esc keypressed close the form
|
|
|
+ // TODO: esc keypressed close the form
|
|
|
};
|
|
|
|
|
|
function saveList($modal, fid, name, title){
|
|
@@ -538,7 +537,7 @@ MaterioFlag = function(){
|
|
|
}
|
|
|
else {
|
|
|
//trace('MaterioFlag :: saved list : data', data);
|
|
|
-
|
|
|
+
|
|
|
$.event.trigger({
|
|
|
type : 'list-edited',
|
|
|
name : data.listname,
|
|
@@ -627,7 +626,7 @@ MaterioFlag = function(){
|
|
|
var $newcontent = $(json.rendered),
|
|
|
$newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
|
|
|
$newpager = $('ul.pager', $newcontent);
|
|
|
-
|
|
|
+
|
|
|
$(container_class, '#content').append($newitems);
|
|
|
$('ul.pager', '#content').replaceWith($newpager.hide());
|
|
|
|
|
@@ -672,8 +671,8 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * cookies
|
|
|
+ /**
|
|
|
+ * cookies
|
|
|
*/
|
|
|
function createCookie(name,value,days) {
|
|
|
if (days) {
|
|
@@ -709,5 +708,5 @@ MaterioFlag = function(){
|
|
|
$(document).ready(function() {
|
|
|
var materioflag = new MaterioFlag();
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
})(jQuery);
|