Bachir Soussi Chiadmi 11 år sedan
förälder
incheckning
5d0c233fec
4 ändrade filer med 43 tillägg och 41 borttagningar
  1. 5 4
      js/materio_flag.js
  2. 5 4
      js/materio_flag.min.js
  3. 32 32
      materio_flag.module
  4. 1 1
      materio_flag.pages.inc

+ 5 - 4
js/materio_flag.js

@@ -116,17 +116,18 @@ MaterioFlag = function(){
 
   function refreshBlocks(name){
     //trace('MaterioFlag :: refreshBlocks | name', name);
-    if($('#block-materio-flag-materio-flag-mybookmarks').length){
-      var type = 'bookmarks';
-    }else if($('#block-materio-flag-materio-flag-mylists').length){
+    if($('#block-materio-flag-materio-flag-mylists').length){
       var type = 'lists';
+    }else if($('#block-materio-flag-materio-flag-mybookmarks').length){
+      var type = 'bookmarks';
     }
 
+
     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);
+        // trace('MaterioFlag :: block refreshed '+type, json);
 
         $(id).replaceWith(json.block);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);

+ 5 - 4
js/materio_flag.min.js

@@ -116,17 +116,18 @@ MaterioFlag = function(){
 
   function refreshBlocks(name){
     //trace('MaterioFlag :: refreshBlocks | name', name);
-    if($('#block-materio-flag-materio-flag-mybookmarks').length){
-      var type = 'bookmarks';
-    }else if($('#block-materio-flag-materio-flag-mylists').length){
+    if($('#block-materio-flag-materio-flag-mylists').length){
       var type = 'lists';
+    }else if($('#block-materio-flag-materio-flag-mybookmarks').length){
+      var type = 'bookmarks';
     }
 
+
     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);
+        // trace('MaterioFlag :: block refreshed '+type, json);
 
         $(id).replaceWith(json.block);
         $('#block-materio-flag-materio-flag-mylists-nav').replaceWith(json.block_nav);

+ 32 - 32
materio_flag.module

@@ -5,7 +5,7 @@
  * The Flag bookmark module.
  *
  * This module creates a default Flag when enabled.
- * 
+ *
  */
 
 /**
@@ -55,14 +55,14 @@ function materio_flag_menu() {
     'page callback' => 'materio_flag_createlist_form',
     'page arguments' => array(3),
   );
-  
+
   $items['materioflag/editlistform/%/%'] = $base+array(
     'access arguments' => array('create flag lists'),
     'access callback' => 'user_access',
     'page callback' => 'materio_flag_editlist_form',
     'page arguments' => array(2,3),
   );
-  
+
   $items['materioflag/editlist/%/%'] = $base+array(
     'access arguments' => array('create flag lists'),
     'access callback' => 'user_access',
@@ -83,7 +83,7 @@ function materio_flag_menu() {
     'page callback' => 'materio_flag_nodelinks',
     // 'page arguments' => array(3),
   );
-  
+
   $items['lists/%'] = $base+array(
     'access arguments' => array('view flag lists'),
     'access callback' => 'user_access',
@@ -121,7 +121,7 @@ function materio_flag_menu_alter(&$items) {
  * Implements hook_block_info().
  */
 function materio_flag_block_info() {
-  
+
   $blocks['materio_flag_mybookmarks'] = array(
     'info' => t('My bookmarks'),
     'cache' => DRUPAL_NO_CACHE
@@ -160,7 +160,7 @@ function materio_flag_block_view($delta = '') {
   	      }
           // TODO:  put this title generation on a theme function
           $subject = '<span class="listname">'.t('My bookmarks (@len) ', array("@len"=>count($userbookmarks))).'</span>';
-  	      $block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); // 
+  	      $block['subject'] = $subject . l('<i class="icon-resize-full"></i>', 'bookmarks', array('html'=>true, 'attributes' => array('class' => array('open-list')),)); //
   	      $block['content'] = theme('materio_flag_mybookmarks_block', array("bookmarks"=>$userbookmarks, "viewmode"=>"bookmark"));
         }else{
         	$block['subject'] = t('My bookmarks');
@@ -175,7 +175,7 @@ function materio_flag_block_view($delta = '') {
         // $userflags = flag_get_user_flags('node');
         // dsm($userflags, 'userflags');
         // dsm($flags, 'flags');
-        
+
         foreach ($flags as $name => $flag) {
           $flag->path = url('lists/'.$flag->fid);
           $flaged_content = flag_lists_get_flagged_content($flag->fid, $user->uid);
@@ -222,7 +222,7 @@ function materio_flag_block_view($delta = '') {
         // if($flags){
           // $block['subject'] = t('My !listname'.'s', array('!listname'=>variable_get('flag_lists_name', 'list')));
           $block['subject'] = t('My '.variable_get('flag_lists_name', 'list').'s');
-        
+
           $block['content'] = theme('materio_flag_mylists_nav_block', array("flags"=>$flags));
           // $block['content'] = theme('flag_lists_user_page', array('uid' => $user->uid));
         // }
@@ -255,7 +255,7 @@ function materio_flag_entity_info_alter(&$entity_info) {
 function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
   if($type == 'node'){
     if(user_access('create flag lists') && $view_mode != 'print'){
-      
+
       $entity->content['flaglistslinks'] = materio_flag_get_entity_links($entity, $type, $view_mode);
 
       drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag.css');
@@ -268,12 +268,12 @@ function materio_flag_entity_view($entity, $type, $view_mode, $langcode) {
           foreach ($flags as $flag) {
             // dsm($flag, 'flag');
             if ( ($flag->module == 'flag_lists' && _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0)) || $flag->is_flagged($entity->nid) ) {
-              $entity->flags[] = $flag;      
+              $entity->flags[] = $flag;
             }
           }
         }
       }
-      
+
     }
   }
 }
@@ -290,10 +290,10 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
   $links = array();
   # if flag name is provided we are on flaglists content list (block mylists)
   if($view_mode == 'bookmark'){
-    // TODO:  define view mode in settings  
+    // TODO:  define view mode in settings
     // if (isset($entity->flag_names) && $flags = flag_lists_get_user_flags($entity->type, $user)) {
     //   // dsm($flags, 'flags');
-    //   // TODO:  limit flag link by current flag list  
+    //   // TODO:  limit flag link by current flag list
     //   foreach ($flags as $flag) {
     //     //dsm($flag->name, 'flag');
     //     if(in_array($flag->name, $entity->flag_names)){
@@ -301,7 +301,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
     //         $action = _flag_lists_is_flagged($flag, $entity->nid, $user->uid, 0) ? 'unflag' : 'flag';
     //       } else {
     //         $action = $flag->is_flagged($entity->nid) ? 'unflag' : 'flag';
-    //       }  
+    //       }
     //       $flag->module = 'materio_flag';
     //       $link = $flag->theme($action, $entity->nid);
 
@@ -349,12 +349,12 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 
       }
     }
-    
+
     // dsm($items, 'items '.$entity->title);
 
     #create new list
     $link = l(
-      '<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>', 
+      '<i class="icon-plus"></i>&nbsp;<span>' . t('New @name', array('@name' => t(variable_get('flag_lists_name', 'list')))) . '</span>',
       'flag-lists/add/' . $entity->type,
       array(
         'attributes' => array(
@@ -366,7 +366,7 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
         'html' => TRUE,
       )
     );
-    
+
     $create = array(
       'data' => $link,
       'class' => array('flag-lists-create'),
@@ -375,15 +375,15 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 
   if(isset($items)){
     $ops = array(
-      '#node' => $entity, 
+      '#node' => $entity,
       '#items' => $items,
     );
   }
-  
-  if(isset($create)){ 
+
+  if(isset($create)){
     $ops['#create'] = $create;
   }
-  
+
   if(isset($ops)){
     // dsm($ops, 'ops');
     drupal_add_js(drupal_get_path('module', 'materio_flag').'/js/materio_flag.min.js');
@@ -397,19 +397,19 @@ function materio_flag_get_entity_links($entity, $type, $view_mode = null){
 function _materio_flag_get_listpagetitle($flag){
   $cont = '<i class="icon-materio-folder"></i>';
   $cont .= '<span class="'.$flag->name.'">'.check_plain($flag->title).'</span>';
-  
+
   if(flag_lists_is_owner('edit', $flag->fid)){
-          
-    $cont .= l('<i class="icon-wrench"></i>', 
-                'flags/lists/edit/'.$flag->fid, 
+
+    $cont .= l('<i class="icon-wrench"></i>',
+                'flags/lists/edit/'.$flag->fid,
                 array(
                   'html'=>true,
                   'attributes'=>array('class'=>array('edit-list', $flag->name)),
                 )
-              ); 
+              );
   }
-        
-  
+
+
   return $cont;
 }
 
@@ -468,11 +468,11 @@ function template_preprocess_materio_flag_mylists_nav_block(&$vars){
 
 /**
  * theme_materio_flag_mylists_entity_links()
- * 
+ *
  * see theme_flag_lists_list()
  */
 function theme_materio_flag_mylists_entity_links($vars){
-  
+
   // $node = $vars['node'];
   $items = $vars['items'];
 
@@ -480,13 +480,13 @@ function theme_materio_flag_mylists_entity_links($vars){
 
   if(isset($vars['create']))
     $items[] = $vars['create'];
-  
+
   return theme('item_list', array('items' => $items, 'type' => 'ul', 'attributes' => array('class' => 'flag-lists-entity-links')));
 
 }
 
 function template_preprocess_materio_flag_mylists_list(&$vars) {
-  
+
   $vars['list_count'] = format_plural(
     $vars['count'],
     '@name @title contains 1 item.', // in @sec seconds

+ 1 - 1
materio_flag.pages.inc

@@ -19,7 +19,7 @@ function materio_flag_refresh_block($flag){
 	if(!isset($block_name))
 		return;
 
-	$rep = array();
+	$rep = array("flag"=>$flag);
 
 	$block = block_load('materio_flag', $block_name);
 	$block_content = _block_render_blocks(array($block));