PageSourceSearch

https://medafarm.ru/sites/all/modules/views/js/base.js?5

js medafarm.ru collected 2026-10-02 06:46:39 UTC 3,493 bytes, 122 lines download raw bytes

1/**
2 * @file base.js
3 *
4 * Some basic behaviors and utility functions for Views.
5 */
6
7Drupal.Views = {};
8
9/**
10 * jQuery UI tabs, Views integration component
11 */
12Drupal.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 */
31Drupal.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 */
58Drupal.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 */
80Drupal.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 */
95Drupal.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 */
108Drupal.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};

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.