1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
(function ($) {
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
Drupal.behaviors.ViewsAjaxView = {};
|
11 |
|
|
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
12 |
|
|
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
13 |
|
|
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
14 |
|
|
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
15 |
|
|
});
|
16 |
|
|
}
|
17 |
|
|
};
|
18 |
|
|
|
19 |
|
|
Drupal.views = {};
|
20 |
|
|
Drupal.views.instances = {};
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
Drupal.views.ajaxView = function(settings) {
|
26 |
|
|
var selector = '.view-dom-id-' + settings.view_dom_id;
|
27 |
|
|
this.$view = $(selector);
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
var ajax_path = Drupal.settings.views.ajax_path;
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
if (ajax_path.constructor.toString().indexOf("Array") != -1) {
|
34 |
|
|
ajax_path = ajax_path[0];
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
var queryString = window.location.search || '';
|
39 |
|
|
if (queryString !== '') {
|
40 |
|
|
|
41 |
|
|
var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
|
42 |
|
|
if (queryString !== '') {
|
43 |
|
|
|
44 |
|
|
queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
this.element_settings = {
|
49 |
|
|
url: ajax_path + queryString,
|
50 |
|
|
submit: settings,
|
51 |
|
|
setClick: true,
|
52 |
|
|
event: 'click',
|
53 |
|
|
selector: selector,
|
54 |
|
|
progress: { type: 'throbber' }
|
55 |
|
|
};
|
56 |
|
|
|
57 |
|
|
this.settings = settings;
|
58 |
|
|
|
59 |
|
|
|
60 |
13c3c9b4
|
Assos Assos
|
this.$exposed_form = this.$view.children('.view-filters').children('form');
|
61 |
85ad3d82
|
Assos Assos
|
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
this.$view
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
.filter(jQuery.proxy(this.filterNestedViews, this))
|
68 |
|
|
.once(jQuery.proxy(this.attachPagerAjax, this));
|
69 |
6eb8d15f
|
Assos Assos
|
|
70 |
13c3c9b4
|
Assos Assos
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
6eb8d15f
|
Assos Assos
|
|
77 |
|
|
var self_settings = this.element_settings;
|
78 |
|
|
self_settings.event = 'RefreshView';
|
79 |
|
|
this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings);
|
80 |
85ad3d82
|
Assos Assos
|
};
|
81 |
|
|
|
82 |
|
|
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
|
83 |
|
|
var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
|
84 |
|
|
button = button[0];
|
85 |
|
|
|
86 |
|
|
this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
|
87 |
|
|
};
|
88 |
|
|
|
89 |
|
|
Drupal.views.ajaxView.prototype.filterNestedViews= function() {
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
return !this.$view.parents('.view').size();
|
93 |
|
|
};
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
|
99 |
|
|
this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
100 |
|
|
.each(jQuery.proxy(this.attachPagerLinkAjax, this));
|
101 |
|
|
};
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
|
107 |
|
|
var $link = $(link);
|
108 |
|
|
var viewData = {};
|
109 |
|
|
var href = $link.attr('href');
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
$.extend(
|
113 |
|
|
viewData,
|
114 |
|
|
this.settings,
|
115 |
|
|
Drupal.Views.parseQueryString(href),
|
116 |
|
|
|
117 |
|
|
Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
$.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
|
123 |
|
|
|
124 |
|
|
this.element_settings.submit = viewData;
|
125 |
|
|
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
|
126 |
|
|
};
|
127 |
|
|
|
128 |
|
|
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
var offset = $(response.selector).offset();
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
var scrollTarget = response.selector;
|
138 |
|
|
while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
|
139 |
|
|
scrollTarget = $(scrollTarget).parent();
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
if (offset.top - 10 < $(scrollTarget).scrollTop()) {
|
143 |
|
|
$(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
|
144 |
|
|
}
|
145 |
|
|
};
|
146 |
|
|
|
147 |
|
|
})(jQuery); |