/* nuget: begin license text * * microsoft grants you the right to use these script files for the sole * purpose of either: (i) interacting through your browser with the microsoft * website or online service, subject to the applicable licensing or use * terms; or (ii) using the files as included with a microsoft product subject * to that product's license terms. microsoft reserves all other rights to the * files not expressly granted by microsoft, whether by implication, estoppel * or otherwise. insofar as a script file is dual licensed under gpl, * microsoft neither took the code under gpl nor distributes it thereunder but * under the terms set out in this paragraph. all notices and licenses * below are for informational purposes only. * * nuget: end license text */ /*! ** unobtrusive ajax support library for jquery ** copyright (c) microsoft corporation. all rights reserved. */ /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ /*global window: false, jquery: false */ (function ($) { var data_click = "unobtrusiveajaxclick", data_validation = "unobtrusivevalidation"; function getfunction(code, argnames) { var fn = window, parts = (code || "").split("."); while (fn && parts.length) { fn = fn[parts.shift()]; } if (typeof (fn) === "function") { return fn; } argnames.push(code); return function.constructor.apply(null, argnames); } function ismethodproxysafe(method) { return method === "get" || method === "post"; } function asynconbeforesend(xhr, method) { if (!ismethodproxysafe(method)) { xhr.setrequestheader("x-http-method-override", method); } } function asynconsuccess(element, data, contenttype) { var mode; if (contenttype.indexof("application/x-javascript") !== -1) { // jquery already executes javascript for us return; } mode = (element.getattribute("data-ajax-mode") || "").touppercase(); $(element.getattribute("data-ajax-update")).each(function (i, update) { var top; switch (mode) { case "before": top = update.firstchild; $("
").html(data).contents().each(function () { update.insertbefore(this, top); }); break; case "after": $("
").html(data).contents().each(function () { update.appendchild(this); }); break; default: $(update).html(data); break; } }); } function asyncrequest(element, options) { var confirm, loading, method, duration; confirm = element.getattribute("data-ajax-confirm"); if (confirm && !window.confirm(confirm)) { return; } loading = $(element.getattribute("data-ajax-loading")); duration = element.getattribute("data-ajax-loading-duration") || 0; $.extend(options, { type: element.getattribute("data-ajax-method") || undefined, url: element.getattribute("data-ajax-url") || undefined, beforesend: function (xhr) { var result; asynconbeforesend(xhr, method); result = getfunction(element.getattribute("data-ajax-begin"), ["xhr"]).apply(this, arguments); if (result !== false) { loading.show(duration); } return result; }, complete: function () { loading.hide(duration); getfunction(element.getattribute("data-ajax-complete"), ["xhr", "status"]).apply(this, arguments); }, success: function (data, status, xhr) { asynconsuccess(element, data, xhr.getresponseheader("content-type") || "text/html"); getfunction(element.getattribute("data-ajax-success"), ["data", "status", "xhr"]).apply(this, arguments); }, error: getfunction(element.getattribute("data-ajax-failure"), ["xhr", "status", "error"]) }); options.data.push({ name: "x-requested-with", value: "xmlhttprequest" }); method = options.type.touppercase(); if (!ismethodproxysafe(method)) { options.type = "post"; options.data.push({ name: "x-http-method-override", value: method }); } $.ajax(options); } function validate(form) { var validationinfo = $(form).data(data_validation); return !validationinfo || !validationinfo.validate || validationinfo.validate(); } $(document).on("click", "a[data-ajax=true]", function (evt) { evt.preventdefault(); asyncrequest(this, { url: this.href, type: "get", data: [] }); }); $(document).on("click", "form[data-ajax=true] input[type=image]", function (evt) { var name = evt.target.name, $target = $(evt.target), form = $target.parents("form")[0], offset = $target.offset(); $(form).data(data_click, [ { name: name + ".x", value: math.round(evt.pagex - offset.left) }, { name: name + ".y", value: math.round(evt.pagey - offset.top) } ]); settimeout(function () { $(form).removedata(data_click); }, 0); }); $(document).on("click", "form[data-ajax=true] :submit", function (evt) { var name = evt.target.name, form = $(evt.target).parents("form")[0]; $(form).data(data_click, name ? [{ name: name, value: evt.target.value }] : []); settimeout(function () { $(form).removedata(data_click); }, 0); }); $(document).on("submit", "form[data-ajax=true]", function (evt) { var clickinfo = $(this).data(data_click) || []; evt.preventdefault(); if (!validate(this)) { return; } asyncrequest(this, { url: this.action, type: this.method || "get", data: clickinfo.concat($(this).serializearray()) }); }); }(jquery));