selectList.module 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // $Id$
  3. //
  4. // jqplug.module
  5. //
  6. //
  7. //
  8. // Created by Bach on 2008-04.
  9. // Modified by bach on 2009-09-09
  10. // Copyright 2009 gui. All rights reserved.
  11. //
  12. /**
  13. * Implementation of hook_init().
  14. */
  15. function selectList_init() {
  16. // $activated = variable_get('jqplug', array());
  17. //
  18. // $match = false;
  19. // foreach($activated as $plug){
  20. // if(stripos($plug, "selectlist")){
  21. // $match = true;
  22. // break;
  23. // }
  24. // }
  25. //
  26. // if($match){
  27. // drupal_add_css(drupal_get_path('module', 'selectList').'/selectList.css');
  28. //
  29. // drupal_add_js("(function ($) { $('select[multiple], .selectlist').removeAttr('size').selectList();})(jQuery);", array('type'=>'inline', 'scope'=>'header', 'group'=>JS_DEFAULT));
  30. // }
  31. $curr_uri = preg_replace('/\?.*$/', '', request_uri());
  32. $curr_uri_parts = explode('/', ltrim($curr_uri, '/'));
  33. // dsm($curr_uri_parts, '$curr_uri');
  34. if ($curr_uri_parts[0] == 'admin'
  35. || $curr_uri_parts[2] == 'edit'
  36. || $curr_uri_parts[1] == 'add'
  37. || $curr_uri_parts[0] == 'batch'
  38. || $curr_uri_parts[0] == 'imce'
  39. ){
  40. drupal_add_js(drupal_get_path('module', 'selectList') .'/jquery.selectlist.pack.js');
  41. $mod_path = drupal_get_path('module', 'selectList');
  42. drupal_add_css($mod_path.'/selectList.css');
  43. $js = '
  44. $(document).ready(function() {
  45. // #node-form
  46. $("select[multiple], .selectlist").removeAttr("size").selectList();
  47. });
  48. ';
  49. drupal_add_js($js, "inline");
  50. }
  51. }