| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /** 2 * @file base.js 3 * 4 * Some basic behaviors and utility functions for Views. 5 */ 6 7 Drupal.Views = {}; 8 9 /** 10 * jQuery UI tabs, Views integration component 11 */ 12 Drupal.behaviors.viewsTabs = function (context) { 13 $('#views-tabset:not(.views-processed)').addClass('views-processed').each(function() { 14 new Drupal.Views.Tabs($(this), {selectedClass: 'active'}); 15 }); 16 17 $('a.views-remove-link') 18 .addClass('views-processed') 19 .click(function() { 20 var id = $(this).attr('id').replace('views-remove-link-', ''); 21 $('#views-row-' + id).hide(); 22 $('#views-removed-' + id).attr('checked', true); 23 return false; 24 }); 25 } 26 27 /** 28 * For IE, attach some javascript so that our hovers do what they're supposed 29 * to do. 30 */ 31 Drupal.behaviors.viewsHoverlinks = function() { 32 if ($.browser.msie) { 33 // If IE, attach a hover event so we can see our admin links. 34 $("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover( 35 function() { 36 $('div.views-hide', this).addClass("views-hide-hover"); return true; 37 }, 38 function(){ 39 $('div.views-hide', this).removeClass("views-hide-hover"); return true; 40 } 41 ); 42 $("div.views-admin-links:not(.views-hover-processed)") 43 .addClass('views-hover-processed') 44 .hover( 45 function() { 46 $(this).addClass("views-admin-links-hover"); return true; 47 }, 48 function(){ 49 $(this).removeClass("views-admin-links-hover"); return true; 50 } 51 ); 52 } 53 } 54 55 /** 56 * Helper function to parse a querystring. 57 */ 58 Drupal.Views.parseQueryString = function (query) { 59 var args = {}; 60 var pos = query.indexOf('?'); 61 if (pos != -1) { 62 query = query.substring(pos + 1); 63 } 64 var pairs = query.split('&'); 65 for(var i in pairs) { 66 if (typeof(pairs[i]) == 'string') { 67 var pair = pairs[i].split('='); 68 // Ignore the 'q' path argument, if present. 69 if (pair[0] != 'q' && pair[1]) { 70 args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); 71 } 72 } 73 } 74 return args; 75 }; 76 77 /** 78 * Helper function to return a view's arguments based on a path. 79 */ 80 Drupal.Views.parseViewArgs = function (href, viewPath) { 81 var returnObj = {}; 82 var path = Drupal.Views.getPath(href); 83 // Ensure we have a correct path. 84 if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { 85 var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); 86 returnObj.view_args = args; 87 returnObj.view_path = path; 88 } 89 return returnObj; 90 }; 91 92 /** 93 * Strip off the protocol plus domain from an href. 94 */ 95 Drupal.Views.pathPortion = function (href) { 96 // Remove e.g. http://example.com if present. 97 var protocol = window.location.protocol; 98 if (href.substring(0, protocol.length) == protocol) { 99 // 2 is the length of the '//' that normally follows the protocol 100 href = href.substring(href.indexOf('/', protocol.length + 2)); 101 } 102 return href; 103 }; 104 105 /** 106 * Return the Drupal path portion of an href. 107 */ 108 Drupal.Views.getPath = function (href) { 109 href = Drupal.Views.pathPortion(href); 110 href = href.substring(Drupal.settings.basePath.length, href.length); 111 // 3 is the length of the '?q=' added to the url without clean urls. 112 if (href.substring(0, 3) == '?q=') { 113 href = href.substring(3, href.length); 114 } 115 var chars = ['#', '?', '&']; 116 for (i in chars) { 117 if (href.indexOf(chars[i]) > -1) { 118 href = href.substr(0, href.indexOf(chars[i])); 119 } 120 } 121 return href; 122 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |