Ajax Links are all handled by jQuery now, no more MvcAjax handlers.

pull/19/head
Mark McDowall 13 years ago
parent 7a1301610a
commit 4a55d08130

@ -14,14 +14,12 @@ namespace NzbDrone.Web.Controllers
_jobProvider = jobProvider;
}
[HttpPost]
public JsonResult Search(int episodeId)
{
_jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId);
return JsonNotificationResult.Info("Queued");
}
[HttpPost]
public JsonResult SearchSeason(int seriesId, int seasonNumber)
{
_jobProvider.QueueJob(typeof(SeasonSearchJob), seriesId, seasonNumber);

@ -11,21 +11,6 @@ namespace NzbDrone.Web.Helpers
{
public static class LinkHelper
{
public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, object imgAttributes, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
{
return ImageActionLink(helper, imageUrl, imgAttributes, actionName, null, routeValues, ajaxOptions, htmlAttributes);
}
public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, object imgAttributes, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
{
var builder = new TagBuilder("img");
builder.MergeAttribute("src", imageUrl);
var imgAttributesDictionary = new RouteValueDictionary(imgAttributes);
builder.MergeAttributes(imgAttributesDictionary);
var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString();
return new MvcHtmlString(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)));
}
public static MvcHtmlString ImageActionLink(this HtmlHelper helper, string imageUrl, object imgAttributes, string actionName, object routeValues, object htmlAttributes)
{
return ImageActionLink(helper, imageUrl, imgAttributes, actionName, null, routeValues, htmlAttributes);

@ -42,4 +42,21 @@
}
});
});
});
//Make .ajaxLink use jQuery Ajax for the request
$(document).on('click', '.ajaxLink', function (event) {
event.preventDefault();
var onSuccess = $(this).attr('onsuccess');
$.ajax({
url: this.href,
cache: false,
success: function () {
if (onSuccess) {
window[onSuccess]();
}
}
});
return false;
});

@ -1,6 +1,6 @@
/* Click on row, show details */
$('.seriesTable a, .dataTable a').live('click', function (event) {
if ($(this).attr('onclick'))
$(document).on('click', '.seriesTable a, .dataTable a', function (event) {
if ($(this).hasClass('ajaxLink') || $(this).attr('onclick'))
return;
event.preventDefault();
@ -48,8 +48,8 @@ function fnFormatDetails(nTr) {
//Create Image
function createImageAjaxLink(url, image, alt, title, classes) {
var html = "<a onclick=\"Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace });\" href=\"" + url + "\">" +
"<img class=\"" + classes + "\" src=\"" + image + "\" title=\"" + title + "\" alt=\"" + alt + "\"></a>";
var html = '<a href="' + url + '" class="ajaxLink">' +
'<img class="' + classes + '" src="' + image + '" title="' + title + '" alt="' + alt + '" /></a>';
return html;
}

@ -3,8 +3,8 @@
@{ViewBag.Title = "History";}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Trim History", "Trim", "History", new AjaxOptions { OnSuccess = "reloadGrid" })</li>
<li>@Ajax.ActionLink("Purge History", "Purge", "History", new AjaxOptions { OnSuccess = "reloadGrid" })</li>
<li>@Html.ActionLink("Trim History", "Trim", "History", null, new { @class = "ajaxLink", onSuccess = "reloadGrid" })</li>
<li>@Html.ActionLink("Purge History", "Purge", "History", null, new { @class = "ajaxLink", onSuccess = "reloadGrid" })</li>
</ul>
}
@section HeaderContent

@ -3,7 +3,7 @@
@{ ViewBag.Title = "Logs";}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Clear Logs", "Clear", "Log", new AjaxOptions { OnSuccess = "redrawGrid" })</li>
<li>@Html.ActionLink("Clear Logs", "Clear", "Log", null, new { @class = "ajaxLink", onSuccess = "redrawGrid" })</li>
<li>@Html.ActionLink("File", "File", "Log")</li>
</ul>
}

@ -9,9 +9,9 @@
}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Start RSS Sync", "RssSync", "Command", null, null)</li>
<li>@Ajax.ActionLink("Start Backlog Search", "BacklogSearch", "Command", null, null, new { title = "Backlog search for ALL missing episodes" })</li>
<li>@Ajax.ActionLink("Start Recent Backlog Search", "RecentBacklogSearch", "Command", null, null, new { title = "Backlog search for missing episodes that aired in the last 30 days only" })</li>
<li>@Html.ActionLink("Start RSS Sync", "RssSync", "Command", null, new { @class = "ajaxLink" })</li>
<li>@Html.ActionLink("Start Backlog Search", "BacklogSearch", "Command", null, new { title = "Backlog search for ALL missing episodes", @class = "ajaxLink" })</li>
<li>@Html.ActionLink("Start Recent Backlog Search", "RecentBacklogSearch", "Command", null, new { title = "Backlog search for missing episodes that aired in the last 30 days only", @class = "ajaxLink" })</li>
</ul>
}
<div class="grid-container">

@ -68,9 +68,9 @@
{
<ul class="sub-menu">
<li><a class="editButton" value="@Model.SeriesId" rel="@Model.Title">Edit</a></li>
<li>@Ajax.ActionLink("Force Refresh", "ForceRefresh", "Command", new { seriesId = Model.SeriesId }, null)</li>
<li>@Ajax.ActionLink("Search for missing episodes", "BacklogSeries", "Episode", new { seriesId = Model.SeriesId }, null)</li>
<li>@Ajax.ActionLink("Rename Episode Files", "RenameEpisodes", "Episode", new { seriesId = Model.SeriesId }, null)</li>
<li>@Html.ActionLink("Force Refresh", "ForceRefresh", "Command", new { seriesId = Model.SeriesId }, new { @class = "ajaxLink" })</li>
<li>@Html.ActionLink("Search for missing episodes", "BacklogSeries", "Episode", new { seriesId = Model.SeriesId }, new { @class = "ajaxLink" })</li>
<li>@Html.ActionLink("Rename Episode Files", "RenameEpisodes", "Episode", new { seriesId = Model.SeriesId }, new { @class = "ajaxLink" })</li>
</ul>
}

@ -25,7 +25,7 @@
@*Commands Column*@
<td class="@cellColourClass">
<img src='../../Content/Images/@(Model.Ignored ? "ignored" : "notIgnored").png' class='ignoreEpisode ignoreEpisode_@(Model.SeasonNumber)@(Model.Ignored ? " ignored" : " ") gridAction' id='@Model.EpisodeId' title='Click to toggle episode ignore status' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "gridAction" }, "Search", "Episode", new { episodeId = Model.EpisodeId }, null, null)
@Html.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "gridAction" }, "Search", "Episode", new { episodeId = Model.EpisodeId }, new { @class = "ajaxLink" })
<img src='../../Content/Images/@(Model.Status).png' alt='@Model.Status' title='@Model.Status' class='gridImage status-@Model.Status statusImage' />
</td>
</tr>

@ -75,7 +75,7 @@
@section ActionMenu{
<ul class="sub-menu">
<li>@Html.ActionLink("Add Series", "Index", "AddSeries")</li>
<li>@Ajax.ActionLink("Start RSS Sync", "RssSync", "Command", null)</li>
<li>@Html.ActionLink("Start RSS Sync", "RssSync", "Command", null, new { @class = "ajaxLink" })</li>
<li>@Html.ActionLink("Series Editor", "SeriesEditor", "Series")</li>
</ul>
}

@ -23,8 +23,8 @@
@*Commands Column*@
<th>
<img src='../../Content/Images/@(Model.Ignored ? "ignored" : "notIgnored").png' class='ignoredEpisodesMaster ignoreEpisode ignoreSeason_@(Model.SeasonNumber)@(Model.Ignored ? " ignored" : " ") gridAction' title='Click to toggle season ignore status' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for all episodes in this season", @class = "gridAction" }, "SearchSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, null, null)
@Ajax.ImageActionLink("../../Content/Images/Rename.png", new { Alt = "Rename", Title = "Rename all episodes in this season", @class = "gridAction" }, "RenameSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, null, null)
@Html.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for all episodes in this season", @class = "gridAction" }, "SearchSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, new { @class = "ajaxLink" })
@Html.ImageActionLink("../../Content/Images/Rename.png", new { Alt = "Rename", Title = "Rename all episodes in this season", @class = "gridAction" }, "RenameSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, new { @class = "ajaxLink" })
</th>
</tr>
</thead>

@ -20,7 +20,7 @@
}
@section ActionMenu{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Start RSS Sync", "RssSync", "Command", null, null)</li>
<li>@Html.ActionLink("Start RSS Sync", "RssSync", "Command", null, new { @class = "ajaxLink" })</li>
</ul>
}
<div class="gridControls">

@ -36,7 +36,7 @@
@*Commands Column*@
<td class="@cellColourClass">
<img src='../../Content/Images/@(Model.Status).png' alt='@Model.Status' title='@Model.Status' class='gridImage statusImage' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "gridAction" }, "Search", "Episode", new { episodeId = Model.EpisodeId }, null, null)
@Html.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "gridAction" }, "Search", "Episode", new { episodeId = Model.EpisodeId }, new { @class = "ajaxLink" })
</td>
</tr>

@ -9,7 +9,7 @@ else
{
<h2>
Available Update: @Model.UpdatePackage.Version
@Ajax.ActionLink("Update", "StartUpdate", "Update", null)
@Html.ActionLink("Update", "StartUpdate", "Update", null, new { @class = "ajaxLink" })
</h2>
}
@if (Model.LogFiles.Count != 0)

Loading…
Cancel
Save