Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
365
modules/views/js/ajax.js
Normal file
365
modules/views/js/ajax.js
Normal file
|
@ -0,0 +1,365 @@
|
|||
/**
|
||||
* @file ajax_admin.js
|
||||
*
|
||||
* Handles AJAX submission and response in Views UI.
|
||||
*/
|
||||
|
||||
Drupal.Views.Ajax = Drupal.Views.Ajax || {};
|
||||
|
||||
/**
|
||||
* Handles the simple process of setting the ajax form area with new data.
|
||||
*/
|
||||
Drupal.Views.Ajax.setForm = function(title, output) {
|
||||
$(Drupal.settings.views.ajax.title).html(title);
|
||||
$(Drupal.settings.views.ajax.id).html(output);
|
||||
}
|
||||
|
||||
/**
|
||||
* An ajax responder that accepts a packet of JSON data and acts appropriately.
|
||||
*
|
||||
* The following fields control behavior.
|
||||
* - 'display': Display the associated data in the form area; bind the new
|
||||
* form to 'url' if appropriate. The 'title' field may also be used.
|
||||
* - 'add': This is a keyed array of HTML output to add via append. The key is
|
||||
* the id to append via $(key).append(value)
|
||||
* - 'replace': This is a keyed array of HTML output to add via replace. The key is
|
||||
* the id to append via $(key).html(value)
|
||||
*
|
||||
*/
|
||||
Drupal.Views.Ajax.ajaxResponse = function(data) {
|
||||
$('a.views-throbbing').removeClass('views-throbbing');
|
||||
$('span.views-throbbing').remove();
|
||||
|
||||
if (data.debug) {
|
||||
alert(data.debug);
|
||||
}
|
||||
|
||||
// See if we have any settings to extend. Do this first so that behaviors
|
||||
// can access the new settings easily.
|
||||
|
||||
if (Drupal.settings.viewsAjax) {
|
||||
Drupal.settings.viewsAjax = {};
|
||||
}
|
||||
if (data.js) {
|
||||
$.extend(Drupal.settings, data.js);
|
||||
}
|
||||
|
||||
// Check the 'display' for data.
|
||||
if (data.display) {
|
||||
Drupal.Views.Ajax.setForm(data.title, data.display);
|
||||
|
||||
// if a URL was supplied, bind the form to it.
|
||||
if (data.url) {
|
||||
var ajax_area = Drupal.settings.views.ajax.id;
|
||||
var ajax_title = Drupal.settings.views.ajax.title;
|
||||
|
||||
// Bind a click to the button to set the value for the button.
|
||||
$('input[type=submit], button', ajax_area).unbind('click');
|
||||
$('input[type=submit], button', ajax_area).click(function() {
|
||||
$('form', ajax_area).append('<input type="hidden" name="'
|
||||
+ $(this).attr('name') + '" value="' + $(this).val() + '">');
|
||||
$(this).after('<span class="views-throbbing"> </span>');
|
||||
});
|
||||
|
||||
// Bind forms to ajax submit.
|
||||
$('form', ajax_area).unbind('submit'); // be safe here.
|
||||
$('form', ajax_area).submit(function(arg) {
|
||||
$(this).ajaxSubmit({
|
||||
url: data.url,
|
||||
data: { 'js': 1 },
|
||||
type: 'POST',
|
||||
success: Drupal.Views.Ajax.ajaxResponse,
|
||||
error: function(xhr) { $('span.views-throbbing').remove(); Drupal.Views.Ajax.handleErrors(xhr, data.url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Drupal.attachBehaviors(ajax_area);
|
||||
}
|
||||
else if (!data.tab) {
|
||||
// If no display, reset the form.
|
||||
Drupal.Views.Ajax.setForm('', Drupal.settings.views.ajax.defaultForm);
|
||||
//Enable the save and delete button.
|
||||
$('#edit-save').removeAttr('disabled');
|
||||
$('#edit-delete').removeAttr('disabled');
|
||||
// Trigger an update for the live preview when we reach this state:
|
||||
if ($('#views-ui-preview-form input#edit-live-preview').is(':checked')) {
|
||||
$('#views-ui-preview-form').trigger('submit');
|
||||
}
|
||||
}
|
||||
|
||||
// Go through the 'add' array and add any new content we're instructed to add.
|
||||
if (data.add) {
|
||||
for (id in data.add) {
|
||||
var newContent = $(id).append(data.add[id]);
|
||||
Drupal.attachBehaviors(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
// Go through the 'replace' array and replace any content we're instructed to.
|
||||
if (data.replace) {
|
||||
for (id in data.replace) {
|
||||
$(id).html(data.replace[id]);
|
||||
Drupal.attachBehaviors(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Go through and add any requested tabs
|
||||
if (data.tab) {
|
||||
for (id in data.tab) {
|
||||
// Retrieve the tabset instance by stored ID.
|
||||
var instance = Drupal.Views.Tabs.instances[$('#views-tabset').data('UI_TABS_UUID')];
|
||||
instance.add(id, data.tab[id]['title'], 0);
|
||||
instance.click(instance.$tabs.length);
|
||||
|
||||
$(id).html(data.tab[id]['body']);
|
||||
$(id).addClass('views-tab');
|
||||
|
||||
// Update the preview widget to preview the new tab.
|
||||
var display_id = id.replace('#views-tab-', '');
|
||||
$("#preview-display-id").append('<option selected="selected" value="' + display_id + '">' + data.tab[id]['title'] + '</option>');
|
||||
|
||||
Drupal.attachBehaviors(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.hilite) {
|
||||
$('.hilited').removeClass('hilited');
|
||||
$(data.hilite).addClass('hilited');
|
||||
}
|
||||
|
||||
if (data.changed) {
|
||||
$('div.views-basic-info').addClass('changed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An ajax responder that accepts a packet of JSON data and acts appropriately.
|
||||
* This one specifically responds to the Views live preview area, so it's
|
||||
* hardcoded and specialized.
|
||||
*/
|
||||
Drupal.Views.Ajax.previewResponse = function(data) {
|
||||
$('a.views-throbbing').removeClass('views-throbbing');
|
||||
$('span.views-throbbing').remove();
|
||||
|
||||
if (data.debug) {
|
||||
alert(data.debug);
|
||||
}
|
||||
|
||||
// See if we have any settings to extend. Do this first so that behaviors
|
||||
// can access the new settings easily.
|
||||
|
||||
// Clear any previous viewsAjax settings.
|
||||
if (Drupal.settings.viewsAjax) {
|
||||
Drupal.settings.viewsAjax = {};
|
||||
}
|
||||
if (data.js) {
|
||||
$.extend(Drupal.settings, data.js);
|
||||
}
|
||||
|
||||
// Check the 'display' for data.
|
||||
if (data.display) {
|
||||
var ajax_area = 'div#views-live-preview';
|
||||
$(ajax_area).html(data.display);
|
||||
|
||||
var url = $(ajax_area, 'form').attr('action');
|
||||
|
||||
// if a URL was supplied, bind the form to it.
|
||||
if (url) {
|
||||
// Bind a click to the button to set the value for the button.
|
||||
$('input[type=submit], button', ajax_area).unbind('click');
|
||||
$('input[type=submit], button', ajax_area).click(function() {
|
||||
$('form', ajax_area).append('<input type="hidden" name="'
|
||||
+ $(this).attr('name') + '" value="' + $(this).val() + '">');
|
||||
$(this).after('<span class="views-throbbing"> </span>');
|
||||
});
|
||||
|
||||
// Bind forms to ajax submit.
|
||||
$('form', ajax_area).unbind('submit'); // be safe here.
|
||||
$('form', ajax_area).submit(function() {
|
||||
$(this).ajaxSubmit({
|
||||
url: url,
|
||||
data: { 'js': 1 },
|
||||
type: 'POST',
|
||||
success: Drupal.Views.Ajax.previewResponse,
|
||||
error: function(xhr) { $('span.views-throbbing').remove(); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Drupal.attachBehaviors(ajax_area);
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.Views.updatePreviewForm = function() {
|
||||
var url = $(this).attr('action');
|
||||
url = url.replace('nojs', 'ajax');
|
||||
|
||||
$('input[type=submit], button', this).after('<span class="views-throbbing"> </span>');
|
||||
$(this).ajaxSubmit({
|
||||
url: url,
|
||||
data: { 'js': 1 },
|
||||
type: 'POST',
|
||||
success: Drupal.Views.Ajax.previewResponse,
|
||||
error: function(xhr) { $('span.views-throbbing').remove(); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Drupal.Views.updatePreviewFilterForm = function() {
|
||||
var url = $(this).attr('action');
|
||||
url = url.replace('nojs', 'ajax');
|
||||
|
||||
$('input[type=submit], button', this).after('<span class="views-throbbing"> </span>');
|
||||
$('input[name=q]', this).remove(); // remove 'q' for live preview.
|
||||
$(this).ajaxSubmit({
|
||||
url: url,
|
||||
data: { 'js': 1 },
|
||||
type: 'GET',
|
||||
success: Drupal.Views.Ajax.previewResponse,
|
||||
error: function(xhr) { $('span.views-throbbing').remove(); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Drupal.Views.updatePreviewLink = function() {
|
||||
var url = $(this).attr('href');
|
||||
url = url.replace('nojs', 'ajax');
|
||||
var intern_url = Drupal.Views.getPath(url);
|
||||
|
||||
if (intern_url.substring(0, 17) != 'admin/build/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$(this).addClass('views-throbbing');
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: 'js=1',
|
||||
type: 'POST',
|
||||
success: Drupal.Views.Ajax.previewResponse,
|
||||
error: function(xhr) { $(this).removeClass('views-throbbing'); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Drupal.behaviors.ViewsAjaxLinks = function() {
|
||||
// Make specified links ajaxy.
|
||||
$('a.views-ajax-link:not(.views-processed)').addClass('views-processed').click(function() {
|
||||
// Translate the href on the link to the ajax href. That way this degrades
|
||||
// into a nice, normal link.
|
||||
var url = $(this).attr('href');
|
||||
url = url.replace('nojs', 'ajax');
|
||||
|
||||
// Turn on the hilite to indicate this is in use.
|
||||
$(this).addClass('hilite');
|
||||
|
||||
// Disable the save and delete button.
|
||||
$('#edit-save').attr('disabled', 'true');
|
||||
$('#edit-delete').attr('disabled', 'true');
|
||||
|
||||
$(this).addClass('views-throbbing');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: 'js=1',
|
||||
success: Drupal.Views.Ajax.ajaxResponse,
|
||||
error: function(xhr) { $(this).removeClass('views-throbbing'); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('form.views-ajax-form:not(.views-processed)').addClass('views-processed').submit(function(arg) {
|
||||
// Translate the href on the link to the ajax href. That way this degrades
|
||||
// into a nice, normal link.
|
||||
var url = $(this).attr('action');
|
||||
url = url.replace('nojs', 'ajax');
|
||||
|
||||
// $('input[@type=submit]', this).after('<span class="views-throbbing"> </span>');
|
||||
$(this).ajaxSubmit({
|
||||
url: url,
|
||||
data: { 'js': 1 },
|
||||
type: 'POST',
|
||||
success: Drupal.Views.Ajax.ajaxResponse,
|
||||
error: function(xhr) { $('span.views-throbbing').remove(); Drupal.Views.Ajax.handleErrors(xhr, url); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Bind the live preview to where it's supposed to go.
|
||||
|
||||
$('form#views-ui-preview-form:not(.views-processed)')
|
||||
.addClass('views-processed')
|
||||
.submit(Drupal.Views.updatePreviewForm);
|
||||
|
||||
$('div#views-live-preview form:not(.views-processed)')
|
||||
.addClass('views-processed')
|
||||
.submit(Drupal.Views.updatePreviewFilterForm);
|
||||
|
||||
$('div#views-live-preview a:not(.views-processed)')
|
||||
.addClass('views-processed')
|
||||
.click(Drupal.Views.updatePreviewLink);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync preview display.
|
||||
*/
|
||||
Drupal.behaviors.syncPreviewDisplay = function() {
|
||||
$("#views-tabset a").click(function() {
|
||||
var href = $(this).attr('href');
|
||||
// Cut of #views-tabset.
|
||||
var display_id = href.substr(11);
|
||||
// Set the form element.
|
||||
$("#views-live-preview #preview-display-id").val(display_id);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of irritating tabledrag messages
|
||||
*/
|
||||
Drupal.theme.tableDragChangedWarning = function () {
|
||||
return '<div></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display error in a more fashion way
|
||||
*/
|
||||
Drupal.Views.Ajax.handleErrors = function (xhr, path) {
|
||||
var error_text = '';
|
||||
|
||||
if ((xhr.status == 500 && xhr.responseText) || xhr.status == 200) {
|
||||
error_text = xhr.responseText;
|
||||
|
||||
// Replace all < and > by < and >
|
||||
error_text = error_text.replace("/&(lt|gt);/g", function (m, p) {
|
||||
return (p == "lt")? "<" : ">";
|
||||
});
|
||||
|
||||
// Now, replace all html tags by empty spaces
|
||||
error_text = error_text.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,"");
|
||||
|
||||
// Fix end lines
|
||||
error_text = error_text.replace(/[\n]+\s+/g,"\n");
|
||||
}
|
||||
else if (xhr.status == 500) {
|
||||
error_text = xhr.status + ': ' + Drupal.t("Internal server error. Please see server or PHP logs for error information.");
|
||||
}
|
||||
else {
|
||||
error_text = xhr.status + ': ' + xhr.statusText;
|
||||
}
|
||||
|
||||
alert(Drupal.t("An error occurred at @path.\n\nError Description: @error", {'@path': path, '@error': error_text}));
|
||||
}
|
167
modules/views/js/ajax_view.js
Normal file
167
modules/views/js/ajax_view.js
Normal file
|
@ -0,0 +1,167 @@
|
|||
|
||||
/**
|
||||
* @file ajaxView.js
|
||||
*
|
||||
* Handles AJAX fetching of views, including filter submission and response.
|
||||
*/
|
||||
|
||||
Drupal.Views.Ajax = Drupal.Views.Ajax || {};
|
||||
|
||||
/**
|
||||
* An ajax responder that accepts a packet of JSON data and acts appropriately.
|
||||
*
|
||||
* The following fields control behavior.
|
||||
* - 'display': Display the associated data in the view area.
|
||||
*/
|
||||
Drupal.Views.Ajax.ajaxViewResponse = function(target, response) {
|
||||
|
||||
if (response.debug) {
|
||||
alert(response.debug);
|
||||
}
|
||||
|
||||
var $view = $(target);
|
||||
|
||||
// Check the 'display' for data.
|
||||
if (response.status && response.display) {
|
||||
var $newView = $(response.display);
|
||||
$view.replaceWith($newView);
|
||||
$view = $newView;
|
||||
Drupal.attachBehaviors($view.parent());
|
||||
}
|
||||
|
||||
if (response.messages) {
|
||||
// Show any messages (but first remove old ones, if there are any).
|
||||
$view.find('.views-messages').remove().end().prepend(response.messages);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Ajax behavior for views.
|
||||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
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];
|
||||
}
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
if (settings.view_dom_id) {
|
||||
var view = '.view-dom-id-' + settings.view_dom_id;
|
||||
if (!$(view).size()) {
|
||||
// Backward compatibility: if 'views-view.tpl.php' is old and doesn't
|
||||
// contain the 'view-dom-id-#' class, we fall back to the old way of
|
||||
// locating the view:
|
||||
view = '.view-id-' + settings.view_name + '.view-display-id-' + settings.view_display_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process exposed filter forms.
|
||||
$('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'))
|
||||
.filter(':not(.views-processed)')
|
||||
.each(function () {
|
||||
// remove 'q' from the form; it's there for clean URLs
|
||||
// so that it submits to the right place with regular submit
|
||||
// but this method is submitting elsewhere.
|
||||
$('input[name=q]', this).remove();
|
||||
var form = this;
|
||||
// ajaxSubmit doesn't accept a data argument, so we have to
|
||||
// pass additional fields this way.
|
||||
$.each(settings, function(key, setting) {
|
||||
$(form).append('<input type="hidden" name="'+ key + '" value="'+ setting +'"/>');
|
||||
});
|
||||
})
|
||||
.addClass('views-processed')
|
||||
.submit(function () {
|
||||
$('input[type=submit], button', this).after('<span class="views-throbbing"> </span>');
|
||||
var object = this;
|
||||
$(this).ajaxSubmit({
|
||||
url: ajax_path,
|
||||
type: 'GET',
|
||||
success: function(response) {
|
||||
// Call all callbacks.
|
||||
if (response.__callbacks) {
|
||||
$.each(response.__callbacks, function(i, callback) {
|
||||
eval(callback)(view, response);
|
||||
});
|
||||
$('.views-throbbing', object).remove();
|
||||
}
|
||||
},
|
||||
error: function(xhr) { Drupal.Views.Ajax.handleErrors(xhr, ajax_path); $('.views-throbbing', object).remove(); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(view).filter(':not(.views-processed)')
|
||||
// Don't attach to nested views. Doing so would attach multiple behaviors
|
||||
// to a given element.
|
||||
.filter(function() {
|
||||
// If there is at least one parent with a view class, this view
|
||||
// is nested (e.g., an attachment). Bail.
|
||||
return !$(this).parents('.view').size();
|
||||
})
|
||||
.each(function() {
|
||||
// Set a reference that will work in subsequent calls.
|
||||
var target = this;
|
||||
$(this)
|
||||
.addClass('views-processed')
|
||||
// Process pager, tablesort, and attachment summary links.
|
||||
.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
||||
.each(function () {
|
||||
var viewData = { 'js': 1 };
|
||||
// Construct an object using the settings defaults and then overriding
|
||||
// with data specific to the link.
|
||||
$.extend(
|
||||
viewData,
|
||||
Drupal.Views.parseQueryString($(this).attr('href')),
|
||||
// Extract argument data from the URL.
|
||||
Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path),
|
||||
// Settings must be used last to avoid sending url aliases to the server.
|
||||
settings
|
||||
);
|
||||
$(this).click(function () {
|
||||
$.extend(viewData, Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path));
|
||||
$(this).addClass('views-throbbing');
|
||||
$.ajax({
|
||||
url: ajax_path,
|
||||
type: 'GET',
|
||||
data: viewData,
|
||||
success: function(response) {
|
||||
$(this).removeClass('views-throbbing');
|
||||
// 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 = $(target).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 = target;
|
||||
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);
|
||||
}
|
||||
// Call all callbacks.
|
||||
if (response.__callbacks) {
|
||||
$.each(response.__callbacks, function(i, callback) {
|
||||
eval(callback)(target, response);
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr) { $(this).removeClass('views-throbbing'); Drupal.Views.Ajax.handleErrors(xhr, ajax_path); },
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}); // .each function () {
|
||||
}); // $view.filter().each
|
||||
}); // .each Drupal.settings.views.ajaxViews
|
||||
} // if
|
||||
};
|
122
modules/views/js/base.js
Normal file
122
modules/views/js/base.js
Normal file
|
@ -0,0 +1,122 @@
|
|||
/**
|
||||
* @file base.js
|
||||
*
|
||||
* Some basic behaviors and utility functions for Views.
|
||||
*/
|
||||
|
||||
Drupal.Views = {};
|
||||
|
||||
/**
|
||||
* jQuery UI tabs, Views integration component
|
||||
*/
|
||||
Drupal.behaviors.viewsTabs = function (context) {
|
||||
$('#views-tabset:not(.views-processed)').addClass('views-processed').each(function() {
|
||||
new Drupal.Views.Tabs($(this), {selectedClass: 'active'});
|
||||
});
|
||||
|
||||
$('a.views-remove-link')
|
||||
.addClass('views-processed')
|
||||
.click(function() {
|
||||
var id = $(this).attr('id').replace('views-remove-link-', '');
|
||||
$('#views-row-' + id).hide();
|
||||
$('#views-removed-' + id).attr('checked', true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* For IE, attach some javascript so that our hovers do what they're supposed
|
||||
* to do.
|
||||
*/
|
||||
Drupal.behaviors.viewsHoverlinks = function() {
|
||||
if ($.browser.msie) {
|
||||
// If IE, attach a hover event so we can see our admin links.
|
||||
$("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover(
|
||||
function() {
|
||||
$('div.views-hide', this).addClass("views-hide-hover"); return true;
|
||||
},
|
||||
function(){
|
||||
$('div.views-hide', this).removeClass("views-hide-hover"); return true;
|
||||
}
|
||||
);
|
||||
$("div.views-admin-links:not(.views-hover-processed)")
|
||||
.addClass('views-hover-processed')
|
||||
.hover(
|
||||
function() {
|
||||
$(this).addClass("views-admin-links-hover"); return true;
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass("views-admin-links-hover"); return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
return args;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to return a view's arguments based on a path.
|
||||
*/
|
||||
Drupal.Views.parseViewArgs = function (href, 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 (i in chars) {
|
||||
if (href.indexOf(chars[i]) > -1) {
|
||||
href = href.substr(0, href.indexOf(chars[i]));
|
||||
}
|
||||
}
|
||||
return href;
|
||||
};
|
195
modules/views/js/dependent.js
Normal file
195
modules/views/js/dependent.js
Normal file
|
@ -0,0 +1,195 @@
|
|||
/**
|
||||
* @file dependent.js
|
||||
*
|
||||
* Written by dmitrig01 (Dmitri Gaskin) for Views; this provides dependent
|
||||
* visibility for form items in Views' ajax forms.
|
||||
*
|
||||
* To your $form item definition add:
|
||||
* - '#process' => array('views_process_dependency'),
|
||||
* - Add '#dependency' => array('id-of-form-item' => array(list, of, values, that,
|
||||
make, this, item, show),
|
||||
*
|
||||
* Special considerations:
|
||||
* - radios are harder. Because Drupal doesn't give radio groups individual ids,
|
||||
* use 'radio:name-of-radio'
|
||||
*
|
||||
* - Checkboxes don't have their own id, so you need to add one in a div
|
||||
* around the checkboxes via #prefix and #suffix. You actually need to add TWO
|
||||
* divs because it's the parent that gets hidden. Also be sure to retain the
|
||||
* 'expand_checkboxes' in the #process array, because the views process will
|
||||
* override it.
|
||||
*/
|
||||
|
||||
Drupal.Views = Drupal.Views || {};
|
||||
|
||||
Drupal.Views.dependent = { bindings: {}, activeBindings: {}, activeTriggers: [] };
|
||||
|
||||
Drupal.Views.dependent.inArray = function(array, search_term) {
|
||||
var i = array.length;
|
||||
if (i > 0) {
|
||||
do {
|
||||
if (array[i] == search_term) {
|
||||
return true;
|
||||
}
|
||||
} while (i--);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Drupal.Views.dependent.autoAttach = function() {
|
||||
// Clear active bindings and triggers.
|
||||
for (i in Drupal.Views.dependent.activeTriggers) {
|
||||
jQuery(Drupal.Views.dependent.activeTriggers[i]).unbind('change');
|
||||
}
|
||||
Drupal.Views.dependent.activeTriggers = [];
|
||||
Drupal.Views.dependent.activeBindings = {};
|
||||
Drupal.Views.dependent.bindings = {};
|
||||
|
||||
if (!Drupal.settings.viewsAjax) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate through all relationships
|
||||
for (id in Drupal.settings.viewsAjax.formRelationships) {
|
||||
|
||||
// Drupal.Views.dependent.activeBindings[id] is a boolean,
|
||||
// whether the binding is active or not. Defaults to no.
|
||||
Drupal.Views.dependent.activeBindings[id] = 0;
|
||||
// Iterate through all possible values
|
||||
for(bind_id in Drupal.settings.viewsAjax.formRelationships[id].values) {
|
||||
// This creates a backward relationship. The bind_id is the ID
|
||||
// of the element which needs to change in order for the id to hide or become shown.
|
||||
// The id is the ID of the item which will be conditionally hidden or shown.
|
||||
// Here we're setting the bindings for the bind
|
||||
// id to be an empty array if it doesn't already have bindings to it
|
||||
if (!Drupal.Views.dependent.bindings[bind_id]) {
|
||||
Drupal.Views.dependent.bindings[bind_id] = [];
|
||||
}
|
||||
// Add this ID
|
||||
Drupal.Views.dependent.bindings[bind_id].push(id);
|
||||
// Big long if statement.
|
||||
// Drupal.settings.viewsAjax.formRelationships[id].values[bind_id] holds the possible values
|
||||
|
||||
if (bind_id.substring(0, 6) == 'radio:') {
|
||||
var trigger_id = "input[name='" + bind_id.substring(6) + "']";
|
||||
}
|
||||
else {
|
||||
var trigger_id = '#' + bind_id;
|
||||
}
|
||||
|
||||
Drupal.Views.dependent.activeTriggers.push(trigger_id);
|
||||
|
||||
if (jQuery(trigger_id).attr('type') == 'checkbox') {
|
||||
$(trigger_id).parent().addClass('hidden-options');
|
||||
}
|
||||
|
||||
var getValue = function(item, trigger) {
|
||||
if (item.substring(0, 6) == 'radio:') {
|
||||
var val = jQuery(trigger + ':checked').val();
|
||||
}
|
||||
else {
|
||||
switch (jQuery(trigger).attr('type')) {
|
||||
case 'checkbox':
|
||||
var val = jQuery(trigger).attr('checked') || 0;
|
||||
|
||||
if (val) {
|
||||
$(trigger).parent().removeClass('hidden-options').addClass('expanded-options');
|
||||
}
|
||||
else {
|
||||
$(trigger).parent().removeClass('expanded-options').addClass('hidden-options');
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
var val = jQuery(trigger).val();
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
var setChangeTrigger = function(trigger_id, bind_id) {
|
||||
// Triggered when change() is clicked.
|
||||
var changeTrigger = function() {
|
||||
var val = getValue(bind_id, trigger_id);
|
||||
|
||||
for (i in Drupal.Views.dependent.bindings[bind_id]) {
|
||||
var id = Drupal.Views.dependent.bindings[bind_id][i];
|
||||
|
||||
// Fix numerous errors
|
||||
if (typeof id != 'string') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// This bit had to be rewritten a bit because two properties on the
|
||||
// same set caused the counter to go up and up and up.
|
||||
if (!Drupal.Views.dependent.activeBindings[id]) {
|
||||
Drupal.Views.dependent.activeBindings[id] = {};
|
||||
}
|
||||
|
||||
if (Drupal.Views.dependent.inArray(Drupal.settings.viewsAjax.formRelationships[id].values[bind_id], val)) {
|
||||
Drupal.Views.dependent.activeBindings[id][bind_id] = 'bind';
|
||||
}
|
||||
else {
|
||||
delete Drupal.Views.dependent.activeBindings[id][bind_id];
|
||||
}
|
||||
|
||||
var len = 0;
|
||||
for (i in Drupal.Views.dependent.activeBindings[id]) {
|
||||
len++;
|
||||
}
|
||||
|
||||
var object = jQuery('#' + id + '-wrapper');
|
||||
if (!object.size()) {
|
||||
object = jQuery('#' + id).parent();
|
||||
}
|
||||
|
||||
var rel_num = Drupal.settings.viewsAjax.formRelationships[id].num;
|
||||
if (typeof rel_num === 'object') {
|
||||
rel_num = Drupal.settings.viewsAjax.formRelationships[id].num[0];
|
||||
}
|
||||
|
||||
if (rel_num <= len) {
|
||||
// Show if the element if criteria is matched
|
||||
object.show(0);
|
||||
object.addClass('dependent-options');
|
||||
}
|
||||
else {
|
||||
// Otherwise hide
|
||||
object.hide(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jQuery(trigger_id).change(function() {
|
||||
// Trigger the internal change function
|
||||
// the attr('id') is used because closures are more confusing
|
||||
changeTrigger(trigger_id, bind_id);
|
||||
});
|
||||
// Trigger initial reaction
|
||||
changeTrigger(trigger_id, bind_id);
|
||||
}
|
||||
setChangeTrigger(trigger_id, bind_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.behaviors.viewsDependent = function (context) {
|
||||
Drupal.Views.dependent.autoAttach();
|
||||
|
||||
// Really large sets of fields are too slow with the above method, so this
|
||||
// is a sort of hacked one that's faster but much less flexible.
|
||||
$("select.views-master-dependent:not(.views-processed)")
|
||||
.addClass('views-processed')
|
||||
.change(function() {
|
||||
var val = $(this).val();
|
||||
if (val == 'all') {
|
||||
$('.views-dependent-all').show(0);
|
||||
}
|
||||
else {
|
||||
$('.views-dependent-all').hide(0);
|
||||
$('.views-dependent-' + val).show(0);
|
||||
}
|
||||
})
|
||||
.trigger('change');
|
||||
}
|
401
modules/views/js/tabs.js
Normal file
401
modules/views/js/tabs.js
Normal file
|
@ -0,0 +1,401 @@
|
|||
|
||||
/**
|
||||
* @file tabs.js
|
||||
* jQuery UI Tabs (Tabs 3)
|
||||
*
|
||||
* This is nothing more than the pure jquery UI tabs implementation.
|
||||
* It has been implemented under the Drupal.Views.Tabs namespace to
|
||||
* avoid conflicts with alternatve versions of jquery, jquery UI.
|
||||
*/
|
||||
|
||||
Drupal.Views = Drupal.Views || {};
|
||||
|
||||
Drupal.Views.Tabs = function(el, options) {
|
||||
|
||||
this.source = el;
|
||||
|
||||
this.options = $.extend({
|
||||
|
||||
// basic setup
|
||||
initial: 0,
|
||||
event: 'click',
|
||||
disabled: [],
|
||||
// TODO bookmarkable: $.ajaxHistory ? true : false,
|
||||
unselected: false,
|
||||
toggle: options.unselected ? true : false,
|
||||
|
||||
// Ajax
|
||||
spinner: 'Loading…',
|
||||
cache: false,
|
||||
hashPrefix: 'tab-',
|
||||
|
||||
// animations
|
||||
/*fxFade: null,
|
||||
fxSlide: null,
|
||||
fxShow: null,
|
||||
fxHide: null,*/
|
||||
fxSpeed: 'normal',
|
||||
/*fxShowSpeed: null,
|
||||
fxHideSpeed: null,*/
|
||||
|
||||
// callbacks
|
||||
add: function() {},
|
||||
remove: function() {},
|
||||
enable: function() {},
|
||||
disable: function() {},
|
||||
click: function() {},
|
||||
hide: function() {},
|
||||
show: function() {},
|
||||
load: function() {},
|
||||
|
||||
// CSS classes
|
||||
navClass: 'ui-tabs-nav',
|
||||
selectedClass: 'ui-tabs-selected',
|
||||
disabledClass: 'ui-tabs-disabled',
|
||||
containerClass: 'ui-tabs-container',
|
||||
hideClass: 'ui-tabs-hide',
|
||||
loadingClass: 'ui-tabs-loading'
|
||||
|
||||
}, options);
|
||||
|
||||
this.tabify(true);
|
||||
|
||||
// save instance for later
|
||||
var uuid = 'instance-' + Drupal.Views.Tabs.prototype.count++;
|
||||
Drupal.Views.Tabs.instances[uuid] = this;
|
||||
this.source.data('UI_TABS_UUID', uuid);
|
||||
|
||||
};
|
||||
|
||||
// static
|
||||
Drupal.Views.Tabs.instances = {};
|
||||
|
||||
$.extend(Drupal.Views.Tabs.prototype, {
|
||||
animating: false,
|
||||
count: 0,
|
||||
tabify: function(init) {
|
||||
|
||||
this.$tabs = $('a:first-child', this.source);
|
||||
this.$containers = $([]);
|
||||
|
||||
var self = this, o = this.options;
|
||||
|
||||
this.$tabs.each(function(i, a) {
|
||||
// inline tab
|
||||
if (a.hash && a.hash.replace('#', '')) { // safari 2 reports '#' for an empty hash
|
||||
self.$containers = self.$containers.add(a.hash);
|
||||
}
|
||||
// remote tab
|
||||
else {
|
||||
var id = a.title && a.title.replace(/\s/g, '_') || o.hashPrefix + (self.count + 1) + '-' + (i + 1), url = a.href;
|
||||
a.href = '#' + id;
|
||||
a.url = url;
|
||||
self.$containers = self.$containers.add(
|
||||
$('#' + id)[0] || $('<div id="' + id + '" class="' + o.containerClass + '"></div>')
|
||||
.insertAfter( self.$containers[i - 1] || self.source )
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (init) {
|
||||
|
||||
// Try to retrieve initial tab from fragment identifier in url if present,
|
||||
// otherwise try to find selected class attribute on <li>.
|
||||
this.$tabs.each(function(i, a) {
|
||||
if (location.hash) {
|
||||
if (a.hash == location.hash) {
|
||||
o.initial = i;
|
||||
// prevent page scroll to fragment
|
||||
//if (($.browser.msie || $.browser.opera) && !o.remote) {
|
||||
if ($.browser.msie || $.browser.opera) {
|
||||
var $toShow = $(location.hash), toShowId = $toShow.attr('id');
|
||||
$toShow.attr('id', '');
|
||||
setTimeout(function() {
|
||||
$toShow.attr('id', toShowId); // restore id
|
||||
}, 500);
|
||||
}
|
||||
scrollTo(0, 0);
|
||||
return false; // break
|
||||
}
|
||||
} else if ( $(a).parents('li:eq(0)').is('li.' + o.selectedClass) ) {
|
||||
o.initial = i;
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
|
||||
// attach necessary classes for styling if not present
|
||||
$(this.source).is('.' + o.navClass) || $(this.source).addClass(o.navClass);
|
||||
this.$containers.each(function() {
|
||||
var $this = $(this);
|
||||
$this.is('.' + o.containerClass) || $this.addClass(o.containerClass);
|
||||
});
|
||||
|
||||
// highlight tab accordingly
|
||||
var $lis = $('li', this.source);
|
||||
this.$containers.addClass(o.hideClass);
|
||||
$lis.removeClass(o.selectedClass);
|
||||
if (!o.unselected) {
|
||||
this.$containers.slice(o.initial, o.initial + 1).show();
|
||||
$lis.slice(o.initial, o.initial + 1).addClass(o.selectedClass);
|
||||
}
|
||||
|
||||
// trigger load of initial tab is remote tab
|
||||
if (this.$tabs[o.initial].url) {
|
||||
this.load(o.initial + 1, this.$tabs[o.initial].url);
|
||||
if (o.cache) {
|
||||
this.$tabs[o.initial].url = null; // if loaded once do not load them again
|
||||
}
|
||||
}
|
||||
|
||||
// disabled tabs
|
||||
for (var i = 0, position; position = o.disabled[i]; i++) {
|
||||
this.disable(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// setup animations
|
||||
var showAnim = {}, hideAnim = {}, showSpeed = o.fxShowSpeed || o.fxSpeed,
|
||||
hideSpeed = o.fxHideSpeed || o.fxSpeed;
|
||||
if (o.fxSlide || o.fxFade) {
|
||||
if (o.fxSlide) {
|
||||
showAnim['height'] = 'show';
|
||||
hideAnim['height'] = 'hide';
|
||||
}
|
||||
if (o.fxFade) {
|
||||
showAnim['opacity'] = 'show';
|
||||
hideAnim['opacity'] = 'hide';
|
||||
}
|
||||
} else {
|
||||
if (o.fxShow) {
|
||||
showAnim = o.fxShow;
|
||||
} else { // use some kind of animation to prevent browser scrolling to the tab
|
||||
showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
|
||||
showSpeed = 1; // as little as 1 is sufficient
|
||||
}
|
||||
if (o.fxHide) {
|
||||
hideAnim = o.fxHide;
|
||||
} else { // use some kind of animation to prevent browser scrolling to the tab
|
||||
hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox
|
||||
hideSpeed = 1; // as little as 1 is sufficient
|
||||
}
|
||||
}
|
||||
|
||||
// callbacks
|
||||
var click = o.click, hide = o.hide, show = o.show;
|
||||
|
||||
// reset some styles to maintain print style sheets etc.
|
||||
var resetCSS = { display: '', overflow: '', height: '' };
|
||||
if (!$.browser.msie) { // not in IE to prevent ClearType font issue
|
||||
resetCSS['opacity'] = '';
|
||||
}
|
||||
|
||||
// hide a tab, animation prevents browser scrolling to fragment
|
||||
function hideTab(clicked, $hide, $show) {
|
||||
$hide.animate(hideAnim, hideSpeed, function() { //
|
||||
$hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
|
||||
hide(clicked, $show, $hide[0]);
|
||||
if ($show) {
|
||||
showTab(clicked, $hide, $show);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// show a tab, animation prevents browser scrolling to fragment
|
||||
function showTab(clicked, $hide, $show) {
|
||||
// show next tab
|
||||
if (!(o.fxSlide || o.fxFade || o.fxShow)) {
|
||||
$show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab containers
|
||||
}
|
||||
$show.animate(showAnim, showSpeed, function() {
|
||||
$show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
|
||||
if ($.browser.msie) {
|
||||
$hide[0].style.filter = '';
|
||||
$show[0].style.filter = '';
|
||||
}
|
||||
show(clicked, $show[0], $hide[0]);
|
||||
self.animating = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// switch a tab
|
||||
function switchTab(clicked, $hide, $show) {
|
||||
/*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
|
||||
$.ajaxHistory.update(clicked.hash);
|
||||
}*/
|
||||
$(clicked).parents('li:eq(0)').addClass(o.selectedClass)
|
||||
.siblings().removeClass(o.selectedClass);
|
||||
hideTab(clicked, $hide, $show);
|
||||
}
|
||||
|
||||
// tab click handler
|
||||
function tabClick(e) {
|
||||
|
||||
//var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
|
||||
var $li = $(this).parents('li:eq(0)'), $hide = self.$containers.filter(':visible'), $show = $(this.hash);
|
||||
|
||||
// if tab may be closed
|
||||
if (o.toggle && !$li.is('.' + o.disabledClass) && !self.animating) {
|
||||
if ($li.is('.' + o.selectedClass)) {
|
||||
$li.removeClass(o.selectedClass);
|
||||
hideTab(this, $hide);
|
||||
this.blur();
|
||||
return false;
|
||||
} else if (!$hide.length) {
|
||||
$li.addClass(o.selectedClass);
|
||||
showTab(this, $hide, $show);
|
||||
this.blur();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If tab is already selected or disabled, animation is still running or click callback
|
||||
// returns false stop here.
|
||||
// Check if click handler returns false last so that it is not executed for a disabled tab!
|
||||
if ($li.is('.' + o.selectedClass + ', .' + o.disabledClass)
|
||||
|| self.animating || click(this, $show[0], $hide[0]) === false) {
|
||||
this.blur();
|
||||
return false;
|
||||
}
|
||||
|
||||
self.animating = true;
|
||||
|
||||
// show new tab
|
||||
if ($show.length) {
|
||||
|
||||
// prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
|
||||
/*if ($.browser.msie && o.bookmarkable) {
|
||||
var showId = this.hash.replace('#', '');
|
||||
$show.attr('id', '');
|
||||
setTimeout(function() {
|
||||
$show.attr('id', showId); // restore id
|
||||
}, 0);
|
||||
}*/
|
||||
|
||||
if (this.url) { // remote tab
|
||||
var a = this;
|
||||
self.load(self.$tabs.index(this) + 1, this.url, function() {
|
||||
switchTab(a, $hide, $show);
|
||||
});
|
||||
if (o.cache) {
|
||||
this.url = null; // if loaded once do not load them again
|
||||
}
|
||||
} else {
|
||||
switchTab(this, $hide, $show);
|
||||
}
|
||||
|
||||
// Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
|
||||
/*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
||||
var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
|
||||
setTimeout(function() {
|
||||
scrollTo(scrollX, scrollY);
|
||||
}, 0);*/
|
||||
|
||||
} else {
|
||||
throw Drupal.t('jQuery UI Tabs: Mismatching fragment identifier.');
|
||||
}
|
||||
|
||||
this.blur(); // prevent IE from keeping other link focussed when using the back button
|
||||
|
||||
//return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// attach click event, avoid duplicates from former tabifying
|
||||
this.$tabs.unbind(o.event, tabClick).bind(o.event, tabClick);
|
||||
|
||||
},
|
||||
add: function(url, text, position) {
|
||||
if (url && text) {
|
||||
var o = this.options;
|
||||
position = position || this.$tabs.length; // append by default
|
||||
if (position >= this.$tabs.length) {
|
||||
var method = 'insertAfter';
|
||||
position = this.$tabs.length;
|
||||
} else {
|
||||
var method = 'insertBefore';
|
||||
}
|
||||
if (url.indexOf('#') == 0) { // ajax container is created by tabify automatically
|
||||
var $container = $(url);
|
||||
// try to find an existing element before creating a new one
|
||||
($container.length && $container || $('<div id="' + url.replace('#', '') + '" class="' + o.containerClass + ' ' + o.hideClass + '"></div>'))
|
||||
[method](this.$containers[position - 1]);
|
||||
}
|
||||
$('<li><a href="' + url + '"><span>' + text + '</span></a></li>')
|
||||
[method](this.$tabs.slice(position - 1, position).parents('li:eq(0)'));
|
||||
this.tabify();
|
||||
o.add(this.$tabs[position - 1], this.$containers[position - 1]); // callback
|
||||
} else {
|
||||
throw Drupal.t('jQuery UI Tabs: Not enough arguments to add tab.');
|
||||
}
|
||||
},
|
||||
remove: function(position) {
|
||||
if (position && position.constructor == Number) {
|
||||
this.$tabs.slice(position - 1, position).parents('li:eq(0)').remove();
|
||||
this.$containers.slice(position - 1, position).remove();
|
||||
this.tabify();
|
||||
}
|
||||
this.options.remove(); // callback
|
||||
},
|
||||
enable: function(position) {
|
||||
var $li = this.$tabs.slice(position - 1, position).parents('li:eq(0)'), o = this.options;
|
||||
$li.removeClass(o.disabledClass);
|
||||
if ($.browser.safari) { // fix disappearing tab after enabling in Safari... TODO check Safari 3
|
||||
$li.animate({ opacity: 1 }, 1, function() {
|
||||
$li.css({ opacity: '' });
|
||||
});
|
||||
}
|
||||
o.enable(this.$tabs[position - 1], this.$containers[position - 1]); // callback
|
||||
},
|
||||
disable: function(position) {
|
||||
var $li = this.$tabs.slice(position - 1, position).parents('li:eq(0)'), o = this.options;
|
||||
if ($.browser.safari) { // fix opacity of tab after disabling in Safari... TODO check Safari 3
|
||||
$li.animate({ opacity: 0 }, 1, function() {
|
||||
$li.css({ opacity: '' });
|
||||
});
|
||||
}
|
||||
$li.addClass(this.options.disabledClass);
|
||||
o.disable(this.$tabs[position - 1], this.$containers[position - 1]); // callback
|
||||
},
|
||||
click: function(position) {
|
||||
this.$tabs.slice(position - 1, position).trigger('click');
|
||||
},
|
||||
load: function(position, url, callback) {
|
||||
var self = this,
|
||||
o = this.options,
|
||||
$a = this.$tabs.slice(position - 1, position).addClass(o.loadingClass),
|
||||
$span = $('span', $a),
|
||||
text = $span.html();
|
||||
|
||||
// shift arguments
|
||||
if (url && url.constructor == Function) {
|
||||
callback = url;
|
||||
}
|
||||
|
||||
// set new URL
|
||||
if (url) {
|
||||
$a[0].url = url;
|
||||
}
|
||||
|
||||
// load
|
||||
if (o.spinner) {
|
||||
$span.html('<em>' + o.spinner + '</em>');
|
||||
}
|
||||
setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
|
||||
$($a[0].hash).load(url, function() {
|
||||
if (o.spinner) {
|
||||
$span.html(text);
|
||||
}
|
||||
$a.removeClass(o.loadingClass);
|
||||
// This callback is needed because the switch has to take place after loading
|
||||
// has completed.
|
||||
if (callback && callback.constructor == Function) {
|
||||
callback();
|
||||
}
|
||||
o.load(self.$tabs[position - 1], self.$containers[position - 1]); // callback
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
});
|
13
modules/views/js/view-list.js
Normal file
13
modules/views/js/view-list.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* @file view-list.js
|
||||
*
|
||||
* Handles JS things for view listing.
|
||||
*/
|
||||
Drupal.behaviors.ViewsList = function() {
|
||||
var timeoutID = 0;
|
||||
$('form#views-ui-list-views-form select:not(.views-processed)')
|
||||
.addClass('views-processed')
|
||||
.change(function() {
|
||||
$('#edit-views-apply').click();
|
||||
});
|
||||
};
|
Reference in a new issue