source: sipes/modules_contrib/views/js/base.js @ 65dadeb

stableversion-3.0
Last change on this file since 65dadeb was 59029b2, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo la version del modulo views

  • Propiedad mode establecida a 100644
File size: 3.8 KB
Línea 
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   * Here is to handle display deletion
27   * (checking in the hidden checkbox and hiding out the row)
28   */
29  $('a.display-remove-link')
30    .addClass('display-processed')
31    .click(function() {
32      var id = $(this).attr('id').replace('display-remove-link-', '');
33      $('#display-row-' + id).hide();
34      $('#display-removed-' + id).attr('checked', true);
35      return false;
36    });
37}
38
39/**
40 * For IE, attach some javascript so that our hovers do what they're supposed
41 * to do.
42 */
43Drupal.behaviors.viewsHoverlinks = function() {
44  if ($.browser.msie) {
45    // If IE, attach a hover event so we can see our admin links.
46    $("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover(
47      function() {
48        $('div.views-hide', this).addClass("views-hide-hover"); return true;
49      },
50      function(){
51        $('div.views-hide', this).removeClass("views-hide-hover"); return true;
52      }
53    );
54    $("div.views-admin-links:not(.views-hover-processed)")
55      .addClass('views-hover-processed')
56      .hover(
57        function() {
58          $(this).addClass("views-admin-links-hover"); return true;
59        },
60        function(){
61          $(this).removeClass("views-admin-links-hover"); return true;
62        }
63      );
64  }
65}
66
67/**
68 * Helper function to parse a querystring.
69 */
70Drupal.Views.parseQueryString = function (query) {
71  var args = {};
72  var pos = query.indexOf('?');
73  if (pos != -1) {
74    query = query.substring(pos + 1);
75  }
76  var pairs = query.split('&');
77  for(var i in pairs) {
78    if (typeof(pairs[i]) == 'string') {
79      var pair = pairs[i].split('=');
80      // Ignore the 'q' path argument, if present.
81      if (pair[0] != 'q' && pair[1]) {
82        args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
83      }
84    }
85  }
86  return args;
87};
88
89/**
90 * Helper function to return a view's arguments based on a path.
91 */
92Drupal.Views.parseViewArgs = function (href, viewPath) {
93  var returnObj = {};
94  var path = Drupal.Views.getPath(href);
95  // Ensure we have a correct path.
96  if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
97    var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
98    returnObj.view_args = args;
99    returnObj.view_path = path;
100  }
101  return returnObj;
102};
103
104/**
105 * Strip off the protocol plus domain from an href.
106 */
107Drupal.Views.pathPortion = function (href) {
108  // Remove e.g. http://example.com if present.
109  var protocol = window.location.protocol;
110  if (href.substring(0, protocol.length) == protocol) {
111    // 2 is the length of the '//' that normally follows the protocol
112    href = href.substring(href.indexOf('/', protocol.length + 2));
113  }
114  return href;
115};
116
117/**
118 * Return the Drupal path portion of an href.
119 */
120Drupal.Views.getPath = function (href) {
121  href = Drupal.Views.pathPortion(href);
122  href = href.substring(Drupal.settings.basePath.length, href.length);
123  // 3 is the length of the '?q=' added to the url without clean urls.
124  if (href.substring(0, 3) == '?q=') {
125    href = href.substring(3, href.length);
126  }
127  var chars = ['#', '?', '&'];
128  for (i in chars) {
129    if (href.indexOf(chars[i]) > -1) {
130      href = href.substr(0, href.indexOf(chars[i]));
131    }
132  }
133  return href;
134};
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.