#174708 by multiple contributors: update jQuery to 1.2
parent
b3fe5b9cbf
commit
21ac9f1917
|
@ -1813,7 +1813,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
|
|||
|
||||
switch ($type) {
|
||||
case 'setting':
|
||||
$output .= '<script type="text/javascript">Drupal.extend({ settings: '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) ." });</script>\n";
|
||||
$output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) .");</script>\n";
|
||||
break;
|
||||
case 'inline':
|
||||
foreach ($data as $info) {
|
||||
|
|
12
misc/ahah.js
12
misc/ahah.js
|
@ -69,7 +69,9 @@ Drupal.ahah.prototype.onsubmit = function () {
|
|||
margin: '0 0 0 20px'
|
||||
});
|
||||
button.css('float', 'left').attr('disabled', true).after(progress_element);
|
||||
eval('progress_element.' + this.showEffect + '()');
|
||||
if (progress_element[this.showEffect]) {
|
||||
progress_element[this.showEffect]();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -93,10 +95,12 @@ Drupal.ahah.prototype.oncomplete = function (data) {
|
|||
if (this.method == 'replace') {
|
||||
wrapper.empty().append(new_content);
|
||||
}
|
||||
else {
|
||||
eval('wrapper.' + this.method + '(new_content)');
|
||||
else if (wrapper[this.method]) {
|
||||
wrapper[this.method](new_content);
|
||||
}
|
||||
if (new_content[this.showEffect]) {
|
||||
new_content[this.showEffect]();
|
||||
}
|
||||
eval('new_content.' + this.showEffect + '()');
|
||||
button.css('float', 'none').attr('disabled', false);
|
||||
|
||||
Drupal.attachBehaviors(new_content);
|
||||
|
|
|
@ -38,7 +38,7 @@ Drupal.jsAC = function (input, db) {
|
|||
|
||||
$(this.input)
|
||||
.keydown(function (event) { return ac.onkeydown(this, event); })
|
||||
.keyup(function (event) { ac.onkeyup(this, event) })
|
||||
.keyup(function (event) { ac.onkeyup(this, event); })
|
||||
.blur(function () { ac.hidePopup(); ac.db.cancel(); });
|
||||
|
||||
};
|
||||
|
@ -270,9 +270,8 @@ Drupal.ACDB.prototype.search = function (searchString) {
|
|||
$.ajax({
|
||||
type: "GET",
|
||||
url: db.uri +'/'+ Drupal.encodeURIComponent(searchString),
|
||||
success: function (data) {
|
||||
// Parse back result
|
||||
var matches = Drupal.parseJson(data);
|
||||
dataType: 'json',
|
||||
success: function (matches) {
|
||||
if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
|
||||
db.cache[searchString] = matches;
|
||||
// Verify if these are still the matches the user wants to see
|
||||
|
|
|
@ -35,13 +35,13 @@ Drupal.toggleFieldset = function(fieldset) {
|
|||
Drupal.collapseScrollIntoView = function (node) {
|
||||
var h = self.innerHeight || document.documentElement.clientHeight || $('body')[0].clientHeight || 0;
|
||||
var offset = self.pageYOffset || document.documentElement.scrollTop || $('body')[0].scrollTop || 0;
|
||||
var pos = Drupal.absolutePosition(node);
|
||||
var posY = $(node).offset().top;
|
||||
var fudge = 55;
|
||||
if (pos.y + node.offsetHeight + fudge > h + offset) {
|
||||
if (posY + node.offsetHeight + fudge > h + offset) {
|
||||
if (node.offsetHeight > h) {
|
||||
window.scrollTo(0, pos.y);
|
||||
window.scrollTo(0, posY);
|
||||
} else {
|
||||
window.scrollTo(0, pos.y + node.offsetHeight - h + fudge);
|
||||
window.scrollTo(0, posY + node.offsetHeight - h + fudge);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,20 +7,6 @@ var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale'
|
|||
*/
|
||||
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;
|
||||
|
||||
/**
|
||||
* Extends the current object with the parameter. Works recursively.
|
||||
*/
|
||||
Drupal.extend = function(obj) {
|
||||
for (var i in obj) {
|
||||
if (this[i]) {
|
||||
Drupal.extend.apply(this[i], [obj[i]]);
|
||||
}
|
||||
else {
|
||||
this[i] = obj[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach all registered behaviors to a page element.
|
||||
*
|
||||
|
@ -204,6 +190,7 @@ Drupal.redirectFormButton = function (uri, button, handler) {
|
|||
button.onmouseover = button.onfocus = function() {
|
||||
button.onclick = function() {
|
||||
// Create target iframe
|
||||
Drupal.deleteIframe();
|
||||
Drupal.createIframe();
|
||||
|
||||
// Prepare variables for use in anonymous function.
|
||||
|
@ -214,6 +201,7 @@ Drupal.redirectFormButton = function (uri, button, handler) {
|
|||
// Redirect form submission to iframe
|
||||
this.form.action = uri;
|
||||
this.form.target = 'redirect-target';
|
||||
this.form.submit();
|
||||
|
||||
handler.onsubmit();
|
||||
|
||||
|
@ -238,10 +226,10 @@ Drupal.redirectFormButton = function (uri, button, handler) {
|
|||
response = null;
|
||||
}
|
||||
|
||||
response = Drupal.parseJson(response);
|
||||
response = eval('('+ response +');');
|
||||
// Check response code
|
||||
if (response.status == 0) {
|
||||
handler.onerror(response.data);
|
||||
if (!response || response.status == 0) {
|
||||
handler.onerror(response.data || Drupal.t('Error parsing response'));
|
||||
return;
|
||||
}
|
||||
handler.oncomplete(response.data);
|
||||
|
@ -257,53 +245,6 @@ Drupal.redirectFormButton = function (uri, button, handler) {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the absolute position of an element on the screen
|
||||
*/
|
||||
Drupal.absolutePosition = function (el) {
|
||||
var sLeft = 0, sTop = 0;
|
||||
var isDiv = /^div$/i.test(el.tagName);
|
||||
if (isDiv && el.scrollLeft) {
|
||||
sLeft = el.scrollLeft;
|
||||
}
|
||||
if (isDiv && el.scrollTop) {
|
||||
sTop = el.scrollTop;
|
||||
}
|
||||
var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop };
|
||||
if (el.offsetParent) {
|
||||
var tmp = Drupal.absolutePosition(el.offsetParent);
|
||||
r.x += tmp.x;
|
||||
r.y += tmp.y;
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the dimensions of an element on the screen
|
||||
*/
|
||||
Drupal.dimensions = function (el) {
|
||||
return { width: el.offsetWidth, height: el.offsetHeight };
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the position of the mouse cursor based on the event object passed
|
||||
*/
|
||||
Drupal.mousePosition = function(e) {
|
||||
return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop };
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a JSON response.
|
||||
*
|
||||
* The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
|
||||
*/
|
||||
Drupal.parseJson = function (data) {
|
||||
if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
|
||||
return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') };
|
||||
}
|
||||
return eval('(' + data + ');');
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an invisible iframe for form submissions.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// $Id$
|
||||
|
||||
Drupal.behaviors.multiselectSelector = function() {
|
||||
// Automatically selects the right radio button in a multiselect control.
|
||||
$('.multiselect select:not(.multiselectSelector-processed)')
|
||||
.addClass('multiselectSelector-processed').change(function() {
|
||||
$('.multiselect input:radio[value="'+ this.id.substr(5) +'"]')
|
||||
.attr('checked', true);
|
||||
});
|
||||
};
|
File diff suppressed because one or more lines are too long
|
@ -72,9 +72,8 @@ Drupal.progressBar.prototype.sendPing = function () {
|
|||
type: this.method,
|
||||
url: this.uri,
|
||||
data: '',
|
||||
success: function (data) {
|
||||
// Parse response
|
||||
var progress = Drupal.parseJson(data);
|
||||
dataType: 'json',
|
||||
success: function (progress) {
|
||||
// Display errors
|
||||
if (progress.status == 0) {
|
||||
pb.displayError(progress.data);
|
||||
|
|
|
@ -47,13 +47,13 @@ Drupal.behaviors.tableHeader = function (context) {
|
|||
ref = table;
|
||||
div.wide = true;
|
||||
}
|
||||
$(div).css('width', $(ref).width() - parseInt($(div).css('paddingLeft')) +'px');
|
||||
$(div).width(Math.max(0, $(ref).width() - parseInt($(div).css('paddingLeft'))));
|
||||
|
||||
// Get position and store.
|
||||
div.cell = this;
|
||||
div.table = table;
|
||||
div.stickyMax = height;
|
||||
div.stickyPosition = Drupal.absolutePosition(this).y;
|
||||
div.stickyPosition = $(this).offset().top;
|
||||
});
|
||||
$(this).addClass('tableHeader-processed');
|
||||
});
|
||||
|
@ -91,7 +91,7 @@ Drupal.behaviors.tableHeader = function (context) {
|
|||
|
||||
$(cells).each(function () {
|
||||
// Get position.
|
||||
this.stickyPosition = Drupal.absolutePosition(this.cell).y;
|
||||
this.stickyPosition = $(this.cell).offset().top;
|
||||
this.stickyMax = this.table.savedHeight;
|
||||
|
||||
// Reflow the cell.
|
||||
|
@ -100,7 +100,7 @@ Drupal.behaviors.tableHeader = function (context) {
|
|||
// Resize the first cell to fit the table.
|
||||
ref = this.table;
|
||||
}
|
||||
$(this).css('width', $(ref).width() - parseInt($(this).css('paddingLeft')) +'px');
|
||||
$(this).width(Math.max(0, $(ref).width() - parseInt($(this).css('paddingLeft'))));
|
||||
});
|
||||
|
||||
// Reset timer
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// $Id$
|
||||
|
||||
Drupal.behaviors.tableSelect = function (context) {
|
||||
$('form table[th.select-all]:not(.tableSelect-processed)', context).each(Drupal.tableSelect);
|
||||
$('form table:has(th.select-all):not(.tableSelect-processed)', context).each(Drupal.tableSelect);
|
||||
};
|
||||
|
||||
Drupal.tableSelect = function() {
|
||||
|
|
|
@ -19,14 +19,14 @@ Drupal.behaviors.textarea = function(context) {
|
|||
grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
|
||||
|
||||
function startDrag(e) {
|
||||
staticOffset = textarea.height() - Drupal.mousePosition(e).y;
|
||||
staticOffset = textarea.height() - e.pageY;
|
||||
textarea.css('opacity', 0.25);
|
||||
$(document).mousemove(performDrag).mouseup(endDrag);
|
||||
return false;
|
||||
}
|
||||
|
||||
function performDrag(e) {
|
||||
textarea.height(Math.max(32, staticOffset + Drupal.mousePosition(e).y) + 'px');
|
||||
textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
110
misc/upload.js
110
misc/upload.js
|
@ -1,110 +0,0 @@
|
|||
// $Id$
|
||||
|
||||
/**
|
||||
* Attaches the upload behaviour to the upload form.
|
||||
*/
|
||||
Drupal.behaviors.upload = function(context) {
|
||||
$('input.upload:not(.upload-processed)', context).addClass('upload-processed').each(function () {
|
||||
var uri = this.value;
|
||||
// Extract the base name from the id (edit-attach-url -> attach).
|
||||
var base = this.id.substring(5, this.id.length - 4);
|
||||
var button = base + '-button';
|
||||
var wrapper = base + '-wrapper';
|
||||
var hide = base + '-hide';
|
||||
var upload = new Drupal.jsUpload(uri, button, wrapper, hide);
|
||||
$(this).addClass('upload-processed');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* JS upload object.
|
||||
*/
|
||||
Drupal.jsUpload = function(uri, button, wrapper, hide) {
|
||||
// Note: these elements are replaced after an upload, so we re-select them
|
||||
// everytime they are needed.
|
||||
this.button = '#'+ button;
|
||||
this.wrapper = '#'+ wrapper;
|
||||
this.hide = '#'+ hide;
|
||||
Drupal.redirectFormButton(uri, $(this.button).get(0), this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for the form redirection submission.
|
||||
*/
|
||||
Drupal.jsUpload.prototype.onsubmit = function () {
|
||||
// Insert progressbar and stretch to take the same space.
|
||||
this.progress = new Drupal.progressBar('uploadprogress');
|
||||
this.progress.setProgress(-1, Drupal.t('Uploading file'));
|
||||
|
||||
var hide = this.hide;
|
||||
var el = this.progress.element;
|
||||
var offset = $(hide).get(0).offsetHeight;
|
||||
$(el).css({
|
||||
width: '28em',
|
||||
height: offset +'px',
|
||||
paddingTop: '10px',
|
||||
display: 'none'
|
||||
});
|
||||
$(hide).css('position', 'absolute');
|
||||
|
||||
$(hide).after(el);
|
||||
$(el).fadeIn('slow');
|
||||
$(hide).fadeOut('slow');
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for the form redirection completion.
|
||||
*/
|
||||
Drupal.jsUpload.prototype.oncomplete = function (data) {
|
||||
// Remove old form
|
||||
Drupal.freezeHeight(); // Avoid unnecessary scrolling
|
||||
$(this.wrapper).html('');
|
||||
|
||||
// Place HTML into temporary div
|
||||
var div = document.createElement('div');
|
||||
$(div).html(data);
|
||||
|
||||
// If uploading the first attachment fade in everything
|
||||
if ($('tr', div).size() == 2) {
|
||||
// Replace form and re-attach behaviours
|
||||
$(div).hide();
|
||||
$(this.wrapper).append(div);
|
||||
$(div).fadeIn('slow');
|
||||
}
|
||||
// Else fade in only the last table row
|
||||
else {
|
||||
// Hide form and last table row
|
||||
$('table tr:last-of-type td', div).hide();
|
||||
|
||||
// Note: workaround because jQuery's #id selector does not work outside of 'document'
|
||||
// Should be: $(this.hide, div).hide();
|
||||
var hide = this.hide;
|
||||
$('div', div).each(function() {
|
||||
if (('#'+ this.id) == hide) {
|
||||
this.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Replace form, fade in items and re-attach behaviour
|
||||
$(this.wrapper).append(div);
|
||||
$('table tr:last-of-type td', div).fadeIn('slow');
|
||||
$(this.hide, div).fadeIn('slow');
|
||||
}
|
||||
Drupal.attachBehaviors(div);
|
||||
Drupal.unfreezeHeight();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for the form redirection error.
|
||||
*/
|
||||
Drupal.jsUpload.prototype.onerror = function (error) {
|
||||
alert(Drupal.t('An error occurred:\n\n@error', { '@error': error }));
|
||||
// Remove progressbar
|
||||
$(this.progress.element).remove();
|
||||
this.progress = null;
|
||||
// Undo hide
|
||||
$(this.hide).css({
|
||||
position: 'static',
|
||||
left: '0px'
|
||||
});
|
||||
};
|
|
@ -24,9 +24,12 @@ Drupal.bookFillSelect = function() {
|
|||
pb.setProgress(-1, Drupal.t('Updating parents...'));
|
||||
$('#edit-book-plid-wrapper').html(pb.element);
|
||||
|
||||
$.get(Drupal.settings.book.formCallback +'/'+ $('#'+ Drupal.settings.book.formId +' input[@name=form_build_id]').val() +'/'+ $('#edit-book-bid').val(), {}, function(data) {
|
||||
parsedData = Drupal.parseJson(data);
|
||||
// Insert the new select, and remove the progress bar.
|
||||
$('#edit-book-plid-wrapper').after(parsedData['book']).remove();
|
||||
$.ajax({
|
||||
url: Drupal.settings.book.formCallback +'/'+ $('#'+ Drupal.settings.book.formId +' input[name=form_build_id]').val() +'/'+ $('#edit-book-bid').val(),
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
// Insert the new select, and remove the progress bar.
|
||||
$('#edit-book-plid-wrapper').after(data['book']).remove();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -188,7 +188,7 @@ Drupal.behaviors.color = function (context) {
|
|||
|
||||
// Add new bindings
|
||||
focused = this;
|
||||
farb.linkTo(function (color) { callback(input, color, true, false) });
|
||||
farb.linkTo(function (color) { callback(input, color, true, false); });
|
||||
farb.setColor(this.value);
|
||||
$(focused).keyup(farb.updateValue).keyup(preview).keyup(resetScheme)
|
||||
.parent().addClass('item-selected');
|
||||
|
|
|
@ -6,7 +6,7 @@ Drupal.behaviors.comment = function (context) {
|
|||
for (i=0;i<3;i++) {
|
||||
cookie = Drupal.comment.getCookie('comment_info_' + parts[i]);
|
||||
if (cookie != '') {
|
||||
$("#comment-form input[@name=" + parts[i] + "]:not(.comment-processed)", context)
|
||||
$("#comment-form input[name=" + parts[i] + "]:not(.comment-processed)", context)
|
||||
.val(cookie)
|
||||
.addClass('comment-processed');
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ function node_filter_form() {
|
|||
$form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
|
||||
}
|
||||
|
||||
drupal_add_js(drupal_get_path('module', 'node') .'/node.js');
|
||||
drupal_add_js('misc/form.js', 'core');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
// $Id$
|
||||
|
||||
if (Drupal.jsEnabled) {
|
||||
$(function() {
|
||||
// Automatically selects the right radio button in the filter section of
|
||||
// the admin content list.
|
||||
$('#node-admin-filter select').change(function() {
|
||||
$('#node-admin-filter input:radio[@value="'+ this.id.substr(5) +'"]')
|
||||
.attr('checked', true);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -41,7 +41,7 @@ Drupal.behaviors.cleanURLsSettingsCheck = function(context) {
|
|||
*/
|
||||
Drupal.cleanURLsInstallCheck = function() {
|
||||
var pathname = location.pathname +"";
|
||||
var url = pathname.replace(/\/[^/]*$/, "/") +"node";
|
||||
var url = pathname.replace(/\/[^\/]*$/, "/") +"node";
|
||||
$("#clean-url .description").append('<span><div id="testing">'+ Drupal.settings.cleanURL.testing +"</div></span>");
|
||||
$("#clean-url.install").css("display", "block");
|
||||
$.ajax({url: location.protocol +"//"+ location.host + url, type: "GET", data: " ", complete: function(response) {
|
||||
|
|
|
@ -585,7 +585,7 @@ function upload_js() {
|
|||
$output = theme('status_messages') . drupal_render($form);
|
||||
|
||||
// We send the updated file attachments form.
|
||||
// Don't call drupal_json(). upload.js uses an iframe and
|
||||
// Don't call drupal_json(). ahah.js uses an iframe and
|
||||
// the header output by drupal_json() causes problems in some browsers.
|
||||
print drupal_to_js(array('status' => TRUE, 'data' => $output));
|
||||
exit;
|
||||
|
|
|
@ -83,6 +83,8 @@ function user_filter_form() {
|
|||
);
|
||||
}
|
||||
|
||||
drupal_add_js('misc/form.js', 'core');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ Drupal.setDefaultTimezone = function() {
|
|||
* "Picture support" radio buttons.
|
||||
*/
|
||||
Drupal.behaviors.userSettings = function (context) {
|
||||
$('div.user-admin-picture-radios input[@type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function () {
|
||||
$('div.user-admin-picture-radios input[type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function () {
|
||||
$('div.user-admin-picture-settings', context)[['hide', 'show'][this.value]]();
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue