1/** 2 * @file 3 * Some basic behaviors and utility functions for Views. 4 */ 5(function ($) { 6 7 Drupal.Views = {}; 8 9 /** 10 * JQuery UI tabs, Views integration component. 11 */ 12 Drupal.behaviors.viewsTabs = { 13 attach: function (context) { 14 if ($.viewsUi && $.viewsUi.tabs) { 15 $('#views-tabset').once('views-processed').viewsTabs({ 16 selectedClass: 'active' 17 }); 18 } 19 20 $('a.views-remove-link').once('views-processed').click(function(event) { 21 var id = $(this).attr('id').replace('views-remove-link-', ''); 22 $('#views-row-' + id).hide(); 23 $('#views-removed-' + id).get(0).checked = true; 24 event.preventDefault(); 25 }); 26 // Here is to handle display deletion 27 // (checking in the hidden checkbox and hiding out the row). 28 $('a.display-remove-link') 29 .addClass('display-processed') 30 .click(function() { 31 var id = $(this).attr('id').replace('display-remove-link-', ''); 32 $('#display-row-' + id).hide(); 33 $('#display-removed-' + id).get(0).checked = true; 34 return false; 35 }); 36 } 37 }; 38 39 /** 40 * Helper function to parse a querystring. 41 */ 42 Drupal.Views.parseQueryString = function (query) { 43 var args = {}; 44 var pos = query.indexOf('?'); 45 if (pos != -1) { 46 query = query.substring(pos + 1); 47 } 48 var pairs = query.split('&'); 49 for (var i in pairs) { 50 if (typeof(pairs[i]) == 'string') { 51 var pair = pairs[i].split('='); 52 // Ignore the 'q' path argument, if present. 53 if (pair[0] != 'q' && pair[1]) { 54 args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); 55 } 56 } 57 } 58 return args; 59 }; 60 61 /** 62 * Helper function to return a view's arguments based on a path. 63 */ 64 Drupal.Views.parseViewArgs = function (href, viewPath) { 65 // Provide language prefix. 66 if (Drupal.settings.pathPrefix) { 67 var viewPath = Drupal.settings.pathPrefix + viewPath; 68 } 69 var returnObj = {}; 70 var path = Drupal.Views.getPath(href); 71 // Ensure there is a correct path. 72 if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { 73 var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); 74 returnObj.view_args = args; 75 returnObj.view_path = path; 76 } 77 return returnObj; 78 }; 79 80 /** 81 * Strip off the protocol plus domain from an href. 82 */ 83 Drupal.Views.pathPortion = function (href) { 84 // Remove e.g. http://example.com if present. 85 var protocol = window.location.protocol; 86 if (href.substring(0, protocol.length) == protocol) { 87 // 2 is the length of the '//' that normally follows the protocol. 88 href = href.substring(href.indexOf('/', protocol.length + 2)); 89 } 90 return href; 91 }; 92 93 /** 94 * Return the Drupal path portion of an href. 95 */ 96 Drupal.Views.getPath = function (href) { 97 href = Drupal.Views.pathPortion(href); 98 href = href.substring(Drupal.settings.basePath.length, href.length); 99 // 3 is the length of the '?q=' added to the URL without clean URLs. 100 if (href.substring(0, 3) == '?q=') { 101 href = href.substring(3, href.length); 102 } 103 var chars = ['#', '?', '&']; 104 for (var i in chars) { 105 if (href.indexOf(chars[i]) > -1) { 106 href = href.substr(0, href.indexOf(chars[i])); 107 } 108 } 109 return href; 110 }; 111 112})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.