Remembering the view type of the features list and added some rough and simple client app settings functionality
--HG-- branch : dev
@ -81,12 +81,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="scripts\jquery.switchable.js" />
|
||||
<Content Include="styles\images\summary-view.gif" />
|
||||
<Content Include="styles\images\summary-view-on.gif" />
|
||||
<Content Include="styles\images\detail-view.gif" />
|
||||
<Content Include="styles\images\detail-view-on.gif" />
|
||||
<Content Include="styles\jquery.switchable.css" />
|
||||
<Content Include="Views\Admin\Add.ascx" />
|
||||
<Content Include="Views\Admin\Index.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
|
@ -1,15 +1,12 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<FeaturesViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Localization" %>
|
||||
<%@ Import Namespace="Orchard.Modules.Extensions" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.Modules.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Utility.Extensions" %><%
|
||||
Html.RegisterStyle("admin.css");
|
||||
Html.RegisterStyle("jquery.switchable.css");
|
||||
Html.RegisterFootScript("jquery.switchable.js"); %>
|
||||
Html.RegisterStyle("admin.css"); %>
|
||||
<h1><%: Html.TitleForPage(T("Manage Features").ToString()) %></h1>
|
||||
<% if (Model.Features.Count() > 0) { %>
|
||||
<ul class="features summary-view switchable"><%
|
||||
<ul class="<% Html.RenderPartial("UI/Switchable", "features summary-view"); %>"><%
|
||||
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category).GroupBy(f => f.Descriptor.Category);
|
||||
foreach (var featureGroup in featureGroups) {
|
||||
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
|
||||
|
@ -89,10 +89,16 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Content\orchard.ico" />
|
||||
<Content Include="Scripts\base.js" />
|
||||
<Content Include="Scripts\jquery.switchable.js" />
|
||||
<Content Include="Styles\admin.css" />
|
||||
<Content Include="Styles\Images\detail-view-on.gif" />
|
||||
<Content Include="Styles\Images\detail-view.gif" />
|
||||
<Content Include="Styles\Images\summary-view-on.gif" />
|
||||
<Content Include="Styles\Images\summary-view.gif" />
|
||||
<Content Include="Styles\Images\toolBarActiveButtonBackground.gif" />
|
||||
<Content Include="Styles\Images\toolBarBackground.gif" />
|
||||
<Content Include="Styles\Images\toolBarHoverButtonBackground.gif" />
|
||||
<Content Include="Styles\jquery.switchable.css" />
|
||||
<Content Include="Styles\special.css" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
<Content Include="Views\Admin\Install.aspx" />
|
||||
@ -106,6 +112,7 @@
|
||||
<Content Include="Views\Menu.ascx" />
|
||||
<Content Include="Views\Messages.ascx" />
|
||||
<Content Include="Views\NotFound.ascx" />
|
||||
<Content Include="Views\UI\Switchable.ascx" />
|
||||
<Content Include="Views\User.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
</ItemGroup>
|
||||
|
@ -1,5 +1,47 @@
|
||||
(function ($) {
|
||||
//todo: (heskew) make use of the autofocus attribute instead
|
||||
// Some simple settings storage/retrieval
|
||||
$.extend({
|
||||
orchard: {
|
||||
__cookieName: "Orchrd", // Orchard, on a diet
|
||||
__cookieExpiration: 180, // roughly 6 months
|
||||
cookie: function (scope, value, options) { // a light-weight wrapper around $.cookie for an Orchard.* cookie name
|
||||
return $.cookie($.orchard.__cookieName + (scope ? "-" + scope.toLowerCase() : ""), value, options);
|
||||
},
|
||||
setting: function (name, value, options) { // cookie-stored settings (only, at the moment)
|
||||
if (value && value.path) {
|
||||
options = value;
|
||||
value = undefined;
|
||||
}
|
||||
var scope = (options && options.path && options.path.replace(/\W+/g, "-")) || ""; // this could become a problem with long paths as it's appended to the cookie name
|
||||
var cookie = $.orchard.cookie(scope);
|
||||
var key = (name + ((options && !!options.key && options.key) || "")).replace(/\W+/g, "-");
|
||||
if (typeof value === "undefined") { // try to get the setting value from the default "root" cookie
|
||||
if (cookie) {
|
||||
var data = $.parseJSON(cookie);
|
||||
return data && data[key];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
else { // store the setting value - the setting isn't removable by the way, setting to "" might be enough for most cases
|
||||
var data = (cookie && $.parseJSON(cookie)) || {};
|
||||
data[key] = value;
|
||||
var dataString = (function (obj) { //todo: pull out into a seperate function
|
||||
if (!obj) { return ""; }
|
||||
var k, str = "{";
|
||||
for (k in obj) { // only really simple stringification
|
||||
str = str + "\"" + k + "\":\"" + obj[k] + "\",";
|
||||
}
|
||||
if (str.length > 1) {
|
||||
str = str.substring(0, str.length - 1);
|
||||
}
|
||||
return str + "}";
|
||||
})(data);
|
||||
$.orchard.cookie(scope, dataString, { expires: $.orchard.__cookieExpiration, path: (options && options.path) || "/" }); // todo: default path should be app path
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Some input (auto)focus and input-controlled toggle
|
||||
$.fn.extend({
|
||||
helpfullyFocus: function () {
|
||||
var _this = $(this);
|
||||
@ -13,7 +55,7 @@
|
||||
return;
|
||||
}
|
||||
// otherwise, make the autofocus attribute work
|
||||
var autofocus = _this.find(":input[autofocus=autofocus]").first();
|
||||
var autofocus = _this.find(":input[autofocus]").first();
|
||||
return autofocus.focus();
|
||||
},
|
||||
toggleWhatYouControl: function () {
|
||||
@ -62,7 +104,7 @@
|
||||
$("body").append(_this);
|
||||
});
|
||||
})();
|
||||
// a little better autofocus
|
||||
// (do) a little better autofocus
|
||||
$(function () {
|
||||
$("body").helpfullyFocus();
|
||||
});
|
||||
@ -89,4 +131,104 @@
|
||||
_this.click(function () { form.submit(); return false; });
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// --- some plugins leaned on by core script components //
|
||||
///////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Cookie plugin
|
||||
*
|
||||
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a cookie with the given name and value and other optional parameters.
|
||||
*
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Set the value of a cookie.
|
||||
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
|
||||
* @desc Create a cookie with all available options.
|
||||
* @example $.cookie('the_cookie', 'the_value');
|
||||
* @desc Create a session cookie.
|
||||
* @example $.cookie('the_cookie', null);
|
||||
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
|
||||
* used when the cookie was set.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @param String value The value of the cookie.
|
||||
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
|
||||
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
|
||||
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
|
||||
* If set to null or omitted, the cookie will be a session cookie and will not be retained
|
||||
* when the the browser exits.
|
||||
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
|
||||
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
|
||||
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
|
||||
* require a secure protocol (like HTTPS).
|
||||
* @type undefined
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the value of a cookie with the given name.
|
||||
*
|
||||
* @example $.cookie('the_cookie');
|
||||
* @desc Get the value of a cookie.
|
||||
*
|
||||
* @param String name The name of the cookie.
|
||||
* @return The value of the cookie.
|
||||
* @type String
|
||||
*
|
||||
* @name $.cookie
|
||||
* @cat Plugins/Cookie
|
||||
* @author Klaus Hartl/klaus.hartl@stilbuero.de
|
||||
*/
|
||||
jQuery.cookie = function(name, value, options) {
|
||||
if (typeof value != 'undefined') { // name and value given, set cookie
|
||||
options = options || {};
|
||||
if (value === null) {
|
||||
value = '';
|
||||
options.expires = -1;
|
||||
}
|
||||
var expires = '';
|
||||
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
|
||||
var date;
|
||||
if (typeof options.expires == 'number') {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
|
||||
} else {
|
||||
date = options.expires;
|
||||
}
|
||||
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
|
||||
}
|
||||
// CAUTION: Needed to parenthesize options.path and options.domain
|
||||
// in the following expressions, otherwise they evaluate to undefined
|
||||
// in the packed version for some reason...
|
||||
var path = options.path ? '; path=' + (options.path) : '';
|
||||
var domain = options.domain ? '; domain=' + (options.domain) : '';
|
||||
var secure = options.secure ? '; secure' : '';
|
||||
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
|
||||
} else { // only name given, get cookie
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie != '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
};
|
@ -4,18 +4,26 @@
|
||||
var _this = $(this);
|
||||
var theSwitch = $("<div class=\"switch-for-switchable\"><ul class=\"switch-button-group\"><li class=\"switch-button summary-view\"> </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); });
|
||||
var summarySwitch = theSwitch.find(".summary-view").click(function () { $(this).switchToSummaryView(_this); });
|
||||
var detailSwitch = theSwitch.find(".detail-view").click(function () { $(this).switchToDetailView(_this); });
|
||||
|
||||
theSwitch.addClass(_this.hasClass("summary-view") ? "summary-switched" : "detail-switched");
|
||||
var setting = $.orchard.setting("switchable", { path: document.location.pathname })
|
||||
|| (_this.hasClass("summary-view") ? "summary-view" : "detail-view");
|
||||
if (setting === "summary-view") {
|
||||
summarySwitch.switchToSummaryView(_this);
|
||||
} else {
|
||||
detailSwitch.switchToDetailView(_this);
|
||||
}
|
||||
|
||||
theSwitch.insertBefore(_this);
|
||||
},
|
||||
switchToDetailView: function (switched) {
|
||||
$.orchard.setting("switchable", "detail-view", { path: document.location.pathname });
|
||||
$(this).closest(".switch-for-switchable").addClass("detail-switched").removeClass("summary-switched");
|
||||
switched.addClass("detail-view").removeClass("summary-view");
|
||||
},
|
||||
switchToSummaryView: function (switched) {
|
||||
$.orchard.setting("switchable", "summary-view", { path: document.location.pathname });
|
||||
$(this).closest(".switch-for-switchable").addClass("summary-switched").removeClass("detail-switched");
|
||||
switched.addClass("summary-view").removeClass("detail-view");
|
||||
}
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 156 B |
@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
|
||||
<%
|
||||
Html.RegisterStyle("jquery.switchable.css");
|
||||
Html.RegisterFootScript("jquery.switchable.js");
|
||||
var cssClass = string.Format("{0} switchable", Model);
|
||||
|
||||
%>
|
||||
<%:cssClass %>
|
@ -43,7 +43,7 @@ namespace Orchard.UI.Resources {
|
||||
context.SetAttribute("rel", "stylesheet");
|
||||
|
||||
if (!_styles.Contains(context))
|
||||
_styles.Add(context);
|
||||
_styles.Insert(0, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
@ -60,7 +60,7 @@ namespace Orchard.UI.Resources {
|
||||
context.SetAttribute("type", "text/javascript");
|
||||
|
||||
if (!_headScripts.Contains(context))
|
||||
_headScripts.Add(context);
|
||||
_headScripts.Insert(0, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace Orchard.UI.Resources {
|
||||
context.SetAttribute("type", "text/javascript");
|
||||
|
||||
if (!_footScripts.Contains(context))
|
||||
_footScripts.Add(context);
|
||||
_footScripts.Insert(0, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|