Created
September 6, 2011 22:54
-
-
Save linuxbender/1199229 to your computer and use it in GitHub Desktop.
script-holder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="jquery-1.6.2-vsdoc.js" /> | |
/// <reference path="jquery-ui-1.8.16.js" /> | |
//<![CDATA[ | |
$(document).ready(function () { | |
getButtonStatus(); | |
getAccordingStatus(); | |
}); | |
$(function () { | |
$("#accordion").accordion({ | |
clearStyle: true | |
}); | |
$('#accordion').bind('accordionchange', function (event, ui) { | |
var status = $("#accordion").accordion("option", "active"); | |
//console.log(status); | |
setAccordingStatus(status); | |
}); | |
}); | |
function setAccordingStatus(Id) { | |
$.post("/Json/According/", { "id": Id }, function (data) { | |
//console.log(data); | |
// verarbeiten der Daten und ans Tag binden | |
}, "json"); | |
} | |
function getAccordingStatus() { | |
$.post("/Json/According/", { "id": undefined }, function (data) { | |
//console.log(data); | |
$("#accordion").accordion("option", "active", data); | |
}, "json"); | |
} | |
function CheckButtonSetStatus(Id) { | |
var status = $(Id).attr("checked"); | |
setButtonStatus($(Id).attr("id"), status); | |
} | |
function setButtonStatus(Id, Status) { | |
$('#de').button("option", "disabled", true); | |
//console.log(Id); | |
$.post("/Json/index/", { "id": Id , "status": Status }, function (data) { | |
//console.log(data); | |
// verarbeiten der Daten und ans Tag binden | |
}, "json"); | |
} | |
function getButtonStatus() { | |
$('#de').button("option", "disabled", true); | |
$.post("/Json/index/", { "id": undefined, "status": undefined }, function (data) { | |
//console.log(data); | |
$.each(data, function () { | |
//console.log(this.id + " " + this.status); | |
$('#'+this.id).attr('checked', this.status).button("refresh"); | |
}); | |
}, "json"); | |
} | |
$(function () { | |
$('#format').buttonset() | |
$("#de").click(function () { | |
$(".editor-label.de,.editor-field.de").slideToggle("fast"); | |
CheckButtonSetStatus(this) | |
//console.log(CheckButtonSetStatus(this)); | |
}); | |
$("#f").click(function () { | |
$(".editor-label.f,.editor-field.f").slideToggle("fast"); | |
CheckButtonSetStatus(this) | |
//console.log(CheckButtonSetStatus(this)); | |
}); | |
$("#it").click(function () { | |
$(".editor-label.it,.editor-field.it").slideToggle("fast"); | |
CheckButtonSetStatus(this) | |
//console.log(CheckButtonSetStatus(this)); | |
}); | |
$("#sp").click(function () { | |
$(".editor-label.sp,.editor-field.sp").slideToggle("fast"); | |
CheckButtonSetStatus(this) | |
//console.log(CheckButtonSetStatus(this)); | |
}); | |
$("#ro").click(function () { | |
$(".editor-label.ro,.editor-field.ro").slideToggle("fast"); | |
CheckButtonSetStatus(this) | |
//console.log(CheckButtonSetStatus(this)); | |
}); | |
}); | |
$(function () { | |
$("input[id$='dAt']").datepicker({ | |
showOn: "both", | |
gotoCurrent: true | |
}); | |
}); | |
$(function () { | |
$("#dialog-message").dialog({ | |
modal: true, | |
resizable: false, | |
height: 280, | |
width: 600, | |
buttons: { | |
"Zurück zur letzten Eingabe": function () { | |
$(this).dialog("close"); | |
history.back(); | |
}//, | |
// Cancel: function () { | |
// $(this).dialog("close"); | |
// history.back(); | |
// } | |
} | |
}); | |
$(".ui-dialog-titlebar").hide(); | |
$(".error").errorStyle(); | |
}); | |
/* addon error msg*/ | |
(function ($) { | |
$.fn.errorStyle = function () { | |
this.replaceWith(function (i, html) { | |
var StyledError = "<div class=\"ui-state-error ui-corner-all\" style=\"padding: 0 .7em;\">"; | |
StyledError += "<p><span class=\"ui-icon ui-icon-alert\" style=\"float: left; margin-right: .3em;\">"; | |
StyledError += "</span>"; | |
StyledError += html; | |
StyledError += "</p></div>"; | |
return StyledError; | |
}); | |
} | |
})(jQuery); | |
//]]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace demo_03.Controllers | |
{ | |
public class JsonController : Controller | |
{ | |
// GET: /Json/ | |
public ActionResult Index(string id, bool status = true) | |
{ | |
if (Session["Status"] == null) | |
{ | |
var list = new List<Status>() | |
{ | |
new Status { id = "de" , status = true }, | |
new Status { id = "f" , status = true }, | |
new Status { id = "it" , status = true }, | |
new Status { id = "sp" , status = false }, | |
new Status { id = "ro" , status = false } | |
}; | |
SetStatusList(list, id, status); | |
return Json(list); | |
} | |
else | |
{ | |
var list = (List<Status>)Session["Status"]; | |
SetStatusList(list, id, status); | |
return Json(list); | |
} | |
} | |
private void SetStatusList(List<Status> list, string id, bool status) | |
{ | |
if (id != null) | |
{ | |
list.Single(o => o.id == id).status = status; | |
} | |
Session["Status"] = list; | |
} | |
private void SetAccording(int? id) | |
{ | |
if (id != null) | |
{ | |
Session["According"] = id; | |
} | |
} | |
public ActionResult According(int? id) | |
{ | |
if (Session["According"] == null) | |
{ | |
Session["According"] = 0; | |
SetAccording(id); | |
return Json(Session["According"]); | |
} | |
else | |
{ | |
SetAccording(id); | |
return Json(Session["According"]); | |
} | |
} | |
} | |
public class Status | |
{ | |
public string id { get; set; } | |
public bool status { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment