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).attr('checked', true); 24 event.preventDefault(); 25 }); 26 /** 27 * Here is to handle display deletion 28 * (checking in the hidden checkbox and hiding out the row). 29 */ 30 $('a.display-remove-link') 31 .addClass('display-processed') 32 .click(function() { 33 var id = $(this).attr('id').replace('display-remove-link-', ''); 34 $('#display-row-' + id).hide(); 35 $('#display-removed-' + id).attr('checked', true); 36 return false; 37 }); 38 } 39 }; 40 41 /** 42 * Helper function to parse a querystring. 43 */ 44 Drupal.Views.parseQueryString = function (query) { 45 var args = {}; 46 if(query == undefined){ 47 return args; 48 } 49 var pos = query.indexOf('?'); 50 if (pos != -1) { 51 query = query.substring(pos + 1); 52 } 53 var pairs = query.split('&'); 54 for (var i in pairs) { 55 if (typeof(pairs[i]) == 'string') { 56 var pair = pairs[i].split('='); 57 // Ignore the 'q' path argument, if present. 58 if (pair[0] != 'q' && pair[1]) { 59 args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); 60 } 61 } 62 } 63 return args; 64 }; 65 66 /** 67 * Helper function to return a view's arguments based on a path. 68 */ 69 Drupal.Views.parseViewArgs = function (href, viewPath) { 70 71 // Provide language prefix. 72 if (Drupal.settings.pathPrefix) { 73 var viewPath = Drupal.settings.pathPrefix + viewPath; 74 } 75 var returnObj = {}; 76 var path = Drupal.Views.getPath(href); 77 // Ensure we have a correct path. 78 if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { 79 var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); 80 returnObj.view_args = args; 81 returnObj.view_path = path; 82 } 83 return returnObj; 84 }; 85 86 /** 87 * Strip off the protocol plus domain from an href. 88 */ 89 Drupal.Views.pathPortion = function (href) { 90 // Remove e.g. http://example.com if present. 91 var protocol = window.location.protocol; 92 if(href == undefined){ 93 return ""; 94 } 95 if (href.substring(0, protocol.length) == protocol) { 96 // 2 is the length of the '//' that normally follows the protocol. 97 href = href.substring(href.indexOf('/', protocol.length + 2)); 98 } 99 return href; 100 }; 101 102 /** 103 * Return the Drupal path portion of an href. 104 */ 105 Drupal.Views.getPath = function (href) { 106 href = Drupal.Views.pathPortion(href); 107 href = href.substring(Drupal.settings.basePath.length, href.length); 108 // 3 is the length of the '?q=' added to the url without clean urls. 109 if (href.substring(0, 3) == '?q=') { 110 href = href.substring(3, href.length); 111 } 112 var chars = ['#', '?', '&']; 113 for (var i in chars) { 114 if (href.indexOf(chars[i]) > -1) { 115 href = href.substr(0, href.indexOf(chars[i])); 116 } 117 } 118 return href; 119 }; 120 121})(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.