--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2011-03-09 17:02:09 -08:00
11 changed files with 132 additions and 55 deletions
+6
View File
@@ -51,6 +51,12 @@ Website: http://clay.codeplex.com/
Copyright: Copyright (c) 2010 Louis Dejardin Copyright: Copyright (c) 2010 Louis Dejardin
License: MS-PL License: MS-PL
CodeMirror
----------
Website: http://codemirror.net/2/
Copyright: Copyright (C) 2011 by Marijn Haverbeke
License: MIT
DLR DLR
--- ---
Website: http://dlr.codeplex.com Website: http://dlr.codeplex.com
@@ -5,12 +5,12 @@
} }
<fieldset> <fieldset>
@Html.EditorFor(m => m.OnAdminMenu) @Html.EditorFor(m => m.OnAdminMenu)
<label for="OnAdminMenu" class="forcheckbox">@T("Create an admin menu item to manage this {0}", Model.ContentItem.ContentType)</label> <label for="OnAdminMenu" class="forcheckbox">@T("Show on admin menu")</label>
<div data-controllerid="OnAdminMenu" class=""> <div data-controllerid="OnAdminMenu" class="">
<label for="AdminMenuText">@T("Admin menu text")</label> <label for="AdminMenuText">@T("Menu text")</label>
@Html.TextBoxFor(m => m.AdminMenuText, new { @class = "large text" }) @Html.TextBoxFor(m => m.AdminMenuText, new { @class = "large text" })
<label for="AdminMenuPosition">@T("Admin menu position")</label> <label for="AdminMenuPosition">@T("Position")</label>
@Html.TextBoxFor(m => m.AdminMenuPosition) @Html.TextBoxFor(m => m.AdminMenuPosition)
</div> </div>
</fieldset> </fieldset>
@@ -57,11 +57,15 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
} }
// text mode // text mode
else if (ch == "@") { else if (ch == "@") {
if (stream.peek() != "@") { // handle @@ escaping
state.tokenize = inRazor(inText); state.tokenize = inRazor(inText);
return "razor-tag"; return "razor-tag";
} }
stream.next()
}
else { else {
stream.eatWhile(/[^&<]/); stream.eatWhile(/[^&<@]/);
return null; return null;
} }
} }
@@ -91,12 +95,12 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
return function (stream, state) { return function (stream, state) {
var razor = false; var razor = false;
while (!stream.eol()) { while (!stream.eol()) {
if (stream.next() == quote) { if (stream.peek() == "@") {
state.tokenize = inTag; state.tokenize = inRazorAttribute(quote);
break; break;
} }
else if (stream.peek() == "@") { else if (stream.next() == quote) {
state.tokenize = inRazor(inAttribute(quote), "xml-attribute"); state.tokenize = inTag;
break; break;
} }
} }
@@ -104,6 +108,14 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
}; };
} }
function inRazorAttribute(quote) {
return function (stream, state) {
stream.eat("@");
state.tokenize = inRazor(inAttribute(quote), "xml-attribute");
return "razor-tag";
}
}
function inBlock(style, terminator) { function inBlock(style, terminator) {
return function (stream, state) { return function (stream, state) {
while (!stream.eol()) { while (!stream.eol()) {
@@ -128,10 +140,10 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
return "razor-keyword"; return "razor-keyword";
} }
else if (stream.match("{")) { else if (stream.match("{")) {
state.tokenize = inRazorBlock(); state.tokenize = inRazorBlock(1, nextState);
} }
else { else {
stream.eatWhile(/[^\s\'\"\<]/); stream.eatWhile(/[^\s\'\"<@]/);
state.tokenize = nextState; state.tokenize = nextState;
} }
@@ -156,33 +168,42 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
} }
} }
function inRazorBlock(nestedLevel) { function inRazorBlock(nestedLevel, nextState) {
var nested = nestedLevel || 1; var nested = nestedLevel || 1;
return function (stream, state) { return function (stream, state) {
while (!stream.eol()) { while (!stream.eol()) {
// identify keywords // identify keywords
if (stream.eatWhile(/[a-zA-Z]/)) { if (stream.eatWhile(/\w/)) {
state.tokenize = inRazorBlock(nested, nextState);
if (keywords[stream.current()]) { if (keywords[stream.current()]) {
state.tokenize = inRazorBlock(nested); stream.eatSpace();
return "razor-keyword"; return "razor-keyword";
} }
stream.next();
break;
}
if (stream.peek() == '"') {
state.tokenize = inRazorString(inRazorBlock(nested, nextState));
break;
} }
if (stream.peek() == '{') nested++; if (stream.peek() == '{') nested++;
if (stream.peek() == '}') nested--; if (stream.peek() == '}') nested--;
if (nested == 0) { if (nested == 0) {
state.tokenize = inRazorBlockEnd; state.tokenize = inRazorBlockEnd(nextState);
break; break;
} }
// eat keywords separators if (stream.eatWhile(/[^\w{}\"]/)) {
if (stream.eatWhile(/^[a-zA-Z]/)) { stream.eatSpace();
state.tokenize = inRazorBlock(nested); state.tokenize = inRazorBlock(nested, nextState);
stream.next(); break;
return "razor";
} }
stream.next(); stream.next();
@@ -192,11 +213,24 @@ CodeMirror.defineMode("razor", function (config, parserConfig) {
}; };
} }
function inRazorBlockEnd(stream, state) { function inRazorBlockEnd(nextState) {
return function (stream, state) {
stream.eat("}"); stream.eat("}");
state.tokenize = inText; state.tokenize = nextState;
return "razor-tag"; return "razor-tag";
} }
}
function inRazorString(nextState) {
return function (stream, state) {
// when in this state, the " is not read yet
stream.eat('"');
stream.eatWhile(/[^"]/);
stream.eat('"');
state.tokenize = nextState;
return "razor-string";
}
}
var curState, setStyle; var curState, setStyle;
@@ -71,7 +71,9 @@
if (wrapper.children('.content').children('div' + selector).children('.CodeMirror').length == 0) { if (wrapper.children('.content').children('div' + selector).children('.CodeMirror').length == 0) {
var textArea = wrapper.children('.content').children('div' + selector).children('textarea').get(0); var textArea = wrapper.children('.content').children('div' + selector).children('textarea').get(0);
CodeMirror.fromTextArea(textArea, { mode: "razor", tabMode: "indent", height: "100%" }); if (textArea) {
CodeMirror.fromTextArea(textArea, { mode: "razor", tabMode: "indent", height: "100%", readOnly : true });
}
} }
}); });
@@ -9,3 +9,11 @@ span.xml-entity {color: #a22;}
span.razor {background-color: rgb(236, 242, 245)} span.razor {background-color: rgb(236, 242, 245)}
span.razor-tag {background-color: yellow;} span.razor-tag {background-color: yellow;}
span.razor-keyword {color: blue; background-color: rgb(236, 242, 245)} span.razor-keyword {color: blue; background-color: rgb(236, 242, 245)}
span.razor-string {color: rgb(163,21,21); background-color: rgb(236, 242, 245)}
.CodeMirror
{
font-family:Consolas, Monospace;
font-size:10pt;
line-height:12pt;
}
@@ -36,8 +36,8 @@
.debug-shapes .shape-tracing .wrapper { .debug-shapes .shape-tracing .wrapper {
background:#FFF; background:#FFF;
border:1px dotted #CA7230; /*border:1px dotted #CA7230;
margin:5px; margin:5px;*/
padding:0px; padding:0px;
display:inline-block; display:inline-block;
@@ -139,14 +139,14 @@ ul.debuggerMenu { margin:8px 0 -8px 0; }
-moz-border-radius: 3px; -moz-border-radius: 3px;
} }
.meta .model div.name .meta .model div.name, .meta ul.properties div.name
{ {
display:block; display:block;
float:left; float:left;
width:30%; width:30%;
} }
.meta .model ul .meta .model ul, .meta ul.properties
{ {
padding:0; padding:0;
margin-left:-15px; margin-left:-15px;
@@ -154,12 +154,12 @@ ul.debuggerMenu { margin:8px 0 -8px 0; }
list-style-type:none; list-style-type:none;
} }
.meta .model ul li .meta .model ul li, .meta ul.properties li
{ {
padding-left:15px; padding-left:15px;
} }
.meta .model h3 .meta .model h3, .meta ul.properties h3
{ {
margin:0; margin:0;
padding:0; padding:0;
@@ -183,14 +183,18 @@ h3:hover
background-image:url(images/menu-glyph.png); background-image:url(images/menu-glyph.png);
} }
.expando-glyph-container.closed .expando-glyph { .expando-glyph-container.closed .expando-glyph
{
background-repeat:none;
background-image:url(images/menu-glyph.png); background-image:url(images/menu-glyph.png);
background-position:0 3px; background-position:0 3px;
} }
.expando-glyph-container.closed .expando-glyph:hover { .expando-glyph-container.closed .expando-glyph:hover {
background-image:url(images/menu-glyph.png); background-image:url(images/menu-glyph.png);
} }
.expando-glyph-container.closing .expando-glyph { .expando-glyph-container.closing .expando-glyph
{
background-repeat:none;
-webkit-transition:all .2s ease-in-out; -webkit-transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out; -moz-transition:all .2s ease-in-out;
transition:all .2s ease-in-out; transition:all .2s ease-in-out;
@@ -198,7 +202,9 @@ h3:hover
-moz-transform:rotate(-90deg) translate(3px, -3px); -moz-transform:rotate(-90deg) translate(3px, -3px);
transform:rotate(-90deg) translate(3px, -3px); transform:rotate(-90deg) translate(3px, -3px);
} }
.expando-glyph-container.opening .expando-glyph { .expando-glyph-container.opening .expando-glyph
{
background-repeat:none;
-webkit-transition:all .2s ease-in-out; -webkit-transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out; -moz-transition:all .2s ease-in-out;
transition:all .2s ease-in-out; transition:all .2s ease-in-out;
@@ -16,11 +16,38 @@
<div class="content"> <div class="content">
<div class="shape"> <div class="shape">
Shape: @Model.ShapeType <br /> <ul class="properties">
Definition: @Model.Definition <br /> <li>
Display Type: @(Model.DisplayType ?? "n/a")<br /> <h3>
Position: @(Model.Position ?? "n/a") <br /> <div class="name">Shape</div>
Placement Source: @(Model.PlacementSource ?? "n/a") <br /> <div class="value">@Model.ShapeType</div>
</h3>
</li>
<li>
<h3>
<div class="name">Definition</div>
<div class="value">@Model.Definition</div>
</h3>
</li>
<li>
<h3>
<div class="name">Display Type</div>
<div class="value">@(String.IsNullOrEmpty((string)Model.DisplayType) ? T("n/a").Text : Model.DisplayType.ToString())</div>
</h3>
</li>
<li>
<h3>
<div class="name">Position</div>
<div class="value">@(String.IsNullOrEmpty((string)Model.Position) ? T("n/a").Text : Model.Position.ToString())</div>
</h3>
</li>
<li>
<h3>
<div class="name">Placement Source</div>
<div class="value">@(String.IsNullOrEmpty((string)Model.PlacementSource) ? T("n/a").Text : Model.PlacementSource.ToString())</div>
</h3>
</li>
</ul>
</div> </div>
<div class="model" style="display:none"> <div class="model" style="display:none">
@@ -9,7 +9,7 @@
} }
@using (Html.BeginFormAntiForgeryPost(Url.Action("Modules", "Gallery"))) { @using (Html.BeginFormAntiForgeryPost(Url.Action("Modules", "Gallery"))) {
<fieldset class="bulk-actions"> <fieldset class="bulk-actions bulk-actions-auto">
<label for="sourceId">@T("Feed:")</label> <label for="sourceId">@T("Feed:")</label>
<select id="sourceId" name="@Html.NameOf(m => m.Options.SourceId)"> <select id="sourceId" name="@Html.NameOf(m => m.Options.SourceId)">
@Html.SelectOption(Model.Options.SourceId, null, T("All feeds").ToString()) @Html.SelectOption(Model.Options.SourceId, null, T("All feeds").ToString())
@@ -27,7 +27,7 @@
@Html.SelectOption(Model.Options.Order, PackagingExtensionsOrder.Alphanumeric, T("Alphanumeric").ToString()) @Html.SelectOption(Model.Options.Order, PackagingExtensionsOrder.Alphanumeric, T("Alphanumeric").ToString())
</select> </select>
<button id="apply-bulk-actions" type="submit">@T("Apply")</button> <button id="apply-bulk-actions" class="apply-bulk-actions-auto" type="submit">@T("Apply")</button>
</fieldset> </fieldset>
<fieldset class="search-actions"> <fieldset class="search-actions">
@@ -9,7 +9,7 @@
} }
@using (Html.BeginFormAntiForgeryPost(Url.Action("Themes", "Gallery"))) { @using (Html.BeginFormAntiForgeryPost(Url.Action("Themes", "Gallery"))) {
<fieldset class="bulk-actions"> <fieldset class="bulk-actions bulk-actions-auto">
<label for="sourceId">@T("Show")</label> <label for="sourceId">@T("Show")</label>
<select id="sourceId" name="@Html.NameOf(m => m.Options.SourceId)"> <select id="sourceId" name="@Html.NameOf(m => m.Options.SourceId)">
@Html.SelectOption(Model.Options.SourceId, null, T("All feeds").ToString()) @Html.SelectOption(Model.Options.SourceId, null, T("All feeds").ToString())
@@ -27,7 +27,7 @@
@Html.SelectOption(Model.Options.Order, PackagingExtensionsOrder.Alphanumeric, T("Alphanumeric").ToString()) @Html.SelectOption(Model.Options.Order, PackagingExtensionsOrder.Alphanumeric, T("Alphanumeric").ToString())
</select> </select>
<button id="apply-bulk-actions" type="submit">@T("Apply")</button> <button id="apply-bulk-actions" class="apply-bulk-actions-auto" type="submit">@T("Apply")</button>
</fieldset> </fieldset>
<fieldset class="search-actions"> <fieldset class="search-actions">
@@ -57,15 +57,9 @@
} }
}); });
$(".bulk-actions").each(function () { $(".bulk-actions-auto select").change(function () {
$("select").each(function () { // form.submit() would be better as it wouldn't rely on an id,
$(this).change(function () { // but the form might rely on knowing which button was clicked.
var self = $(this); $("#apply-bulk-actions").click();
var form = self.closest("form");
// Submit form
form.submit();
});
});
}); });
})(jQuery); })(jQuery);
@@ -962,7 +962,7 @@ table.items th, table.items td {
.page-size-options select { .page-size-options select {
margin-top: 10px; margin-top: 10px;
} }
html.dyn #submit-pager, html.dyn #apply-bulk-actions { display:none; } html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; }
.pager { list-style: none; padding: 0; margin: 12px 0 0 0;} .pager { list-style: none; padding: 0; margin: 12px 0 0 0;}
.pager li { .pager li {
float: left; float: left;