| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: jquery_ui.module,v 1.6.2.2 2009/06/21 03:43:03 sun Exp $ 3 4 /** 5 * @file 6 * Provides the jQuery UI plug-in to other Drupal modules. 7 * 8 * This module doesn't do too much, but it is a central location for any other 9 * modules that implement the JQuery UI library. It ensures that multiple 10 * modules will all include the same library script just once on any given page. 11 */ 12 13 /** 14 * Path to jQuery UI library. 15 * 16 * During site installation, JQUERY_UI_PATH is the absolute path to the 17 * jQuery UI library. At all other times JQUERY_UI_PATH is relative, and 18 * safe for use in URLs. 19 */ 20 if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') { 21 define('JQUERY_UI_PATH', dirname(__FILE__) . '/jquery.ui'); 22 } 23 else { 24 define('JQUERY_UI_PATH', drupal_get_path('module', 'jquery_ui') . '/jquery.ui'); 25 } 26 27 /** 28 * Add the specified jQuery UI library files to this page. 29 * 30 * The ui.core file is always included automatically, as well as the 31 * effects.core file if any of the effects libraries are used. 32 * 33 * @param $files 34 * An array of what additional files (other than UI core) should be loaded 35 * on the page, or a string with a single file name. 36 */ 37 function jquery_ui_add($files = array()) { 38 static $loaded_files, $ui_core, $effects_core; 39 $jquery_ui_path = JQUERY_UI_PATH . '/ui'; 40 $compression = variable_get('jquery_update_compression_type', 'mini'); 41 42 // Convert file to an array if it's not one already, to compensate for 43 // lazy developers. ;) 44 if (!is_array($files)) { 45 $files = array($files); 46 } 47 48 // If core hasn't been added yet, add it. 49 if (!isset($ui_core)) { 50 $ui_core = TRUE; 51 jquery_ui_add(array('ui.core')); 52 } 53 54 // Loop through list of files to include and add them to the page. 55 foreach ($files as $file) { 56 // Any effects files require the effects core file. 57 if (!isset($effects_core) && strpos($file, 'effects.') === 0) { 58 $effects_core = TRUE; 59 jquery_ui_add(array('effects.core')); 60 } 61 62 // Load other files. 63 if (!isset($loaded_files[$file])) { 64 switch ($compression) { 65 case 'none': 66 $file_path = "$file.js"; 67 break; 68 69 case 'pack': 70 $file_path = "packed/$file.packed.js"; 71 break; 72 73 case 'mini': 74 default: 75 $file_path = "minified/$file.min.js"; 76 break; 77 } 78 $js_path = $jquery_ui_path . '/' . $file_path; 79 drupal_add_js($js_path); 80 $loaded_files[$file] = $js_path; 81 } 82 } 83 } 84 85 /** 86 * Return the version of jQuery UI installed. 87 */ 88 function jquery_ui_get_version() { 89 $version = 0; 90 91 if (file_exists(JQUERY_UI_PATH . '/version.txt')) { 92 $version = file_get_contents(JQUERY_UI_PATH . '/version.txt'); 93 } 94 95 return $version; 96 } 97
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |