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