diff --git a/core/includes/common.inc b/core/includes/common.inc index 17e1363..0260cfe 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3827,7 +3827,7 @@ function drupal_add_js($data = NULL, $options = NULL) { 'browsers' => array(), ), 'core/misc/drupal.js' => array( - 'data' => 'core/misc/drupal.js', + 'data' => 'core/modules/system/assets/drupal.js', 'type' => 'file', 'scope' => 'header', 'group' => JS_LIBRARY, diff --git a/core/misc/ajax.js b/core/misc/ajax.js deleted file mode 100644 index 64af212..0000000 --- a/core/misc/ajax.js +++ /dev/null @@ -1,635 +0,0 @@ -(function ($) { - -"use strict"; - -/** - * Provides Ajax page updating via jQuery $.ajax (Asynchronous JavaScript and XML). - * - * Ajax is a method of making a request via JavaScript while viewing an HTML - * page. The request returns an array of commands encoded in JSON, which is - * then executed to make any changes that are necessary to the page. - * - * Drupal uses this file to enhance form elements with #ajax['path'] and - * #ajax['wrapper'] properties. If set, this file will automatically be included - * to provide Ajax capabilities. - */ - -Drupal.ajax = Drupal.ajax || {}; - -/** - * Attaches the Ajax behavior to each Ajax form element. - */ -Drupal.behaviors.AJAX = { - attach: function (context, settings) { - // Load all Ajax behaviors specified in the settings. - for (var base in settings.ajax) { - var element_settings = settings.ajax[base]; - if (typeof element_settings.selector === 'undefined') { - element_settings.selector = '#' + base; - } - $(element_settings.selector).once('drupal-ajax', function() { - element_settings.element = this; - Drupal.ajax[element_settings.selector] = new Drupal.ajax(base, this, element_settings); - }); - } - - // Bind Ajax behaviors to all items showing the class. - $('.use-ajax').once('ajax', function () { - var element_settings = {}; - // Clicked links look better with the throbber than the progress bar. - element_settings.progress = { 'type': 'throbber' }; - - // For anchor tags, these will go to the target of the anchor rather - // than the usual location. - if ($(this).attr('href')) { - element_settings.url = $(this).attr('href'); - element_settings.event = 'click'; - } - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - }); - - // This class means to submit the form to the action using Ajax. - $('.use-ajax-submit').once('ajax', function () { - var element_settings = {}; - - // Ajax submits specified in this manner automatically submit to the - // normal form action. - element_settings.url = $(this.form).attr('action'); - // Form submit button clicks need to tell the form what was clicked so - // it gets passed in the POST request. - element_settings.setClick = true; - // Form buttons use the 'click' event rather than mousedown. - element_settings.event = 'click'; - // Clicked form buttons look better with the throbber than the progress bar. - element_settings.progress = { 'type': 'throbber' }; - - var base = $(this).attr('id'); - Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); - }); - } -}; - -/** - * Ajax object. - * - * All Ajax objects on a page are accessible through the global Drupal.ajax - * object and are keyed by the submit button's ID. You can access them from - * your module's JavaScript file to override properties or functions. - * - * For example, if your Ajax enabled button has the ID 'edit-submit', you can - * redefine the function that is called to insert the new content like this - * (inside a Drupal.behaviors attach block): - * @code - * Drupal.behaviors.myCustomAJAXStuff = { - * attach: function (context, settings) { - * Drupal.ajax['edit-submit'].commands.insert = function (ajax, response, status) { - * new_content = $(response.data); - * $('#my-wrapper').append(new_content); - * alert('New content was appended to #my-wrapper'); - * } - * } - * }; - * @endcode - */ -Drupal.ajax = function (base, element, element_settings) { - var defaults = { - url: 'system/ajax', - event: 'mousedown', - keypress: true, - selector: '#' + base, - effect: 'none', - speed: 'none', - method: 'replaceWith', - progress: { - type: 'throbber', - message: Drupal.t('Please wait...') - }, - submit: { - 'js': true - } - }; - - $.extend(this, defaults, element_settings); - - this.element = element; - this.element_settings = element_settings; - - // Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let - // the server detect when it needs to degrade gracefully. - // There are four scenarios to check for: - // 1. /nojs/ - // 2. /nojs$ - The end of a URL string. - // 3. /nojs? - Followed by a query (e.g. path/nojs?destination=foobar). - // 4. /nojs# - Followed by a fragment (e.g.: path/nojs#myfragment). - this.url = element_settings.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1'); - this.wrapper = '#' + element_settings.wrapper; - - // If there isn't a form, jQuery.ajax() will be used instead, allowing us to - // bind Ajax to links as well. - if (this.element.form) { - this.form = $(this.element.form); - } - - // Set the options for the ajaxSubmit function. - // The 'this' variable will not persist inside of the options object. - var ajax = this; - ajax.options = { - url: ajax.url, - data: ajax.submit, - beforeSerialize: function (element_settings, options) { - return ajax.beforeSerialize(element_settings, options); - }, - beforeSubmit: function (form_values, element_settings, options) { - ajax.ajaxing = true; - return ajax.beforeSubmit(form_values, element_settings, options); - }, - beforeSend: function (xmlhttprequest, options) { - ajax.ajaxing = true; - return ajax.beforeSend(xmlhttprequest, options); - }, - success: function (response, status) { - // Sanity check for browser support (object expected). - // When using iFrame uploads, responses must be returned as a string. - if (typeof response === 'string') { - response = $.parseJSON(response); - } - return ajax.success(response, status); - }, - complete: function (response, status) { - ajax.ajaxing = false; - if (status === 'error' || status === 'parsererror') { - return ajax.error(response, ajax.url); - } - }, - dataType: 'json', - type: 'POST' - }; - - // Bind the ajaxSubmit function to the element event. - $(ajax.element).bind(element_settings.event, function (event) { - return ajax.eventResponse(this, event); - }); - - // If necessary, enable keyboard submission so that Ajax behaviors - // can be triggered through keyboard input as well as e.g. a mousedown - // action. - if (element_settings.keypress) { - $(ajax.element).keypress(function (event) { - return ajax.keypressResponse(this, event); - }); - } - - // If necessary, prevent the browser default action of an additional event. - // For example, prevent the browser default action of a click, even if the - // AJAX behavior binds to mousedown. - if (element_settings.prevent) { - $(ajax.element).bind(element_settings.prevent, false); - } -}; - -/** - * Handle a key press. - * - * The Ajax object will, if instructed, bind to a key press response. This - * will test to see if the key press is valid to trigger this event and - * if it is, trigger it for us and prevent other keypresses from triggering. - * In this case we're handling RETURN and SPACEBAR keypresses (event codes 13 - * and 32. RETURN is often used to submit a form when in a textfield, and - * SPACE is often used to activate an element without submitting. - */ -Drupal.ajax.prototype.keypressResponse = function (element, event) { - // Create a synonym for this to reduce code confusion. - var ajax = this; - - // Detect enter key and space bar and allow the standard response for them, - // except for form elements of type 'text' and 'textarea', where the - // spacebar activation causes inappropriate activation if #ajax['keypress'] is - // TRUE. On a text-type widget a space should always be a space. - if (event.which === 13 || (event.which === 32 && element.type !== 'text' && element.type !== 'textarea')) { - $(ajax.element_settings.element).trigger(ajax.element_settings.event); - return false; - } -}; - -/** - * Handle an event that triggers an Ajax response. - * - * When an event that triggers an Ajax response happens, this method will - * perform the actual Ajax call. It is bound to the event using - * bind() in the constructor, and it uses the options specified on the - * ajax object. - */ -Drupal.ajax.prototype.eventResponse = function (element, event) { - // Create a synonym for this to reduce code confusion. - var ajax = this; - - // Do not perform another ajax command if one is already in progress. - if (ajax.ajaxing) { - return false; - } - - try { - if (ajax.form) { - // If setClick is set, we must set this to ensure that the button's - // value is passed. - if (ajax.setClick) { - // Mark the clicked button. 'form.clk' is a special variable for - // ajaxSubmit that tells the system which element got clicked to - // trigger the submit. Without it there would be no 'op' or - // equivalent. - element.form.clk = element; - } - - ajax.form.ajaxSubmit(ajax.options); - } - else { - ajax.beforeSerialize(ajax.element, ajax.options); - $.ajax(ajax.options); - } - } - catch (e) { - // Unset the ajax.ajaxing flag here because it won't be unset during - // the complete response. - ajax.ajaxing = false; - alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); - } - - // For radio/checkbox, allow the default event. On IE, this means letting - // it actually check the box. - if (typeof element.type !== 'undefined' && (element.type === 'checkbox' || element.type === 'radio')) { - return true; - } - else { - return false; - } - -}; - -/** - * Handler for the form serialization. - * - * Runs before the beforeSend() handler (see below), and unlike that one, runs - * before field data is collected. - */ -Drupal.ajax.prototype.beforeSerialize = function (element, options) { - // Allow detaching behaviors to update field values before collecting them. - // This is only needed when field values are added to the POST data, so only - // when there is a form such that this.form.ajaxSubmit() is used instead of - // $.ajax(). When there is no form and $.ajax() is used, beforeSerialize() - // isn't called, but don't rely on that: explicitly check this.form. - if (this.form) { - var settings = this.settings || Drupal.settings; - Drupal.detachBehaviors(this.form, settings, 'serialize'); - } - - // Prevent duplicate HTML ids in the returned markup. - // @see drupal_html_id() - options.data['ajax_html_ids[]'] = []; - $('[id]').each(function () { - options.data['ajax_html_ids[]'].push(this.id); - }); - - // Allow Drupal to return new JavaScript and CSS files to load without - // returning the ones already loaded. - // @see ajax_base_page_theme() - // @see drupal_get_css() - // @see drupal_get_js() - options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme; - options.data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token; - for (var key in Drupal.settings.ajaxPageState.css) { - options.data['ajax_page_state[css][' + key + ']'] = 1; - } - for (var key in Drupal.settings.ajaxPageState.js) { - options.data['ajax_page_state[js][' + key + ']'] = 1; - } -}; - -/** - * Modify form values prior to form submission. - */ -Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { - // This function is left empty to make it simple to override for modules - // that wish to add functionality here. -}; - -/** - * Prepare the Ajax request before it is sent. - */ -Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { - // For forms without file inputs, the jQuery Form plugin serializes the form - // values, and then calls jQuery's $.ajax() function, which invokes this - // handler. In this circumstance, options.extraData is never used. For forms - // with file inputs, the jQuery Form plugin uses the browser's normal form - // submission mechanism, but captures the response in a hidden IFRAME. In this - // circumstance, it calls this handler first, and then appends hidden fields - // to the form to submit the values in options.extraData. There is no simple - // way to know which submission mechanism will be used, so we add to extraData - // regardless, and allow it to be ignored in the former case. - if (this.form) { - options.extraData = options.extraData || {}; - - // Let the server know when the IFRAME submission mechanism is used. The - // server can use this information to wrap the JSON response in a TEXTAREA, - // as per http://jquery.malsup.com/form/#file-upload. - options.extraData.ajax_iframe_upload = '1'; - - // The triggering element is about to be disabled (see below), but if it - // contains a value (e.g., a checkbox, textfield, select, etc.), ensure that - // value is included in the submission. As per above, submissions that use - // $.ajax() are already serialized prior to the element being disabled, so - // this is only needed for IFRAME submissions. - var v = $.fieldValue(this.element); - if (v !== null) { - options.extraData[this.element.name] = v; - } - } - - // Disable the element that received the change to prevent user interface - // interaction while the Ajax request is in progress. ajax.ajaxing prevents - // the element from triggering a new request, but does not prevent the user - // from changing its value. - $(this.element).addClass('progress-disabled').attr('disabled', true); - - // Insert progressbar or throbber. - if (this.progress.type === 'bar') { - var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop); - if (this.progress.message) { - progressBar.setProgress(-1, this.progress.message); - } - if (this.progress.url) { - progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500); - } - this.progress.element = $(progressBar.element).addClass('ajax-progress ajax-progress-bar'); - this.progress.object = progressBar; - $(this.element).after(this.progress.element); - } - else if (this.progress.type === 'throbber') { - this.progress.element = $('
 
'); - if (this.progress.message) { - this.progress.element.find('.throbber').after('
' + this.progress.message + '
'); - } - $(this.element).after(this.progress.element); - } -}; - -/** - * Handler for the form redirection completion. - */ -Drupal.ajax.prototype.success = function (response, status) { - // Remove the progress element. - if (this.progress.element) { - $(this.progress.element).remove(); - } - if (this.progress.object) { - this.progress.object.stopMonitoring(); - } - $(this.element).removeClass('progress-disabled').removeAttr('disabled'); - - Drupal.freezeHeight(); - - for (var i in response) { - if (response[i]['command'] && this.commands[response[i]['command']]) { - this.commands[response[i]['command']](this, response[i], status); - } - } - - // Reattach behaviors, if they were detached in beforeSerialize(). The - // attachBehaviors() called on the new content from processing the response - // commands is not sufficient, because behaviors from the entire form need - // to be reattached. - if (this.form) { - var settings = this.settings || Drupal.settings; - Drupal.attachBehaviors(this.form, settings); - } - - Drupal.unfreezeHeight(); - - // Remove any response-specific settings so they don't get used on the next - // call by mistake. - this.settings = null; -}; - -/** - * Build an effect object which tells us how to apply the effect when adding new HTML. - */ -Drupal.ajax.prototype.getEffect = function (response) { - var type = response.effect || this.effect; - var speed = response.speed || this.speed; - - var effect = {}; - if (type === 'none') { - effect.showEffect = 'show'; - effect.hideEffect = 'hide'; - effect.showSpeed = ''; - } - else if (type === 'fade') { - effect.showEffect = 'fadeIn'; - effect.hideEffect = 'fadeOut'; - effect.showSpeed = speed; - } - else { - effect.showEffect = type + 'Toggle'; - effect.hideEffect = type + 'Toggle'; - effect.showSpeed = speed; - } - - return effect; -}; - -/** - * Handler for the form redirection error. - */ -Drupal.ajax.prototype.error = function (response, uri) { - alert(Drupal.ajaxError(response, uri)); - // Remove the progress element. - if (this.progress.element) { - $(this.progress.element).remove(); - } - if (this.progress.object) { - this.progress.object.stopMonitoring(); - } - // Undo hide. - $(this.wrapper).show(); - // Re-enable the element. - $(this.element).removeClass('progress-disabled').removeAttr('disabled'); - // Reattach behaviors, if they were detached in beforeSerialize(). - if (this.form) { - var settings = response.settings || this.settings || Drupal.settings; - Drupal.attachBehaviors(this.form, settings); - } -}; - -/** - * Provide a series of commands that the server can request the client perform. - */ -Drupal.ajax.prototype.commands = { - /** - * Command to insert new content into the DOM. - */ - insert: function (ajax, response, status) { - // Get information from the response. If it is not there, default to - // our presets. - var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); - var method = response.method || ajax.method; - var effect = ajax.getEffect(response); - - // We don't know what response.data contains: it might be a string of text - // without HTML, so don't rely on jQuery correctly iterpreting - // $(response.data) as new HTML rather than a CSS selector. Also, if - // response.data contains top-level text nodes, they get lost with either - // $(response.data) or $('
').replaceWith(response.data). - var new_content_wrapped = $('
').html(response.data); - var new_content = new_content_wrapped.contents(); - - // For legacy reasons, the effects processing code assumes that new_content - // consists of a single top-level element. Also, it has not been - // sufficiently tested whether attachBehaviors() can be successfully called - // with a context object that includes top-level text nodes. However, to - // give developers full control of the HTML appearing in the page, and to - // enable Ajax content to be inserted in places where DIV elements are not - // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new - // content satisfies the requirement of a single top-level element, and - // only use the container DIV created above when it doesn't. For more - // information, please see http://drupal.org/node/736066. - if (new_content.length !== 1 || new_content.get(0).nodeType !== 1) { - new_content = new_content_wrapped; - } - - // If removing content from the wrapper, detach behaviors first. - switch (method) { - case 'html': - case 'replaceWith': - case 'replaceAll': - case 'empty': - case 'remove': - var settings = response.settings || ajax.settings || Drupal.settings; - Drupal.detachBehaviors(wrapper, settings); - } - - // Add the new content to the page. - wrapper[method](new_content); - - // Immediately hide the new content if we're using any effects. - if (effect.showEffect !== 'show') { - new_content.hide(); - } - - // Determine which effect to use and what content will receive the - // effect, then show the new content. - if (new_content.find('.ajax-new-content').length > 0) { - new_content.find('.ajax-new-content').hide(); - new_content.show(); - new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed); - } - else if (effect.showEffect !== 'show') { - new_content[effect.showEffect](effect.showSpeed); - } - - // Attach all JavaScript behaviors to the new content, if it was successfully - // added to the page, this if statement allows #ajax['wrapper'] to be - // optional. - if (new_content.parents('html').length > 0) { - // Apply any settings from the returned JSON if available. - var settings = response.settings || ajax.settings || Drupal.settings; - Drupal.attachBehaviors(new_content, settings); - } - }, - - /** - * Command to remove a chunk from the page. - */ - remove: function (ajax, response, status) { - var settings = response.settings || ajax.settings || Drupal.settings; - Drupal.detachBehaviors($(response.selector), settings); - $(response.selector).remove(); - }, - - /** - * Command to mark a chunk changed. - */ - changed: function (ajax, response, status) { - if (!$(response.selector).hasClass('ajax-changed')) { - $(response.selector).addClass('ajax-changed'); - if (response.asterisk) { - $(response.selector).find(response.asterisk).append(' * '); - } - } - }, - - /** - * Command to provide an alert. - */ - alert: function (ajax, response, status) { - alert(response.text, response.title); - }, - - /** - * Command to provide the jQuery css() function. - */ - css: function (ajax, response, status) { - $(response.selector).css(response.argument); - }, - - /** - * Command to set the settings that will be used for other commands in this response. - */ - settings: function (ajax, response, status) { - if (response.merge) { - $.extend(true, Drupal.settings, response.settings); - } - else { - ajax.settings = response.settings; - } - }, - - /** - * Command to attach data using jQuery's data API. - */ - data: function (ajax, response, status) { - $(response.selector).data(response.name, response.value); - }, - - /** - * Command to apply a jQuery method. - */ - invoke: function (ajax, response, status) { - var $element = $(response.selector); - $element[response.method].apply($element, response.arguments); - }, - - /** - * Command to restripe a table. - */ - restripe: function (ajax, response, status) { - // :even and :odd are reversed because jQuery counts from 0 and - // we count from 1, so we're out of sync. - // Match immediate children of the parent element to allow nesting. - $(response.selector).find('> tbody > tr:visible, > tr:visible') - .removeClass('odd even') - .filter(':even').addClass('odd').end() - .filter(':odd').addClass('even'); - }, - - /** - * Command to add css. - * - * Uses the proprietary addImport method if available as browsers which - * support that method ignore @import statements in dynamically added - * stylesheets. - */ - add_css: function (ajax, response, status) { - // Add the styles in the normal way. - $('head').prepend(response.data); - // Add imports in the styles using the addImport method if available. - var match, importMatch = /^@import url\("(.*)"\);$/igm; - if (document.styleSheets[0].addImport && importMatch.test(response.data)) { - importMatch.lastIndex = 0; - while (match = importMatch.exec(response.data)) { - document.styleSheets[0].addImport(match[1]); - } - } - } -}; - -})(jQuery); diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js deleted file mode 100644 index 0ffe404..0000000 --- a/core/misc/autocomplete.js +++ /dev/null @@ -1,334 +0,0 @@ -(function ($) { - -"use strict"; - -/** - * Attaches the autocomplete behavior to all required fields. - */ -Drupal.behaviors.autocomplete = { - attach: function (context, settings) { - var acdb = []; - $(context).find('input.autocomplete').once('autocomplete', function () { - var uri = this.value; - if (!acdb[uri]) { - acdb[uri] = new Drupal.ACDB(uri); - } - var $input = $('#' + this.id.substr(0, this.id.length - 13)) - .attr('autocomplete', 'OFF') - .attr('aria-autocomplete', 'list'); - $($input[0].form).submit(Drupal.autocompleteSubmit); - $input.parent() - .attr('role', 'application') - .append($('') - .attr('id', $input[0].id + '-autocomplete-aria-live') - ); - new Drupal.jsAC($input, acdb[uri]); - }); - } -}; - -/** - * Prevents the form from submitting if the suggestions popup is open - * and closes the suggestions popup when doing so. - */ -Drupal.autocompleteSubmit = function () { - var $autocomplete = $('#autocomplete'); - if ($autocomplete.length !== 0) { - $autocomplete[0].owner.hidePopup(); - } - return $autocomplete.length === 0; -}; - -/** - * An AutoComplete object. - */ -Drupal.jsAC = function ($input, db) { - var ac = this; - this.input = $input[0]; - this.ariaLive = $('#' + this.input.id + '-autocomplete-aria-live'); - this.db = db; - - $input - .keydown(function (event) { return ac.onkeydown(this, event); }) - .keyup(function (event) { ac.onkeyup(this, event); }) - .blur(function () { ac.hidePopup(); ac.db.cancel(); }); -}; - -/** - * Handler for the "keydown" event. - */ -Drupal.jsAC.prototype.onkeydown = function (input, e) { - if (!e) { - e = window.event; - } - switch (e.keyCode) { - case 40: // down arrow. - this.selectDown(); - return false; - case 38: // up arrow. - this.selectUp(); - return false; - default: // All other keys. - return true; - } -}; - -/** - * Handler for the "keyup" event. - */ -Drupal.jsAC.prototype.onkeyup = function (input, e) { - if (!e) { - e = window.event; - } - switch (e.keyCode) { - case 16: // Shift. - case 17: // Ctrl. - case 18: // Alt. - case 20: // Caps lock. - case 33: // Page up. - case 34: // Page down. - case 35: // End. - case 36: // Home. - case 37: // Left arrow. - case 38: // Up arrow. - case 39: // Right arrow. - case 40: // Down arrow. - return true; - - case 9: // Tab. - case 13: // Enter. - case 27: // Esc. - this.hidePopup(e.keyCode); - return true; - - default: // All other keys. - if (input.value.length > 0 && !input.readOnly) { - this.populatePopup(); - } - else { - this.hidePopup(e.keyCode); - } - return true; - } -}; - -/** - * Puts the currently highlighted suggestion into the autocomplete field. - */ -Drupal.jsAC.prototype.select = function (node) { - this.input.value = $(node).data('autocompleteValue'); -}; - -/** - * Highlights the next suggestion. - */ -Drupal.jsAC.prototype.selectDown = function () { - if (this.selected && this.selected.nextSibling) { - this.highlight(this.selected.nextSibling); - } - else if (this.popup) { - var lis = $(this.popup).find('li'); - if (lis.length > 0) { - this.highlight(lis.get(0)); - } - } -}; - -/** - * Highlights the previous suggestion. - */ -Drupal.jsAC.prototype.selectUp = function () { - if (this.selected && this.selected.previousSibling) { - this.highlight(this.selected.previousSibling); - } -}; - -/** - * Highlights a suggestion. - */ -Drupal.jsAC.prototype.highlight = function (node) { - // Unhighlights a suggestion for "keyup" and "keydown" events. - if (this.selected !== false) { - $(this.selected).removeClass('selected'); - } - $(node).addClass('selected'); - this.selected = node; - $(this.ariaLive).html($(this.selected).html()); -}; - -/** - * Unhighlights a suggestion. - */ -Drupal.jsAC.prototype.unhighlight = function (node) { - $(node).removeClass('selected'); - this.selected = false; - $(this.ariaLive).empty(); -}; - -/** - * Hides the autocomplete suggestions. - */ -Drupal.jsAC.prototype.hidePopup = function (keycode) { - // Select item if the right key or mousebutton was pressed. - if (this.selected && ((keycode && keycode !== 46 && keycode !== 8 && keycode !== 27) || !keycode)) { - this.input.value = $(this.selected).data('autocompleteValue'); - } - // Hide popup. - var popup = this.popup; - if (popup) { - this.popup = null; - $(popup).fadeOut('fast', function () { $(popup).remove(); }); - } - this.selected = false; - $(this.ariaLive).empty(); -}; - -/** - * Positions the suggestions popup and starts a search. - */ -Drupal.jsAC.prototype.populatePopup = function () { - var $input = $(this.input); - var position = $input.position(); - // Show popup. - if (this.popup) { - $(this.popup).remove(); - } - this.selected = false; - this.popup = $('
')[0]; - this.popup.owner = this; - $(this.popup).css({ - top: parseInt(position.top + this.input.offsetHeight, 10) + 'px', - left: parseInt(position.left, 10) + 'px', - width: $input.innerWidth() + 'px', - display: 'none' - }); - $input.before(this.popup); - - // Do search. - this.db.owner = this; - this.db.search(this.input.value); -}; - -/** - * Fills the suggestion popup with any matches received. - */ -Drupal.jsAC.prototype.found = function (matches) { - // If no value in the textfield, do not show the popup. - if (!this.input.value.length) { - return false; - } - - // Prepare matches. - var ul = $(''); - var ac = this; - for (var key in matches) { - if (matches.hasOwnProperty(key)) { - $('
  • ') - .html($('
    ').html(matches[key])) - .mousedown(function () { ac.select(this); }) - .mouseover(function () { ac.highlight(this); }) - .mouseout(function () { ac.unhighlight(this); }) - .data('autocompleteValue', key) - .appendTo(ul); - } - } - - // Show popup with matches, if any. - if (this.popup) { - if (ul.children().length) { - $(this.popup).empty().append(ul).show(); - $(this.ariaLive).html(Drupal.t('Autocomplete popup')); - } - else { - $(this.popup).css({ visibility: 'hidden' }); - this.hidePopup(); - } - } -}; - -Drupal.jsAC.prototype.setStatus = function (status) { - switch (status) { - case 'begin': - $(this.input).addClass('throbbing'); - $(this.ariaLive).html(Drupal.t('Searching for matches...')); - break; - case 'cancel': - case 'error': - case 'found': - $(this.input).removeClass('throbbing'); - break; - } -}; - -/** - * An AutoComplete DataBase object. - */ -Drupal.ACDB = function (uri) { - this.uri = uri; - this.delay = 300; - this.cache = {}; -}; - -/** - * Performs a cached and delayed search. - */ -Drupal.ACDB.prototype.search = function (searchString) { - var db = this; - this.searchString = searchString; - - // See if this string needs to be searched for anyway. - searchString = searchString.replace(/^\s+|\s+$/, ''); - if (searchString.length <= 0 || - searchString.charAt(searchString.length - 1) === ',') { - return; - } - - // See if this key has been searched for before. - if (this.cache[searchString]) { - return this.owner.found(this.cache[searchString]); - } - - // Initiate delayed search. - if (this.timer) { - clearTimeout(this.timer); - } - this.timer = setTimeout(function () { - db.owner.setStatus('begin'); - - // Ajax GET request for autocompletion. We use Drupal.encodePath instead of - // encodeURIComponent to allow autocomplete search terms to contain slashes. - $.ajax({ - type: 'GET', - url: db.uri + '/' + Drupal.encodePath(searchString), - 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. - if (db.searchString === searchString) { - db.owner.found(matches); - } - db.owner.setStatus('found'); - } - }, - error: function (xmlhttp) { - alert(Drupal.ajaxError(xmlhttp, db.uri)); - } - }); - }, this.delay); -}; - -/** - * Cancels the current autocomplete request. - */ -Drupal.ACDB.prototype.cancel = function () { - if (this.owner) { - this.owner.setStatus('cancel'); - } - if (this.timer) { - clearTimeout(this.timer); - } - this.searchString = ''; -}; - -})(jQuery); diff --git a/core/misc/batch.js b/core/misc/batch.js deleted file mode 100644 index 246e9ef..0000000 --- a/core/misc/batch.js +++ /dev/null @@ -1,37 +0,0 @@ -(function ($) { - -"use strict"; - -/** - * Attaches the batch behavior to progress bars. - */ -Drupal.behaviors.batch = { - attach: function (context, settings) { - $(context).find('#progress').once('batch', function () { - var holder = $(this); - // Remove HTML from no-js progress bar. The JS progress bar is created - // later on. - holder.empty(); - - // Success: redirect to the summary. - var updateCallback = function (progress, status, pb) { - if (progress === '100') { - pb.stopMonitoring(); - window.location = settings.batch.uri + '&op=finished'; - } - }; - - var errorCallback = function (pb) { - holder.prepend($('

    ').html(settings.batch.errorMessage)); - $('#wait').hide(); - }; - - var progress = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback); - progress.setProgress(-1, settings.batch.initMessage); - holder.append(progress.element); - progress.startMonitoring(settings.batch.uri + '&op=do', 10); - }); - } -}; - -})(jQuery); diff --git a/core/misc/collapse.js b/core/misc/collapse.js deleted file mode 100644 index d834563..0000000 --- a/core/misc/collapse.js +++ /dev/null @@ -1,105 +0,0 @@ -(function ($) { - -"use strict"; - -/** - * Toggle the visibility of a fieldset using smooth animations. - */ -Drupal.toggleFieldset = function (fieldset) { - var $fieldset = $(fieldset); - if ($fieldset.is('.collapsed')) { - var $content = $fieldset.find('> .fieldset-wrapper').hide(); - $fieldset - .removeClass('collapsed') - .trigger({ type: 'collapsed', value: false }) - .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Hide')); - $content.slideDown({ - duration: 'fast', - easing: 'linear', - complete: function () { - Drupal.collapseScrollIntoView(fieldset); - fieldset.animating = false; - }, - step: function () { - // Scroll the fieldset into view. - Drupal.collapseScrollIntoView(fieldset); - } - }); - } - else { - $fieldset.trigger({ type: 'collapsed', value: true }); - $fieldset.find('> .fieldset-wrapper').slideUp('fast', function () { - $fieldset - .addClass('collapsed') - .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show')); - fieldset.animating = false; - }); - } -}; - -/** - * Scroll a given fieldset into view as much as possible. - */ -Drupal.collapseScrollIntoView = function (node) { - var h = document.documentElement.clientHeight || document.body.clientHeight || 0; - var offset = document.documentElement.scrollTop || document.body.scrollTop || 0; - var posY = $(node).offset().top; - var fudge = 55; - if (posY + node.offsetHeight + fudge > h + offset) { - if (node.offsetHeight > h) { - window.scrollTo(0, posY); - } - else { - window.scrollTo(0, posY + node.offsetHeight - h + fudge); - } - } -}; - -Drupal.behaviors.collapse = { - attach: function (context, settings) { - $(context).find('fieldset.collapsible').once('collapse', function () { - var $fieldset = $(this); - // Expand fieldset if there are errors inside, or if it contains an - // element that is targeted by the uri fragment identifier. - var anchor = location.hash && location.hash !== '#' ? ', ' + location.hash : ''; - if ($fieldset.find('.error' + anchor).length) { - $fieldset.removeClass('collapsed'); - } - - var summary = $(''); - $fieldset. - bind('summaryUpdated', function () { - var text = $.trim($fieldset.drupalGetSummary()); - summary.html(text ? ' (' + text + ')' : ''); - }) - .trigger('summaryUpdated'); - - // Turn the legend into a clickable link, but retain span.fieldset-legend - // for CSS positioning. - var $legend = $fieldset.find('> legend .fieldset-legend'); - - $('') - .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide')) - .prependTo($legend) - .after(' '); - - // .wrapInner() does not retain bound events. - var $link = $('') - .prepend($legend.contents()) - .appendTo($legend) - .click(function () { - var fieldset = $fieldset.get(0); - // Don't animate multiple times. - if (!fieldset.animating) { - fieldset.animating = true; - Drupal.toggleFieldset(fieldset); - } - return false; - }); - - $legend.append(summary); - }); - } -}; - -})(jQuery); diff --git a/core/misc/drupal.js b/core/misc/drupal.js deleted file mode 100644 index 36612ec..0000000 --- a/core/misc/drupal.js +++ /dev/null @@ -1,416 +0,0 @@ -var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} }; - -// Allow other JavaScript libraries to use $. -jQuery.noConflict(); - -// JavaScript should be made compatible with libraries other than jQuery by -// wrapping it in an anonymous closure. -(function ($, Drupal, window, document, undefined) { - -"use strict"; - -/** - * Attach all registered behaviors to a page element. - * - * Behaviors are event-triggered actions that attach to page elements, enhancing - * default non-JavaScript UIs. Behaviors are registered in the Drupal.behaviors - * object using the method 'attach' and optionally also 'detach' as follows: - * @code - * Drupal.behaviors.behaviorName = { - * attach: function (context, settings) { - * ... - * }, - * detach: function (context, settings, trigger) { - * ... - * } - * }; - * @endcode - * - * Drupal.attachBehaviors is added below to the jQuery.ready event and therefore - * runs on initial page load. Developers implementing Ajax in their solutions - * should also call this function after new page content has been loaded, - * feeding in an element to be processed, in order to attach all behaviors to - * the new content. - * - * Behaviors should use - * @code - * var elements = $(context).find(selector).once('behavior-name'); - * @endcode - * to ensure the behavior is attached only once to a given element. (Doing so - * enables the reprocessing of given elements, which may be needed on occasion - * despite the ability to limit behavior attachment to a particular element.) - * - * @param context - * An element to attach behaviors to. If none is given, the document element - * is used. - * @param settings - * An object containing settings for the current context. If none is given, - * the global Drupal.settings object is used. - */ -Drupal.attachBehaviors = function (context, settings) { - context = context || document; - settings = settings || Drupal.settings; - var i, behaviors = Drupal.behaviors; - // Execute all of them. - for (i in behaviors) { - if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') { - behaviors[i].attach(context, settings); - } - } -}; - -/** - * Detach registered behaviors from a page element. - * - * Developers implementing AHAH/Ajax in their solutions should call this - * function before page content is about to be removed, feeding in an element - * to be processed, in order to allow special behaviors to detach from the - * content. - * - * Such implementations should look for the class name that was added in their - * corresponding Drupal.behaviors.behaviorName.attach implementation, i.e. - * behaviorName-processed, to ensure the behavior is detached only from - * previously processed elements. - * - * @param context - * An element to detach behaviors from. If none is given, the document element - * is used. - * @param settings - * An object containing settings for the current context. If none given, the - * global Drupal.settings object is used. - * @param trigger - * A string containing what's causing the behaviors to be detached. The - * possible triggers are: - * - unload: (default) The context element is being removed from the DOM. - * - move: The element is about to be moved within the DOM (for example, - * during a tabledrag row swap). After the move is completed, - * Drupal.attachBehaviors() is called, so that the behavior can undo - * whatever it did in response to the move. Many behaviors won't need to - * do anything simply in response to the element being moved, but because - * IFRAME elements reload their "src" when being moved within the DOM, - * behaviors bound to IFRAME elements (like WYSIWYG editors) may need to - * take some action. - * - serialize: When an Ajax form is submitted, this is called with the - * form as the context. This provides every behavior within the form an - * opportunity to ensure that the field elements have correct content - * in them before the form is serialized. The canonical use-case is so - * that WYSIWYG editors can update the hidden textarea to which they are - * bound. - * - * @see Drupal.attachBehaviors - */ -Drupal.detachBehaviors = function (context, settings, trigger) { - context = context || document; - settings = settings || Drupal.settings; - trigger = trigger || 'unload'; - var i, behaviors = Drupal.behaviors; - // Execute all of them. - for (i in behaviors) { - if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function' ) { - behaviors[i].detach(context, settings, trigger); - } - } -}; - -/** - * Helper to test document width for mobile configurations. - * @todo Temporary solution for the mobile initiative. - */ -Drupal.checkWidthBreakpoint = function (width) { - width = width || Drupal.settings.widthBreakpoint || 640; - return (document.documentElement.clientWidth > width); -}; - -/** - * Encode special characters in a plain-text string for display as HTML. - * - * @param str - * The string to be encoded. - * @return - * The encoded string. - * @ingroup sanitization - */ -Drupal.checkPlain = function (str) { - str = str.toString() - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(//g, '>'); - return str; -}; - -/** - * Replace placeholders with sanitized values in a string. - * - * @param str - * A string with placeholders. - * @param args - * An object of replacements pairs to make. Incidences of any key in this - * array are replaced with the corresponding value. Based on the first - * character of the key, the value is escaped and/or themed: - * - !variable: inserted as is - * - @variable: escape plain text to HTML (Drupal.checkPlain) - * - %variable: escape text and theme as a placeholder for user-submitted - * content (checkPlain + Drupal.theme('placeholder')) - * - * @see Drupal.t() - * @ingroup sanitization - */ -Drupal.formatString = function(str, args) { - // Transform arguments before inserting them. - for (var key in args) { - if (args.hasOwnProperty(key)) { - switch (key.charAt(0)) { - // Escaped only. - case '@': - args[key] = Drupal.checkPlain(args[key]); - break; - // Pass-through. - case '!': - break; - // Escaped and placeholder. - default: - args[key] = Drupal.theme('placeholder', args[key]); - break; - } - str = str.replace(key, args[key]); - } - } - return str; -}; - -/** - * Translate strings to the page language or a given language. - * - * See the documentation of the server-side t() function for further details. - * - * @param str - * A string containing the English string to translate. - * @param args - * An object of replacements pairs to make after translation. Incidences - * of any key in this array are replaced with the corresponding value. - * See Drupal.formatString(). - * - * @param options - * - 'context' (defaults to the empty context): The context the source string - * belongs to. - * - * @return - * The translated string. - */ -Drupal.t = function (str, args, options) { - options = options || {}; - options.context = options.context || ''; - - // Fetch the localized version of the string. - if (Drupal.locale.strings && Drupal.locale.strings[options.context] && Drupal.locale.strings[options.context][str]) { - str = Drupal.locale.strings[options.context][str]; - } - - if (args) { - str = Drupal.formatString(str, args); - } - return str; -}; - -/** - * Returns the URL to a Drupal page. - */ -Drupal.url = function (path) { - return Drupal.settings.basePath + Drupal.settings.scriptPath + path; -}; - -/** - * Format a string containing a count of items. - * - * This function ensures that the string is pluralized correctly. Since Drupal.t() is - * called by this function, make sure not to pass already-localized strings to it. - * - * See the documentation of the server-side format_plural() function for further details. - * - * @param count - * The item count to display. - * @param singular - * The string for the singular case. Please make sure it is clear this is - * singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). - * Do not use @count in the singular string. - * @param plural - * The string for the plural case. Please make sure it is clear this is plural, - * to ease translation. Use @count in place of the item count, as in "@count - * new comments". - * @param args - * An object of replacements pairs to make after translation. Incidences - * of any key in this array are replaced with the corresponding value. - * See Drupal.formatString(). - * Note that you do not need to include @count in this array. - * This replacement is done automatically for the plural case. - * @param options - * The options to pass to the Drupal.t() function. - * @return - * A translated string. - */ -Drupal.formatPlural = function (count, singular, plural, args, options) { - args = args || {}; - args['@count'] = count; - // Determine the index of the plural form. - var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] === 1) ? 0 : 1); - - if (index === 0) { - return Drupal.t(singular, args, options); - } - else if (index === 1) { - return Drupal.t(plural, args, options); - } - else { - args['@count[' + index + ']'] = args['@count']; - delete args['@count']; - return Drupal.t(plural.replace('@count', '@count[' + index + ']'), args, options); - } -}; - -/** - * Generate the themed representation of a Drupal object. - * - * All requests for themed output must go through this function. It examines - * the request and routes it to the appropriate theme function. If the current - * theme does not provide an override function, the generic theme function is - * called. - * - * For example, to retrieve the HTML for text that should be emphasized and - * displayed as a placeholder inside a sentence, call - * Drupal.theme('placeholder', text). - * - * @param func - * The name of the theme function to call. - * @param ... - * Additional arguments to pass along to the theme function. - * @return - * Any data the theme function returns. This could be a plain HTML string, - * but also a complex object. - */ -Drupal.theme = function (func) { - var args = Array.prototype.slice.apply(arguments, [1]); - if (func in Drupal.theme) { - return Drupal.theme[func].apply(this, args); - } -}; - -/** - * Freeze the current body height (as minimum height). Used to prevent - * unnecessary upwards scrolling when doing DOM manipulations. - */ -Drupal.freezeHeight = function () { - Drupal.unfreezeHeight(); - $('
    ').css({ - position: 'absolute', - top: '0px', - left: '0px', - width: '1px', - height: $('body').css('height') - }).appendTo('body'); -}; - -/** - * Unfreeze the body height. - */ -Drupal.unfreezeHeight = function () { - $('#freeze-height').remove(); -}; - -/** - * Encodes a Drupal path for use in a URL. - * - * For aesthetic reasons slashes are not escaped. - */ -Drupal.encodePath = function (item) { - return window.encodeURIComponent(item).replace(/%2F/g, '/'); -}; - -/** - * Get the text selection in a textarea. - */ -Drupal.getSelection = function (element) { - var range1, range2, start, end; - if (typeof element.selectionStart !== 'number' && document.selection) { - // The current selection. - range1 = document.selection.createRange(); - range2 = range1.duplicate(); - // Select all text. - range2.moveToElementText(element); - // Now move 'dummy' end point to end point of original range. - range2.setEndPoint('EndToEnd', range1); - // Now we can calculate start and end points. - start = range2.text.length - range1.text.length; - end = start + range1.text.length; - return { 'start': start, 'end': end }; - } - return { 'start': element.selectionStart, 'end': element.selectionEnd }; -}; - -/** - * Build an error message from an Ajax response. - */ -Drupal.ajaxError = function (xmlhttp, uri) { - var statusCode, statusText, pathText, responseText, readyStateText, message; - if (xmlhttp.status) { - statusCode = "\n" + Drupal.t("An AJAX HTTP error occurred.") + "\n" + Drupal.t("HTTP Result Code: !status", {'!status': xmlhttp.status}); - } - else { - statusCode = "\n" + Drupal.t("An AJAX HTTP request terminated abnormally."); - } - statusCode += "\n" + Drupal.t("Debugging information follows."); - pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} ); - statusText = ''; - // In some cases, when statusCode === 0, xmlhttp.statusText may not be defined. - // Unfortunately, testing for it with typeof, etc, doesn't seem to catch that - // and the test causes an exception. So we need to catch the exception here. - try { - statusText = "\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)}); - } - catch (e) {} - - responseText = ''; - // Again, we don't have a way to know for sure whether accessing - // xmlhttp.responseText is going to throw an exception. So we'll catch it. - try { - responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) } ); - } catch (e) {} - - // Make the responseText more readable by stripping HTML tags and newlines. - responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,""); - responseText = responseText.replace(/[\n]+\s+/g,"\n"); - - // We don't need readyState except for status == 0. - readyStateText = xmlhttp.status === 0 ? ("\n" + Drupal.t("ReadyState: !readyState", {'!readyState': xmlhttp.readyState})) : ""; - - message = statusCode + pathText + statusText + responseText + readyStateText; - return message; -}; - -// Class indicating that JS is enabled; used for styling purpose. -$('html').addClass('js'); - -//Attach all behaviors. -$(function () { - Drupal.attachBehaviors(document, Drupal.settings); -}); - -/** - * The default themes. - */ -$.extend(Drupal.theme, { - - /** - * Formats text for emphasized display in a placeholder inside a sentence. - * - * @param str - * The text to format (plain-text). - * @return - * The formatted text (html). - */ - placeholder: function (str) { - return '' + Drupal.checkPlain(str) + ''; - } -}); - -})(jQuery, Drupal, this, this.document); diff --git a/core/misc/form.js b/core/misc/form.js deleted file mode 100644 index d75de97..0000000 --- a/core/misc/form.js +++ /dev/null @@ -1,83 +0,0 @@ -(function ($) { - -"use strict"; - -/** - * Retrieves the summary for the first element. - */ -$.fn.drupalGetSummary = function () { - var callback = this.data('summaryCallback'); - return (this[0] && callback) ? $.trim(callback(this[0])) : ''; -}; - -/** - * Sets the summary for all matched elements. - * - * @param callback - * Either a function that will be called each time the summary is - * retrieved or a string (which is returned each time). - */ -$.fn.drupalSetSummary = function (callback) { - var self = this; - - // To facilitate things, the callback should always be a function. If it's - // not, we wrap it into an anonymous function which just returns the value. - if (typeof callback !== 'function') { - var val = callback; - callback = function () { return val; }; - } - - return this - .data('summaryCallback', callback) - // To prevent duplicate events, the handlers are first removed and then - // (re-)added. - .unbind('formUpdated.summary') - .bind('formUpdated.summary', function () { - self.trigger('summaryUpdated'); - }) - // The actual summaryUpdated handler doesn't fire when the callback is - // changed, so we have to do this manually. - .trigger('summaryUpdated'); -}; - -/** - * Sends a 'formUpdated' event each time a form element is modified. - */ -Drupal.behaviors.formUpdated = { - attach: function (context) { - // These events are namespaced so that we can remove them later. - var events = 'change.formUpdated click.formUpdated blur.formUpdated keyup.formUpdated'; - $(context) - // Since context could be an input element itself, it's added back to - // the jQuery object and filtered again. - .find(':input').andSelf().filter(':input') - // To prevent duplicate events, the handlers are first removed and then - // (re-)added. - .unbind(events).bind(events, function () { - $(this).trigger('formUpdated'); - }); - } -}; - -/** - * Prepopulate form fields with information from the visitor cookie. - */ -Drupal.behaviors.fillUserInfoFromCookie = { - attach: function (context, settings) { - var userInfo = ['name', 'mail', 'homepage']; - $('form.user-info-from-cookie').once('user-info-from-cookie', function () { - var formContext = this; - var $formContext = $(this); - var i, il, $element, cookie; - for (i = 0, il = userInfo.length; i < il; i += 1) { - $element = $formContext.find('[name=' + userInfo[i] + ']'); - cookie = $.cookie('Drupal.visitor.' + userInfo[i]); - if ($element.length && cookie) { - $element.val(cookie); - } - } - }); - } -}; - -})(jQuery); diff --git a/core/misc/html5.js b/core/misc/html5.js deleted file mode 100644 index a984d04..0000000 --- a/core/misc/html5.js +++ /dev/null @@ -1,3 +0,0 @@ -// HTML5 Shiv v3 | @jon_neal @afarkas @rem | MIT/GPL2 Licensed -// Uncompressed source: https://github.com/aFarkas/html5shiv -(function(a,b){var c=function(a){return a.innerHTML="",a.childNodes.length===1}(b.createElement("a")),d=function(a,b,c){return b.appendChild(a),(c=(c?c(a):a.currentStyle).display)&&b.removeChild(a)&&c==="block"}(b.createElement("nav"),b.documentElement,a.getComputedStyle),e={elements:"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),shivDocument:function(a){a=a||b;if(a.documentShived)return;a.documentShived=!0;var f=a.createElement,g=a.createDocumentFragment,h=a.getElementsByTagName("head")[0],i=function(a){f(a)};c||(e.elements.join(" ").replace(/\w+/g,i),a.createElement=function(a){var b=f(a);return b.canHaveChildren&&e.shivDocument(b.document),b},a.createDocumentFragment=function(){return e.shivDocument(g())});if(!d&&h){var j=f("div");j.innerHTML=["x"].join(""),h.insertBefore(j.lastChild,h.firstChild)}return a}};e.shivDocument(b),a.html5=e})(this,document) diff --git a/core/misc/jquery.ba-bbq.js b/core/misc/jquery.ba-bbq.js deleted file mode 100644 index deb9a2f..0000000 --- a/core/misc/jquery.ba-bbq.js +++ /dev/null @@ -1,19 +0,0 @@ - -/* - * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 - * http://benalman.com/projects/jquery-bbq-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); diff --git a/core/misc/jquery.form.js b/core/misc/jquery.form.js deleted file mode 100644 index 4c044b4..0000000 --- a/core/misc/jquery.form.js +++ /dev/null @@ -1,919 +0,0 @@ -/*! - * jQuery Form Plugin - * version: 2.87 (20-OCT-2011) - * @requires jQuery v1.3.2 or later - * - * Examples and documentation at: http://malsup.com/jquery/form/ - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - */ -;(function($) { - -/* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are intended to be exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').bind('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. -*/ - -/** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ -$.fn.ajaxSubmit = function(options) { - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - - var method, action, url, $form = this; - - if (typeof options == 'function') { - options = { success: options }; - } - - method = this.attr('method'); - action = this.attr('action'); - url = (typeof action === 'string') ? $.trim(action) : ''; - url = url || window.location.href || ''; - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; - } - - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || 'GET', - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options); - - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; - } - - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; - } - - var traditional = options.traditional; - if ( traditional === undefined ) { - traditional = $.ajaxSettings.traditional; - } - - var qx,n,v,a = this.formToArray(options.semantic); - if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); - } - - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } - - // fire vetoable 'validate' event - this.trigger('form-submit-validate', [a, this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; - } - - var q = $.param(a, traditional); - if (qx) - q = ( q ? (q + '&' + qx) : qx ); - - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else { - options.data = q; // data is the query string for 'post' - } - - var callbacks = []; - if (options.resetForm) { - callbacks.push(function() { $form.resetForm(); }); - } - if (options.clearForm) { - callbacks.push(function() { $form.clearForm(options.includeHidden); }); - } - - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); - } - else if (options.success) { - callbacks.push(options.success); - } - - options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || options; // jQuery 1.4+ supports scope context - for (var i=0, max=callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); - } - }; - - // are there files to upload? - var fileInputs = $('input:file', this).length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if (options.iframe !== false && (fileInputs || options.iframe || multipart)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function() { fileUpload(a); }); - } - else { - fileUpload(a); - } - } - else { - // IE7 massage (see issue 57) - if ($.browser.msie && method == 'get' && typeof options.type === "undefined") { - var ieMeth = $form[0].getAttribute('method'); - if (typeof ieMeth === 'string') - options.type = ieMeth; - } - $.ajax(options); - } - - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUpload(a) { - var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; - var useProp = !!$.fn.prop; - - if (a) { - if ( useProp ) { - // ensure that every serialized input is still enabled - for (i=0; i < a.length; i++) { - el = $(form[a[i].name]); - el.prop('disabled', false); - } - } else { - for (i=0; i < a.length; i++) { - el = $(form[a[i].name]); - el.removeAttr('disabled'); - } - }; - } - - if ($(':input[name=submit],:input[id=submit]', form).length) { - // if there is an input with a name or id of 'submit' then we won't be - // able to invoke the submit fn on the form (at least not x-browser) - alert('Error: Form elements must not have name or id of "submit".'); - return; - } - - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr('name'); - if (n == null) - $io.attr('name', id); - else - id = n; - } - else { - $io = $('