Files
Orchard/src/Orchard.Web/Modules/Orchard.Modules/scripts/jquery.switchable.js
Nathan Heskew 19c2f0e1c1 Added a switchable view interface for the features UI* and cleaned up a little more
* can be pulled back into the base eventually

--HG--
branch : dev
2010-05-28 15:17:33 -07:00

24 lines
1.2 KiB
JavaScript

(function ($) {
$.fn.extend({
powerUpTheSwitch: function () {
var _this = $(this);
var theSwitch = $("<div class=\"switch-for-switchable\"><ul class=\"switch-button-group\"><li class=\"switch-button summary-view\">&nbsp;</li><li class=\"switch-button detail-view\"></li></ul></div>");
theSwitch.find(".summary-view").click(function () { $(this).switchToSummaryView(_this); });
theSwitch.find(".detail-view").click(function () { $(this).switchToDetailView(_this); });
theSwitch.addClass(_this.hasClass("summary-view") ? "summary-switched" : "detail-switched");
theSwitch.insertBefore(_this);
},
switchToDetailView: function (switched) {
$(this).closest(".switch-for-switchable").addClass("detail-switched").removeClass("summary-switched");
switched.addClass("detail-view").removeClass("summary-view");
},
switchToSummaryView: function (switched) {
$(this).closest(".switch-for-switchable").addClass("summary-switched").removeClass("detail-switched");
switched.addClass("summary-view").removeClass("detail-view");
}
});
$(".switchable").powerUpTheSwitch();
})(jQuery);