Index: sites/all/modules/contrib/views/js/ajax_view.js IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP <+>/**\n * @file\n * Handles AJAX fetching of views, including filter submission and response.\n */\n(function ($) {\n\n/**\n * Attaches the AJAX behavior to Views exposed filter forms and key View links.\n */\nDrupal.behaviors.ViewsAjaxView = {};\nDrupal.behaviors.ViewsAjaxView.attach = function() {\n if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {\n $.each(Drupal.settings.views.ajaxViews, function(i, settings) {\n Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);\n });\n }\n};\n\nDrupal.views = {};\nDrupal.views.instances = {};\n\n/**\n * Javascript object for a certain view.\n */\nDrupal.views.ajaxView = function(settings) {\n var selector = '.view-dom-id-' + settings.view_dom_id;\n this.$view = $(selector);\n\n // Retrieve the path to use for views' ajax.\n var ajax_path = Drupal.settings.views.ajax_path;\n\n // If there are multiple views this might've ended up showing up multiple times.\n if (ajax_path.constructor.toString().indexOf(\"Array\") != -1) {\n ajax_path = ajax_path[0];\n }\n\n // Check if there are any GET parameters to send to views.\n var queryString = window.location.search || '';\n if (queryString !== '') {\n // Remove the question mark and Drupal path component if any.\n var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');\n if (queryString !== '') {\n // If there is a '?' in ajax_path, clean url are on and & should be used to add parameters.\n queryString = ((/\\?/.test(ajax_path)) ? '&' : '?') + queryString;\n }\n }\n\n this.element_settings = {\n url: ajax_path + queryString,\n submit: settings,\n setClick: true,\n event: 'click',\n selector: selector,\n progress: { type: 'throbber' }\n };\n\n this.settings = settings;\n\n // Add the ajax to exposed forms.\n this.$exposed_form = $('form#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));\n this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));\n\n // Add the ajax to pagers.\n this.$view\n // Don't attach to nested views. Doing so would attach multiple behaviors\n // to a given element.\n .filter(jQuery.proxy(this.filterNestedViews, this))\n .once(jQuery.proxy(this.attachPagerAjax, this));\n\n // Add a trigger to update this view specifically.\n var self_settings = this.element_settings;\n self_settings.event = 'RefreshView';\n this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings);\n};\n\nDrupal.views.ajaxView.prototype.attachExposedFormAjax = function() {\n var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);\n button = button[0];\n\n this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);\n};\n\nDrupal.views.ajaxView.prototype.filterNestedViews= function() {\n // If there is at least one parent with a view class, this view\n // is nested (e.g., an attachment). Bail.\n return !this.$view.parents('.view').size();\n};\n\n/**\n * Attach the ajax behavior to each link.\n */\nDrupal.views.ajaxView.prototype.attachPagerAjax = function() {\n this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')\n .each(jQuery.proxy(this.attachPagerLinkAjax, this));\n};\n\n/**\n * Attach the ajax behavior to a singe link.\n */\nDrupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {\n var $link = $(link);\n var viewData = {};\n var href = $link.attr('href');\n // Construct an object using the settings defaults and then overriding\n // with data specific to the link.\n $.extend(\n viewData,\n this.settings,\n Drupal.Views.parseQueryString(href),\n // Extract argument data from the URL.\n Drupal.Views.parseViewArgs(href, this.settings.view_base_path)\n );\n\n // For anchor tags, these will go to the target of the anchor rather\n // than the usual location.\n $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));\n\n this.element_settings.submit = viewData;\n this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);\n};\n\nDrupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {\n // Scroll to the top of the view. This will allow users\n // to browse newly loaded content after e.g. clicking a pager\n // link.\n var offset = $(response.selector).offset();\n // We can't guarantee that the scrollable object should be\n // the body, as the view could be embedded in something\n // more complex such as a modal popup. Recurse up the DOM\n // and scroll the first element that has a non-zero top.\n var scrollTarget = response.selector;\n while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {\n scrollTarget = $(scrollTarget).parent();\n }\n // Only scroll upward\n if (offset.top - 10 < $(scrollTarget).scrollTop()) {\n $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);\n }\n};\n\n})(jQuery);\n =================================================================== --- sites/all/modules/contrib/views/js/ajax_view.js (date 1422282478000) +++ sites/all/modules/contrib/views/js/ajax_view.js (revision ) @@ -70,7 +70,10 @@ // Add a trigger to update this view specifically. var self_settings = this.element_settings; self_settings.event = 'RefreshView'; - this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings); + self = this; + this.$view.once('refresh', function(){ + self.refreshViewAjax = new Drupal.ajax(self.selector, self.$view, self_settings); + }) }; Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {