updated contrib modules
This commit is contained in:
@@ -25,7 +25,13 @@
|
||||
});
|
||||
|
||||
$('form', ajax_body).once('views-ajax-submit-processed').each(function() {
|
||||
var element_settings = { 'url': response.url, 'event': 'submit', 'progress': { 'type': 'throbber' } };
|
||||
var element_settings = {
|
||||
'url': response.url,
|
||||
'event': 'submit',
|
||||
'progress': {
|
||||
'type': 'throbber'
|
||||
}
|
||||
};
|
||||
var $form = $(this);
|
||||
var id = $form.attr('id');
|
||||
Drupal.ajax[id] = new Drupal.ajax(id, this, element_settings);
|
||||
@@ -90,7 +96,7 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Get rid of irritating tabledrag messages
|
||||
* Get rid of irritating tabledrag messages.
|
||||
*/
|
||||
Drupal.theme.tableDragChangedWarning = function () {
|
||||
return [];
|
||||
@@ -143,7 +149,9 @@
|
||||
|
||||
var base_element_settings = {
|
||||
'event': 'click',
|
||||
'progress': { 'type': 'throbber' }
|
||||
'progress': {
|
||||
'type': 'throbber'
|
||||
}
|
||||
};
|
||||
// Bind AJAX behaviors to all items showing the class.
|
||||
$('a.views-ajax-link', context).once('views-ajax-processed').each(function () {
|
||||
@@ -158,23 +166,23 @@
|
||||
|
||||
$('div#views-live-preview a')
|
||||
.once('views-ajax-processed').each(function () {
|
||||
// We don't bind to links without a URL.
|
||||
if (!$(this).attr('href')) {
|
||||
return true;
|
||||
}
|
||||
// We don't bind to links without a URL.
|
||||
if (!$(this).attr('href')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this).attr('href');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this).attr('href');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
|
||||
// Within a live preview, make exposed widget form buttons re-trigger the
|
||||
// Preview button.
|
||||
@@ -182,29 +190,29 @@
|
||||
// of the main Edit form.
|
||||
$('div#views-live-preview input[type=submit]')
|
||||
.once('views-ajax-processed').each(function(event) {
|
||||
$(this).click(function () {
|
||||
this.form.clk = this;
|
||||
return true;
|
||||
$(this).click(function () {
|
||||
this.form.clk = this;
|
||||
return true;
|
||||
});
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
element_settings.event = 'click';
|
||||
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
element_settings.event = 'click';
|
||||
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
|
||||
if (!this.collapseReplaced && Drupal.collapseScrollIntoView) {
|
||||
this.collapseReplaced = true;
|
||||
Drupal.collapseScrollIntoView = function (node) {
|
||||
for (var $parent = $(node); $parent.get(0) != document && $parent.size() != 0; $parent = $parent.parent()) {
|
||||
for (var $parent = $(node); $parent.get(0) != document && $parent.length != 0; $parent = $parent.parent()) {
|
||||
if ($parent.css('overflow') == 'scroll' || $parent.css('overflow') == 'auto') {
|
||||
if (Drupal.viewsUi.resizeModal) {
|
||||
// If the modal is already at the max height, don't bother with
|
||||
|
@@ -4,148 +4,162 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
* Attaches the AJAX behavior to Views exposed filter forms and key View links.
|
||||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = {};
|
||||
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.views = {};
|
||||
Drupal.views.instances = {};
|
||||
|
||||
/**
|
||||
* Javascript object for a certain view.
|
||||
*/
|
||||
Drupal.views.ajaxView = function(settings) {
|
||||
var selector = '.view-dom-id-' + settings.view_dom_id;
|
||||
this.$view = $(selector);
|
||||
|
||||
// Retrieve the path to use for views' ajax.
|
||||
var ajax_path = Drupal.settings.views.ajax_path;
|
||||
|
||||
// If there are multiple views this might've ended up showing up multiple times.
|
||||
if (ajax_path.constructor.toString().indexOf("Array") != -1) {
|
||||
ajax_path = ajax_path[0];
|
||||
}
|
||||
|
||||
// Check if there are any GET parameters to send to views.
|
||||
var queryString = window.location.search || '';
|
||||
if (queryString !== '') {
|
||||
// Remove the question mark and Drupal path component if any.
|
||||
var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
|
||||
if (queryString !== '') {
|
||||
// If there is a '?' in ajax_path, clean url are on and & should be used to add parameters.
|
||||
queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
|
||||
/**
|
||||
* Attaches the AJAX behavior to exposed filter forms and key views links.
|
||||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = {};
|
||||
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.element_settings = {
|
||||
url: ajax_path + queryString,
|
||||
submit: settings,
|
||||
setClick: true,
|
||||
event: 'click',
|
||||
selector: selector,
|
||||
progress: { type: 'throbber' }
|
||||
};
|
||||
|
||||
this.settings = settings;
|
||||
Drupal.views = {};
|
||||
Drupal.views.instances = {};
|
||||
|
||||
// Add the ajax to exposed forms.
|
||||
this.$exposed_form = $('#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
|
||||
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
|
||||
/**
|
||||
* JavaScript object for a certain view.
|
||||
*/
|
||||
Drupal.views.ajaxView = function(settings) {
|
||||
var selector = '.view-dom-id-' + settings.view_dom_id;
|
||||
this.$view = $(selector);
|
||||
|
||||
// Store Drupal.ajax objects here for all pager links.
|
||||
this.links = [];
|
||||
// Retrieve the path to use for views' ajax.
|
||||
var ajax_path = Drupal.settings.views.ajax_path;
|
||||
|
||||
// Add the ajax to pagers.
|
||||
this.$view
|
||||
// Don't attach to nested views. Doing so would attach multiple behaviors
|
||||
// to a given element.
|
||||
.filter(jQuery.proxy(this.filterNestedViews, this))
|
||||
.once(jQuery.proxy(this.attachPagerAjax, this));
|
||||
// If there are multiple views this might've ended up showing up multiple
|
||||
// times.
|
||||
if (ajax_path.constructor.toString().indexOf("Array") != -1) {
|
||||
ajax_path = ajax_path[0];
|
||||
}
|
||||
|
||||
// Add a trigger to update this view specifically. In order to trigger a
|
||||
// refresh use the following code.
|
||||
//
|
||||
// @code
|
||||
// jQuery('.view-name').trigger('RefreshView');
|
||||
// @endcode
|
||||
// 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);
|
||||
};
|
||||
// Check if there are any GET parameters to send to views.
|
||||
var queryString = window.location.search || '';
|
||||
if (queryString !== '') {
|
||||
// Remove the question mark and Drupal path component if any.
|
||||
var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
|
||||
if (queryString !== '') {
|
||||
// If there is a '?' in ajax_path, clean url are on and & should be
|
||||
// used to add parameters.
|
||||
queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
|
||||
var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
|
||||
button = button[0];
|
||||
this.element_settings = {
|
||||
url: ajax_path + queryString,
|
||||
submit: settings,
|
||||
setClick: true,
|
||||
event: 'click',
|
||||
selector: selector,
|
||||
progress: {
|
||||
type: 'throbber'
|
||||
}
|
||||
};
|
||||
|
||||
this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
|
||||
};
|
||||
this.settings = settings;
|
||||
|
||||
Drupal.views.ajaxView.prototype.filterNestedViews= function() {
|
||||
// If there is at least one parent with a view class, this view
|
||||
// is nested (e.g., an attachment). Bail.
|
||||
return !this.$view.parents('.view').size();
|
||||
};
|
||||
// Add the ajax to exposed forms.
|
||||
this.$exposed_form = $('#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
|
||||
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to each link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
|
||||
this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
||||
.each(jQuery.proxy(this.attachPagerLinkAjax, this));
|
||||
};
|
||||
// Store Drupal.ajax objects here for all pager links.
|
||||
this.links = [];
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to a singe link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
|
||||
var $link = $(link);
|
||||
var viewData = {};
|
||||
var href = $link.attr('href');
|
||||
// Construct an object using the settings defaults and then overriding
|
||||
// with data specific to the link.
|
||||
$.extend(
|
||||
// Add the ajax to pagers.
|
||||
this.$view
|
||||
.once(jQuery.proxy(this.attachPagerAjax, this));
|
||||
|
||||
// Add a trigger to update this view specifically. In order to trigger a
|
||||
// refresh use the following code.
|
||||
//
|
||||
// @code
|
||||
// jQuery('.view-name').trigger('RefreshView');
|
||||
// @endcode
|
||||
// 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);
|
||||
};
|
||||
|
||||
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
|
||||
var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
|
||||
button = button[0];
|
||||
|
||||
// Call the autocomplete submit before doing AJAX.
|
||||
$(button).click(function () {
|
||||
if (Drupal.autocompleteSubmit) {
|
||||
Drupal.autocompleteSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to each link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
|
||||
this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
||||
.each(jQuery.proxy(this.attachPagerLinkAjax, this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to a singe link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
|
||||
var $link = $(link);
|
||||
// Don't attach to pagers inside nested views.
|
||||
if ($link.closest('.view')[0] !== this.$view[0]) {
|
||||
return;
|
||||
}
|
||||
var viewData = {};
|
||||
var href = $link.attr('href');
|
||||
|
||||
// Provide a default page if none has been set. This must be done
|
||||
// prior to merging with settings to avoid accidentally using the
|
||||
// page landed on instead of page 1.
|
||||
if (typeof(viewData.page) === 'undefined') {
|
||||
viewData.page = 0;
|
||||
}
|
||||
|
||||
// Construct an object using the settings defaults and then overriding
|
||||
// with data specific to the link.
|
||||
$.extend(
|
||||
viewData,
|
||||
this.settings,
|
||||
Drupal.Views.parseQueryString(href),
|
||||
// Extract argument data from the URL.
|
||||
Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
|
||||
);
|
||||
);
|
||||
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
$.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
$.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
|
||||
|
||||
this.element_settings.submit = viewData;
|
||||
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
|
||||
this.links.push(this.pagerAjax);
|
||||
};
|
||||
this.element_settings.submit = viewData;
|
||||
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
|
||||
this.links.push(this.pagerAjax);
|
||||
};
|
||||
|
||||
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
|
||||
// Scroll to the top of the view. This will allow users
|
||||
// to browse newly loaded content after e.g. clicking a pager
|
||||
// link.
|
||||
var offset = $(response.selector).offset();
|
||||
// We can't guarantee that the scrollable object should be
|
||||
// the body, as the view could be embedded in something
|
||||
// more complex such as a modal popup. Recurse up the DOM
|
||||
// and scroll the first element that has a non-zero top.
|
||||
var scrollTarget = response.selector;
|
||||
while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
|
||||
scrollTarget = $(scrollTarget).parent();
|
||||
}
|
||||
// Only scroll upward
|
||||
if (offset.top - 10 < $(scrollTarget).scrollTop()) {
|
||||
$(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
|
||||
}
|
||||
};
|
||||
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
|
||||
// Scroll to the top of the view. This will allow users
|
||||
// to browse newly loaded content after e.g. clicking a pager
|
||||
// link.
|
||||
var offset = $(response.selector).offset();
|
||||
// We can't guarantee that the scrollable object should be
|
||||
// the body, as the view could be embedded in something
|
||||
// more complex such as a modal popup. Recurse up the DOM
|
||||
// and scroll the first element that has a non-zero top.
|
||||
var scrollTarget = response.selector;
|
||||
while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
|
||||
scrollTarget = $(scrollTarget).parent();
|
||||
}
|
||||
// Only scroll upward.
|
||||
if (offset.top - 10 < $(scrollTarget).scrollTop()) {
|
||||
$(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -4,112 +4,112 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.Views = {};
|
||||
Drupal.Views = {};
|
||||
|
||||
/**
|
||||
* jQuery UI tabs, Views integration component
|
||||
*/
|
||||
Drupal.behaviors.viewsTabs = {
|
||||
attach: function (context) {
|
||||
if ($.viewsUi && $.viewsUi.tabs) {
|
||||
$('#views-tabset').once('views-processed').viewsTabs({
|
||||
selectedClass: 'active'
|
||||
});
|
||||
}
|
||||
|
||||
$('a.views-remove-link').once('views-processed').click(function(event) {
|
||||
var id = $(this).attr('id').replace('views-remove-link-', '');
|
||||
$('#views-row-' + id).hide();
|
||||
$('#views-removed-' + id).attr('checked', true);
|
||||
event.preventDefault();
|
||||
});
|
||||
/**
|
||||
* Here is to handle display deletion
|
||||
* (checking in the hidden checkbox and hiding out the row)
|
||||
*/
|
||||
$('a.display-remove-link')
|
||||
.addClass('display-processed')
|
||||
.click(function() {
|
||||
var id = $(this).attr('id').replace('display-remove-link-', '');
|
||||
$('#display-row-' + id).hide();
|
||||
$('#display-removed-' + id).attr('checked', true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
* JQuery UI tabs, Views integration component.
|
||||
*/
|
||||
Drupal.behaviors.viewsTabs = {
|
||||
attach: function (context) {
|
||||
if ($.viewsUi && $.viewsUi.tabs) {
|
||||
$('#views-tabset').once('views-processed').viewsTabs({
|
||||
selectedClass: 'active'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
$('a.views-remove-link').once('views-processed').click(function(event) {
|
||||
var id = $(this).attr('id').replace('views-remove-link-', '');
|
||||
$('#views-row-' + id).hide();
|
||||
$('#views-removed-' + id).attr('checked', true);
|
||||
event.preventDefault();
|
||||
});
|
||||
/**
|
||||
* Here is to handle display deletion
|
||||
* (checking in the hidden checkbox and hiding out the row).
|
||||
*/
|
||||
$('a.display-remove-link')
|
||||
.addClass('display-processed')
|
||||
.click(function() {
|
||||
var id = $(this).attr('id').replace('display-remove-link-', '');
|
||||
$('#display-row-' + id).hide();
|
||||
$('#display-removed-' + id).attr('checked', true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to parse a querystring.
|
||||
*/
|
||||
Drupal.Views.parseQueryString = function (query) {
|
||||
var args = {};
|
||||
var pos = query.indexOf('?');
|
||||
if (pos != -1) {
|
||||
query = query.substring(pos + 1);
|
||||
}
|
||||
var pairs = query.split('&');
|
||||
for(var i in pairs) {
|
||||
if (typeof(pairs[i]) == 'string') {
|
||||
var pair = pairs[i].split('=');
|
||||
// Ignore the 'q' path argument, if present.
|
||||
if (pair[0] != 'q' && pair[1]) {
|
||||
args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
|
||||
Drupal.Views.parseQueryString = function (query) {
|
||||
var args = {};
|
||||
var pos = query.indexOf('?');
|
||||
if (pos != -1) {
|
||||
query = query.substring(pos + 1);
|
||||
}
|
||||
var pairs = query.split('&');
|
||||
for (var i in pairs) {
|
||||
if (typeof(pairs[i]) == 'string') {
|
||||
var pair = pairs[i].split('=');
|
||||
// Ignore the 'q' path argument, if present.
|
||||
if (pair[0] != 'q' && pair[1]) {
|
||||
args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return args;
|
||||
};
|
||||
return args;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Helper function to return a view's arguments based on a path.
|
||||
*/
|
||||
Drupal.Views.parseViewArgs = function (href, viewPath) {
|
||||
Drupal.Views.parseViewArgs = function (href, viewPath) {
|
||||
|
||||
// Provide language prefix.
|
||||
if (Drupal.settings.pathPrefix) {
|
||||
var viewPath = Drupal.settings.pathPrefix + viewPath;
|
||||
}
|
||||
var returnObj = {};
|
||||
var path = Drupal.Views.getPath(href);
|
||||
// Ensure we have a correct path.
|
||||
if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
|
||||
var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
|
||||
returnObj.view_args = args;
|
||||
returnObj.view_path = path;
|
||||
}
|
||||
return returnObj;
|
||||
};
|
||||
// Provide language prefix.
|
||||
if (Drupal.settings.pathPrefix) {
|
||||
var viewPath = Drupal.settings.pathPrefix + viewPath;
|
||||
}
|
||||
var returnObj = {};
|
||||
var path = Drupal.Views.getPath(href);
|
||||
// Ensure we have a correct path.
|
||||
if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
|
||||
var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
|
||||
returnObj.view_args = args;
|
||||
returnObj.view_path = path;
|
||||
}
|
||||
return returnObj;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Strip off the protocol plus domain from an href.
|
||||
*/
|
||||
Drupal.Views.pathPortion = function (href) {
|
||||
// Remove e.g. http://example.com if present.
|
||||
var protocol = window.location.protocol;
|
||||
if (href.substring(0, protocol.length) == protocol) {
|
||||
// 2 is the length of the '//' that normally follows the protocol
|
||||
href = href.substring(href.indexOf('/', protocol.length + 2));
|
||||
}
|
||||
return href;
|
||||
};
|
||||
Drupal.Views.pathPortion = function (href) {
|
||||
// Remove e.g. http://example.com if present.
|
||||
var protocol = window.location.protocol;
|
||||
if (href.substring(0, protocol.length) == protocol) {
|
||||
// 2 is the length of the '//' that normally follows the protocol.
|
||||
href = href.substring(href.indexOf('/', protocol.length + 2));
|
||||
}
|
||||
return href;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the Drupal path portion of an href.
|
||||
*/
|
||||
Drupal.Views.getPath = function (href) {
|
||||
href = Drupal.Views.pathPortion(href);
|
||||
href = href.substring(Drupal.settings.basePath.length, href.length);
|
||||
// 3 is the length of the '?q=' added to the url without clean urls.
|
||||
if (href.substring(0, 3) == '?q=') {
|
||||
href = href.substring(3, href.length);
|
||||
}
|
||||
var chars = ['#', '?', '&'];
|
||||
for (var i in chars) {
|
||||
if (href.indexOf(chars[i]) > -1) {
|
||||
href = href.substr(0, href.indexOf(chars[i]));
|
||||
Drupal.Views.getPath = function (href) {
|
||||
href = Drupal.Views.pathPortion(href);
|
||||
href = href.substring(Drupal.settings.basePath.length, href.length);
|
||||
// 3 is the length of the '?q=' added to the url without clean urls.
|
||||
if (href.substring(0, 3) == '?q=') {
|
||||
href = href.substring(3, href.length);
|
||||
}
|
||||
}
|
||||
return href;
|
||||
};
|
||||
var chars = ['#', '?', '&'];
|
||||
for (var i in chars) {
|
||||
if (href.indexOf(chars[i]) > -1) {
|
||||
href = href.substr(0, href.indexOf(chars[i]));
|
||||
}
|
||||
}
|
||||
return href;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* @file
|
||||
* This is part of a patch to address a jQueryUI bug. The bug is responsible
|
||||
* for the inability to scroll a page when a modal dialog is active. If the content
|
||||
* of the dialog extends beyond the bottom of the viewport, the user is only able
|
||||
@@ -9,19 +10,22 @@
|
||||
* @see views_ui.module
|
||||
* @see js/jquery.ui.dialog.min.js
|
||||
*
|
||||
* This javascript patch overwrites the $.ui.dialog.overlay.events object to remove
|
||||
* This JavaScript patch overwrites the $.ui.dialog.overlay.events object to remove
|
||||
* the mousedown, mouseup and click events from the list of events that are bound
|
||||
* in $.ui.dialog.overlay.create
|
||||
*
|
||||
* The original code for this object:
|
||||
* $.ui.dialog.overlay.events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
||||
* function(event) { return event + '.dialog-overlay'; }).join(' '),
|
||||
*
|
||||
* function(event) {
|
||||
* return event + '.dialog-overlay';
|
||||
* }).join(' '),
|
||||
*/
|
||||
|
||||
(function ($, undefined) {
|
||||
if ($.ui && $.ui.dialog && $.ui.dialog.overlay) {
|
||||
$.ui.dialog.overlay.events = $.map('focus,keydown,keypress'.split(','),
|
||||
function(event) { return event + '.dialog-overlay'; }).join(' ');
|
||||
function(event) {
|
||||
return event + '.dialog-overlay';
|
||||
}).join(' ');
|
||||
}
|
||||
}(jQuery));
|
||||
|
@@ -187,7 +187,8 @@ Drupal.viewsUi.addItemForm.prototype.handleCheck = function (event) {
|
||||
else {
|
||||
var length = this.checkedItems.length;
|
||||
var position = jQuery.inArray(label, this.checkedItems);
|
||||
// Delete the item from the list and take sure that the list doesn't have undefined items left.
|
||||
// Delete the item from the list and take sure that the list doesn't have
|
||||
// undefined items left.
|
||||
for (var i = 0; i < this.checkedItems.length; i++) {
|
||||
if (i == position) {
|
||||
this.checkedItems.splice(i, 1);
|
||||
@@ -245,7 +246,7 @@ Drupal.behaviors.viewsUiRenderAddViewButton.attach = function (context, settings
|
||||
});
|
||||
$addDisplayDropdown.appendTo($menu);
|
||||
|
||||
// Add the click handler for the add display button
|
||||
// Add the click handler for the add display button.
|
||||
$('li.add > a', $menu).bind('click', function (event) {
|
||||
event.preventDefault();
|
||||
var $trigger = $(this);
|
||||
@@ -668,7 +669,7 @@ Drupal.viewsUi.rearrangeFilterHandler.prototype.modifyTableDrag = function () {
|
||||
|
||||
// Make sure the "group" dropdown is properly updated when rows are dragged
|
||||
// into an empty filter group. This is borrowed heavily from the block.js
|
||||
// implementation of tableDrag.onDrop().
|
||||
// Implements tableDrag.onDrop().
|
||||
var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0);
|
||||
var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
var groupField = $('select.views-group-select', this.rowObject.element);
|
||||
@@ -769,14 +770,14 @@ Drupal.behaviors.viewsFilterConfigSelectAll.attach = function(context) {
|
||||
$('#views-ui-config-item-form div.form-item-options-value-all', context).once(function() {
|
||||
$(this).show();
|
||||
})
|
||||
.find('input[type=checkbox]')
|
||||
.click(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
// Update all checkbox beside the select all checkbox.
|
||||
$(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() {
|
||||
$(this).attr('checked', checked);
|
||||
.find('input[type=checkbox]')
|
||||
.click(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
// Update all checkbox beside the select all checkbox.
|
||||
$(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() {
|
||||
$(this).attr('checked', checked);
|
||||
});
|
||||
});
|
||||
});
|
||||
// Uncheck the select all checkbox if any of the others are unchecked.
|
||||
$('#views-ui-config-item-form div.form-type-checkbox').not($('.form-item-options-value-all')).find('input[type=checkbox]').each(function() {
|
||||
$(this).click(function() {
|
||||
@@ -926,7 +927,7 @@ Drupal.behaviors.viewsUiOverrideSelect.attach = function (context, settings) {
|
||||
$submit.val(Drupal.t('Apply (this display)'));
|
||||
}
|
||||
})
|
||||
.trigger('change');
|
||||
.trigger('change');
|
||||
});
|
||||
|
||||
};
|
||||
@@ -935,13 +936,14 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
var $ = jQuery;
|
||||
var $modal = $('.views-ui-dialog');
|
||||
var $scroll = $('.scroll', $modal);
|
||||
if ($modal.size() == 0 || $modal.css('display') == 'none') {
|
||||
if ($modal.length == 0 || $modal.css('display') == 'none') {
|
||||
return;
|
||||
}
|
||||
|
||||
var maxWidth = parseInt($(window).width() * .85); // 70% of window
|
||||
var minWidth = parseInt($(window).width() * .6); // 70% of window
|
||||
|
||||
var maxWidth = parseInt($(window).width() * .85);
|
||||
// 70% of window.
|
||||
var minWidth = parseInt($(window).width() * .6);
|
||||
// 70% of window.
|
||||
// Set the modal to the minwidth so that our width calculation of
|
||||
// children works.
|
||||
$modal.css('width', minWidth);
|
||||
@@ -976,15 +978,14 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
|
||||
// Now, calculate what the difference between the scroll and the modal
|
||||
// will be.
|
||||
|
||||
var difference = 0;
|
||||
difference += parseInt($scroll.css('padding-top'));
|
||||
difference += parseInt($scroll.css('padding-bottom'));
|
||||
difference += $('.views-override').outerHeight(true);
|
||||
difference += $('.views-messages').outerHeight(true);
|
||||
difference += $('#views-ajax-title').outerHeight(true);
|
||||
difference += $('.views-add-form-selected').outerHeight(true);
|
||||
difference += $('.form-buttons', $modal).outerHeight(true);
|
||||
difference += $('.views-override').outerHeight(true) || 0;
|
||||
difference += $('.views-messages').outerHeight(true) || 0;
|
||||
difference += $('#views-ajax-title').outerHeight(true) || 0;
|
||||
difference += $('.views-add-form-selected').outerHeight(true) || 0;
|
||||
difference += $('.form-buttons', $modal).outerHeight(true) || 0;
|
||||
|
||||
height = scrollHeight + difference;
|
||||
|
||||
@@ -1001,7 +1002,7 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
width = maxWidth;
|
||||
}
|
||||
|
||||
// Get where we should move content to
|
||||
// Get where we should move content to.
|
||||
var top = ($(window).height() / 2) - (height / 2);
|
||||
var left = ($(window).width() / 2) - (width / 2);
|
||||
|
||||
|
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* @file
|
||||
* Javascript related to contextual links.
|
||||
* JavaScript related to contextual links.
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.viewsContextualLinks = {
|
||||
attach: function (context) {
|
||||
// If there are views-related contextual links attached to the main page
|
||||
// content, find the smallest region that encloses both the links and the
|
||||
// view, and display it as a contextual links region.
|
||||
$('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region');
|
||||
}
|
||||
};
|
||||
Drupal.behaviors.viewsContextualLinks = {
|
||||
attach: function (context) {
|
||||
// If there are views-related contextual links attached to the main page
|
||||
// content, find the smallest region that encloses both the links and the
|
||||
// view, and display it as a contextual links region.
|
||||
$('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region');
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -1,21 +1,21 @@
|
||||
/**
|
||||
* @file
|
||||
* Javascript related to the main view list.
|
||||
* JavaScript related to the main view list.
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.viewsUIList = {
|
||||
attach: function (context) {
|
||||
$('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() {
|
||||
$(this).click(function() {
|
||||
var query = $.deparam.querystring(this.href);
|
||||
$('#ctools-export-ui-list-form select[name=order]').val(query['order']);
|
||||
$('#ctools-export-ui-list-form select[name=sort]').val(query['sort']);
|
||||
$('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click');
|
||||
return false;
|
||||
Drupal.behaviors.viewsUIList = {
|
||||
attach: function (context) {
|
||||
$('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() {
|
||||
$(this).click(function() {
|
||||
var query = $.deparam.querystring(this.href);
|
||||
$('#ctools-export-ui-list-form select[name=order]').val(query['order']);
|
||||
$('#ctools-export-ui-list-form select[name=sort]').val(query['sort']);
|
||||
$('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
Reference in New Issue
Block a user