/[drupal]/contributions/modules/jgrowl/jgrowl.module
ViewVC logotype

Diff of /contributions/modules/jgrowl/jgrowl.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.6, Fri Dec 12 22:10:45 2008 UTC revision 1.7, Sun Dec 14 00:47:52 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: jgrowl.module,v 1.2.2.3 2008/10/17 23:13:47 stevemckenzie Exp $  // $Id: jgrowl.module,v 1.6 2008/12/12 22:10:45 stevemckenzie Exp $
3    
4  /**  /**
5   *   *
# Line 27  function jgrowl_perm() { Line 27  function jgrowl_perm() {
27  /**  /**
28   *  Implementation of hook_menu().   *  Implementation of hook_menu().
29   */   */
30  function jgrowl_menu($may_cache) {  function jgrowl_menu() {
31    $items = array();    $items = array();
32    
33    if ($may_cache) {    $items['admin/settings/jgrowl'] = array(
34      $items[] = array(    'title' => t('jGrowl'),
35      'title' => t('jGrowl'),    'page callback' => 'drupal_get_form',
36      'path' => 'admin/settings/jgrowl',    'page arguments' => array('jgrowl_settings_form'),
37      'callback' => 'drupal_get_form',    'access callback' => 'user_access',
38      'callback arguments' => array('jgrowl_settings_form'),    'access arguments' => array('administer jgrowl'),
39      'access' => user_access('administer jgrowl'),    );
     );  
   }  
40    
41    return $items;    return $items;
42  }  }
43    
44  /**  /**
45     *  Implementation of hook_theme().
46     */
47    function jgrowl_theme() {
48      return array(
49        'jgrowl_message' => array(
50          'arguments' => array('message' => NULL, 'options' => array()),
51        ),
52      );
53    }
54    
55    /**
56   *  Implementation of hook_footer().   *  Implementation of hook_footer().
57   */   */
58  function jgrowl_footer($main = 0) {  function jgrowl_footer($main = 0) {
# Line 70  function jgrowl_include() { Line 79  function jgrowl_include() {
79      if ($type != 'full') {      if ($type != 'full') {
80        $file .= '_'. $type;        $file .= '_'. $type;
81      }      }
82      drupal_add_js($path. '/jgrowl/'. $file .'.js');      drupal_add_js($path. '/jgrowl/'. $file .'.js', 'module', 'footer');
83    
84      // TODO: make theme-able.      // TODO: make theme-able.
85      drupal_add_css($path .'/jgrowl/jquery.jgrowl.css');      drupal_add_css($path .'/jgrowl/jquery.jgrowl.css');
# Line 200  function jgrowl_system_messages() { Line 209  function jgrowl_system_messages() {
209        }        }
210         unset($_SESSION['messages'][$type]);         unset($_SESSION['messages'][$type]);
211      }      }
212      drupal_add_js("$(document).ready(function() { $js });", 'inline');      drupal_add_js("$(document).ready(function() { $js });", 'inline', 'footer');
213    }    }
214  }  }
215    
# Line 223  function jgrowl_to_js($var) { Line 232  function jgrowl_to_js($var) {
232    }    }
233    
234    switch ($type) {    switch ($type) {
     // Handle items already in JS format.  
     case substr($var, 0, 1) == '{' && substr($var, (strlen($var) - 1)) == '}':  
       return $var;  
   
235      case 'boolean':      case 'boolean':
236        return $var ? 'true' : 'false'; // Lowercase necessary!        return $var ? 'true' : 'false'; // Lowercase necessary!
237    
238      case 'integer':      case 'integer':
239      case 'double':      case 'double':
240        return $var;        return $var;
   
     // Handle custom JS functions.  
     case substr($var, 0, strlen('function')) == 'function':  
       return $var;  
241    
242      case 'resource':      case 'resource':
243      case 'string':      case 'string':
# Line 259  function jgrowl_to_js($var) { Line 260  function jgrowl_to_js($var) {
260          $output[] = jgrowl_to_js(strval($k)) .': '. jgrowl_to_js($v);          $output[] = jgrowl_to_js(strval($k)) .': '. jgrowl_to_js($v);
261        }        }
262        return '{ '. implode(', ', $output) .' }';        return '{ '. implode(', ', $output) .' }';
263    
264        // Handle items already in JS format.
265        case substr($var, 0, 1) == '{' && substr($var, (strlen($var) - 1)) == '}':
266          return $var;
267    
268        // Handle custom JS functions.
269        case substr($var, 0, strlen('function')) == 'function':
270          return $var;
271    
272      default:      default:
273        return 'null';        return 'null';
274    }    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.2