Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/js/base.js
4 4
 */
5 5
(function ($) {
6 6

  
7
Drupal.Views = {};
7
  Drupal.Views = {};
8 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 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 27
    * Here is to handle display deletion
28
    * (checking in the hidden checkbox and hiding out the row)
28
    * (checking in the hidden checkbox and hiding out the row).
29 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
};
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 40

  
41
/**
41
  /**
42 42
 * Helper function to parse a querystring.
43 43
 */
44
Drupal.Views.parseQueryString = function (query) {
45
  var args = {};
46
  var pos = query.indexOf('?');
47
  if (pos != -1) {
48
    query = query.substring(pos + 1);
49
  }
50
  var pairs = query.split('&');
51
  for(var i in pairs) {
52
    if (typeof(pairs[i]) == 'string') {
53
      var pair = pairs[i].split('=');
54
      // Ignore the 'q' path argument, if present.
55
      if (pair[0] != 'q' && pair[1]) {
56
        args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
44
  Drupal.Views.parseQueryString = function (query) {
45
    var args = {};
46
    var pos = query.indexOf('?');
47
    if (pos != -1) {
48
      query = query.substring(pos + 1);
49
    }
50
    var pairs = query.split('&');
51
    for (var i in pairs) {
52
      if (typeof(pairs[i]) == 'string') {
53
        var pair = pairs[i].split('=');
54
        // Ignore the 'q' path argument, if present.
55
        if (pair[0] != 'q' && pair[1]) {
56
          args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
57
        }
57 58
      }
58 59
    }
59
  }
60
  return args;
61
};
60
    return args;
61
  };
62 62

  
63
/**
63
  /**
64 64
 * Helper function to return a view's arguments based on a path.
65 65
 */
66
Drupal.Views.parseViewArgs = function (href, viewPath) {
66
  Drupal.Views.parseViewArgs = function (href, viewPath) {
67 67

  
68
  // Provide language prefix.
69
  if (Drupal.settings.pathPrefix) {
70
    var viewPath = Drupal.settings.pathPrefix + viewPath;
71
  }
72
  var returnObj = {};
73
  var path = Drupal.Views.getPath(href);
74
  // Ensure we have a correct path.
75
  if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
76
    var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
77
    returnObj.view_args = args;
78
    returnObj.view_path = path;
79
  }
80
  return returnObj;
81
};
68
    // Provide language prefix.
69
    if (Drupal.settings.pathPrefix) {
70
      var viewPath = Drupal.settings.pathPrefix + viewPath;
71
    }
72
    var returnObj = {};
73
    var path = Drupal.Views.getPath(href);
74
    // Ensure we have a correct path.
75
    if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
76
      var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
77
      returnObj.view_args = args;
78
      returnObj.view_path = path;
79
    }
80
    return returnObj;
81
  };
82 82

  
83
/**
83
  /**
84 84
 * Strip off the protocol plus domain from an href.
85 85
 */
86
Drupal.Views.pathPortion = function (href) {
87
  // Remove e.g. http://example.com if present.
88
  var protocol = window.location.protocol;
89
  if (href.substring(0, protocol.length) == protocol) {
90
    // 2 is the length of the '//' that normally follows the protocol
91
    href = href.substring(href.indexOf('/', protocol.length + 2));
92
  }
93
  return href;
94
};
86
  Drupal.Views.pathPortion = function (href) {
87
    // Remove e.g. http://example.com if present.
88
    var protocol = window.location.protocol;
89
    if (href.substring(0, protocol.length) == protocol) {
90
      // 2 is the length of the '//' that normally follows the protocol.
91
      href = href.substring(href.indexOf('/', protocol.length + 2));
92
    }
93
    return href;
94
  };
95 95

  
96
/**
96
  /**
97 97
 * Return the Drupal path portion of an href.
98 98
 */
99
Drupal.Views.getPath = function (href) {
100
  href = Drupal.Views.pathPortion(href);
101
  href = href.substring(Drupal.settings.basePath.length, href.length);
102
  // 3 is the length of the '?q=' added to the url without clean urls.
103
  if (href.substring(0, 3) == '?q=') {
104
    href = href.substring(3, href.length);
105
  }
106
  var chars = ['#', '?', '&'];
107
  for (var i in chars) {
108
    if (href.indexOf(chars[i]) > -1) {
109
      href = href.substr(0, href.indexOf(chars[i]));
99
  Drupal.Views.getPath = function (href) {
100
    href = Drupal.Views.pathPortion(href);
101
    href = href.substring(Drupal.settings.basePath.length, href.length);
102
    // 3 is the length of the '?q=' added to the url without clean urls.
103
    if (href.substring(0, 3) == '?q=') {
104
      href = href.substring(3, href.length);
105
    }
106
    var chars = ['#', '?', '&'];
107
    for (var i in chars) {
108
      if (href.indexOf(chars[i]) > -1) {
109
        href = href.substr(0, href.indexOf(chars[i]));
110
      }
110 111
    }
111
  }
112
  return href;
113
};
112
    return href;
113
  };
114 114

  
115 115
})(jQuery);

Formats disponibles : Unified diff