Skip to content

Commit

Permalink
Fixed odd behavior of buttons with journal. Buttons now grouped and s…
Browse files Browse the repository at this point in the history
…tay in bottom right.
  • Loading branch information
hallahan committed May 12, 2012
1 parent f804dbe commit 2687bf6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
15 changes: 10 additions & 5 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
remove: '✕'
};
addToJournal = wiki.addToJournal = function(journalElement, action) {
var actionElement, actionTitle, pageElement, prev;
var actionElement, actionTitle, controls, pageElement, prev;
pageElement = journalElement.parents('.page:first');
if (action.type === 'edit') {
prev = journalElement.find(".edit[data-id=" + (action.id || 0) + "]");
Expand All @@ -439,7 +439,13 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
if (action.date != null) {
actionTitle += ": " + (util.formatDate(action.date));
}
actionElement = $("<a href=\"\#\" /> ").addClass("action").addClass(action.type).text(wiki.symbols[action.type]).attr('title', actionTitle).attr('data-id', action.id || "0").appendTo(journalElement);
actionElement = $("<a href=\"\#\" /> ").addClass("action").addClass(action.type).text(wiki.symbols[action.type]).attr('title', actionTitle).attr('data-id', action.id || "0");
controls = journalElement.children('.control-buttons');
if (controls.length > 0) {
actionElement.insertBefore(controls);
} else {
actionElement.appendTo(journalElement);
}
if (action.type === 'fork') {
return actionElement.css("background-image", "url(//" + action.site + "/favicon.png)").attr("href", "//" + action.site + "/" + (pageElement.attr('id')) + ".html").data("site", action.site).data("slug", pageElement.attr('id'));
}
Expand Down Expand Up @@ -1286,7 +1292,7 @@ require.define("/lib/refresh.coffee", function (require, module, exports, __dirn
var buildPage, pageElement;
pageElement = $(this);
buildPage = function(data) {
var action, addContext, context, controlButtons, footerElement, journalElement, page, site, slug, storyElement, _i, _len, _ref, _ref2;
var action, addContext, context, footerElement, journalElement, page, site, slug, storyElement, _i, _len, _ref, _ref2;
if (!(data != null)) {
pageElement.find('.item').each(function(i, each) {
var item;
Expand Down Expand Up @@ -1328,8 +1334,7 @@ require.define("/lib/refresh.coffee", function (require, module, exports, __dirn
$.each(page.journal, function(i, action) {
return wiki.addToJournal(journalElement, action);
});
controlButtons = "<div class=\"control-buttons\"> <a href=\"#\" class=\"button add-factory\" title=\"add paragraph\">" + wiki.symbols['add'] + "</a> <a href=\"#\" class=\"button fork-page\" title=\"fork this page\">" + wiki.symbols['fork'] + "</a> </div>";
journalElement.append(controlButtons);
journalElement.append("<div class=\"control-buttons\">\n <a href=\"#\" class=\"button fork-page\" title=\"fork this page\">" + wiki.symbols['fork'] + "</a>\n <a href=\"#\" class=\"button add-factory\" title=\"add paragraph\">" + wiki.symbols['add'] + "</a>\n</div>");
footerElement.append('<a id="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a> . ').append("<a class=\"show-page-source\" href=\"/" + slug + ".json?random=" + (util.randomBytes(4)) + "\" title=\"source\">JSON</a>");
state.setUrl();
}
Expand Down
6 changes: 5 additions & 1 deletion client/lib/legacy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ $ ->
.text(wiki.symbols[action.type])
.attr('title',actionTitle)
.attr('data-id', action.id || "0")
.appendTo(journalElement)
controls = journalElement.children('.control-buttons')
if controls.length > 0
actionElement.insertBefore(controls)
else
actionElement.appendTo(journalElement)
if action.type == 'fork'
actionElement
.css("background-image", "url(//#{action.site}/favicon.png)")
Expand Down
12 changes: 6 additions & 6 deletions client/lib/refresh.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ module.exports = refresh = wiki.refresh = ->
$.each page.journal, (i, action) ->
wiki.addToJournal journalElement, action

controlButtons = "<div class=\"control-buttons\">
<a href=\"#\" class=\"button add-factory\" title=\"add paragraph\">#{wiki.symbols['add']}</a>
<a href=\"#\" class=\"button fork-page\" title=\"fork this page\">#{wiki.symbols['fork']}</a>
</div>"
journalElement.append(controlButtons)

journalElement.append """

This comment has been minimized.

Copy link
@hallahan

hallahan May 12, 2012

Author Owner

It has occurred to me that this functionality of coffee-script takes away the need of a templating library. Maybe we should consider this sort of styling for view related code. It may be a good idea to have a file just for view construction in a format similar to this.

<div class="control-buttons">
<a href="#" class="button fork-page" title="fork this page">#{wiki.symbols['fork']}</a>
<a href="#" class="button add-factory" title="add paragraph">#{wiki.symbols['add']}</a>
</div>
"""
footerElement
.append('<a id="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a> . ')
.append("<a class=\"show-page-source\" href=\"/#{slug}.json?random=#{util.randomBytes(4)}\" title=\"source\">JSON</a>")
Expand Down
22 changes: 13 additions & 9 deletions client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ footer {
width: 100%; }

.journal {
width: 420px;
overflow-x: hidden;
margin-top: 2px;
clear: both;
background-color: #eeeeee;
Expand All @@ -85,8 +87,11 @@ footer {
width: 18px; }

.control-buttons {
white-space: nowrap;
}
float: right;
position: relative;
right: 5px;
overflow-x: visible;
white-space: nowrap; }

.button {
/*from bootstrap*/
Expand Down Expand Up @@ -115,16 +120,15 @@ footer {
display: inline-block;
white-space: normal;
position: relative;
bottom: 1px;
right: 1px;
top: 2px;
left: 3px;
font-size: 0.9em;
text-align: center;
text-decoration: none;
padding: 0.2em;
margin: 2px;
margin-bottom: 2px;
color: #2c3f39;
float: right;
width: 17px; }
width: 18px; }

.button:hover {
color: #d9a513;
Expand Down Expand Up @@ -166,8 +170,8 @@ p.readout {
.page {
float: left;
margin: 8px;
padding: 0 30px;
width: 436px;
padding: 0 31px;
width: 430px;
background-color: white;
height: 100%;
overflow: auto;
Expand Down

0 comments on commit 2687bf6

Please sign in to comment.