|
@@ -21,7 +21,7 @@ MaterioFlag = function(){
|
|
|
.bind('view-mode-changed', onViewModeChanged)
|
|
|
.bind('history-state-change', onHistoryStateChange);
|
|
|
|
|
|
- ajaxifyLinks();
|
|
|
+ // ajaxifyLinks();
|
|
|
|
|
|
// trigger updated event for direct html loading
|
|
|
if(isList()){
|
|
@@ -42,7 +42,7 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function buildBlocks(activename){
|
|
|
- //trace('MaterioFlag :: buildBlocks', activename);
|
|
|
+ //trace('MaterioFlag :: buildBlocks | activename', activename);
|
|
|
|
|
|
if($('#block-materio-flag-materio-flag-mybookmarks').length){
|
|
|
var type = 'bookmarks';
|
|
@@ -66,6 +66,7 @@ MaterioFlag = function(){
|
|
|
case 'lists':
|
|
|
// nav block
|
|
|
$('a.open-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav').each(function(index){
|
|
|
+ //trace('nav block a.open-list this', this);
|
|
|
$this = $(this)
|
|
|
.bind('click', onClickOpenLink)
|
|
|
.addClass('ajax-processed');
|
|
@@ -74,6 +75,16 @@ MaterioFlag = function(){
|
|
|
// trace('MaterioFlag :: name', name);
|
|
|
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
|
|
});
|
|
|
+
|
|
|
+ $('a.edit-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
|
|
|
+ .bind('click', onCLickEditList)
|
|
|
+ .addClass('ajax-processed');
|
|
|
+
|
|
|
+
|
|
|
+ $('a.flag-lists-create:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists-nav')
|
|
|
+ .bind('click', onClickCreatLink)
|
|
|
+ .addClass('ajax-processed');
|
|
|
+
|
|
|
|
|
|
// preview block
|
|
|
$('section.flag-list:not(.ajax-processed)', '#block-materio-flag-materio-flag-mylists').each(function(index){
|
|
@@ -86,6 +97,7 @@ MaterioFlag = function(){
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// trigger refresh block event for enabling lazyload images
|
|
|
setTimeout(function(){
|
|
|
$.event.trigger({
|
|
@@ -130,7 +142,6 @@ MaterioFlag = function(){
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- ajaxifyLinks();
|
|
|
};
|
|
|
|
|
|
function ajaxifyLinks(container){
|
|
@@ -154,9 +165,6 @@ MaterioFlag = function(){
|
|
|
.bind('click', onClickCreatLink)
|
|
|
.addClass('ajax-processed');
|
|
|
|
|
|
- $('a.edit-list:not(.ajax-processed)', container)
|
|
|
- .bind('click', onCLickEditList)
|
|
|
- .addClass('ajax-processed');
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -202,6 +210,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');
|
|
@@ -259,6 +268,7 @@ MaterioFlag = function(){
|
|
|
* onClickCreatLink(event)
|
|
|
*/
|
|
|
function onClickCreatLink(event){
|
|
|
+ //trace('MaterioFlag :: onClickCreatLink | event', event);
|
|
|
event.preventDefault();
|
|
|
var $link = $(event.currentTarget);
|
|
|
var type = $link.attr('href').match(/[^\/]*$/);
|
|
@@ -273,7 +283,7 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function showCreateListForm(json, $link){
|
|
|
-
|
|
|
+ //trace('MaterioFlag :: showCreateListForm | json', json);
|
|
|
// google analytics
|
|
|
$.event.trigger({
|
|
|
type:"record-stat",
|
|
@@ -329,6 +339,9 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function createList($modal, type, title, $link){
|
|
|
+ //trace('materioflag :: createList | title', title);
|
|
|
+ $('.flag-lists-create').addClass('loading');
|
|
|
+
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'flag-lists/add/'+type+'/js';
|
|
|
$.getJSON(url, {name:title}, function(data) {
|
|
|
if (data.error) {
|
|
@@ -352,6 +365,7 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function flagEntityWithList(name, nid, token){
|
|
|
+ //trace('MaterioFlag :: flagEntityWithList | name', name);
|
|
|
// var ret;
|
|
|
// Send POST request
|
|
|
$.ajax({
|
|
@@ -385,11 +399,14 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function refreshNodeLinks(){
|
|
|
-
|
|
|
+ //trace('MaterioFlag :: refreshNodeLinks');
|
|
|
var nids = new Array();
|
|
|
- $('.flag-lists-entity-links').parents('.node').each(function(index) {
|
|
|
- nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
|
|
|
- });
|
|
|
+ $('.flag-lists-entity-links')
|
|
|
+ // .addClass('loading')
|
|
|
+ .parents('.node')
|
|
|
+ .each(function(index) {
|
|
|
+ nids.push($(this).attr('class').match(/node-([0-9]+)/)[1]);
|
|
|
+ });
|
|
|
// trace('MaterioFlag :: nids', nids);
|
|
|
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/nodelinks';
|
|
@@ -403,7 +420,8 @@ MaterioFlag = function(){
|
|
|
// trace('MaterioFlag :: typeof Drupal.flagLink', typeof Drupal.flagLink);
|
|
|
// if (typeof Drupal.flagLink != 'undefined')
|
|
|
// 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');
|
|
|
|
|
|
}
|
|
@@ -419,6 +437,7 @@ MaterioFlag = function(){
|
|
|
* onCLickEditList(event)
|
|
|
*/
|
|
|
function onCLickEditList(event){
|
|
|
+ //trace('MaterioFlag :: onCLickEditList | event', event);
|
|
|
// TODO: empécher le double formulaire
|
|
|
event.preventDefault();
|
|
|
var $link = $(event.currentTarget);
|
|
@@ -435,7 +454,7 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function showEditListForm(json, $link){
|
|
|
-
|
|
|
+ //trace('MaterioFlag :: showEditListForm | json', json);
|
|
|
// google analytics
|
|
|
$.event.trigger({
|
|
|
type:"record-stat",
|
|
@@ -475,12 +494,12 @@ MaterioFlag = function(){
|
|
|
// google analytics
|
|
|
var action = "submit edit form";
|
|
|
|
|
|
- editList($modal, fid, name, title);
|
|
|
+ saveList($modal, fid, name, title);
|
|
|
break;
|
|
|
case 'delete':
|
|
|
//trace('MaterioFlag :: delete',event);
|
|
|
|
|
|
- if(confirm('Do you realy want to delete the folder '+title+'?')){
|
|
|
+ if(confirm('Do you realy want to delete your '+title+' folder ?')){
|
|
|
var action = "submit delete form";
|
|
|
deleteList($modal, fid);
|
|
|
}else{
|
|
@@ -503,7 +522,11 @@ MaterioFlag = function(){
|
|
|
// TODO: esc keypressed close the form
|
|
|
};
|
|
|
|
|
|
- function editList($modal, fid, name, title){
|
|
|
+ function saveList($modal, fid, name, title){
|
|
|
+ //trace('MaterioFlag :: saveList | fid : '+fid+'| name', name);
|
|
|
+
|
|
|
+ $('.flag-lists-link.fid-'+fid).addClass('loading');
|
|
|
+
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlist/'+fid+'/'+name+'/'+title;
|
|
|
$.getJSON(url, function(data) {
|
|
|
if (data.error) {
|
|
@@ -529,7 +552,10 @@ MaterioFlag = function(){
|
|
|
};
|
|
|
|
|
|
function deleteList($modal, fid){
|
|
|
- // prompt('are you sure ?');
|
|
|
+ //trace('MaterioFlag :: deletelist | fid', fid);
|
|
|
+
|
|
|
+ $('.flag-lists-link.fid-'+fid).hide();
|
|
|
+
|
|
|
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/deletelist/'+fid;
|
|
|
$.getJSON(url, function(data) {
|
|
|
if (data.error) {
|
|
@@ -554,7 +580,6 @@ MaterioFlag = function(){
|
|
|
function onUnflagList(event){
|
|
|
//trace('onUnflagList', event);
|
|
|
$(this).parents('article.node').addClass('removed');
|
|
|
-
|
|
|
};
|
|
|
|
|
|
/**
|