Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cool JS toggle for edit mode

  • Loading branch information...
commit d30d8ca1ae6293ac0d19f9ad7663ff06d4427f52 1 parent 5b5a48d
myfreeweb authored
Showing with 27 additions and 3 deletions.
  1. +14 −1 views/js.haml
  2. +1 −1  views/pages.haml
  3. +12 −1 views/screen.sass
View
15 views/js.haml
@@ -1,5 +1,18 @@
+%script{:type => "text/javascript", :src => "/$dom.js"}
+- if @cur_page
+ :javascript
+ $dom.addClass($dom.get('article form')[0], 'hidden');
+ var editlink = $dom.create('a'), bd = $dom.get('#body')[0], af = $dom.get('article form')[0];
+ editlink.innerHTML = 'edit';
+ editlink.href = 'javascript:void(0)';
+ editlink.onclick = function() {
+ $dom.toggleClass(bd, 'hidden', !$dom.hasClass(bd, 'hidden'));
+ $dom.toggleClass(af, 'hidden', !$dom.hasClass(af, 'hidden'));
+ if (editlink.innerHTML == 'edit') editlink.innerHTML = 'cancel'
+ else editlink.innerHTML = 'edit';
+ }
+ $dom.get('article header')[0].appendChild(editlink);
- if flash
- %script{:type => "text/javascript", :src => "/$dom.js"}
:javascript
if (!Array.prototype.forEach) {Array.prototype.forEach = function(fun){var len=this.length;
if (typeof fun!="function") throw new TypeError();
View
2  views/pages.haml
@@ -15,7 +15,7 @@
%header
%h1= @cur_page[:name]
%a{:href => "/pages/#{@cur_page[:name]}/delete"} delete
- = wikify(@cur_page)
+ %section#body= wikify(@cur_page)
%form{:method => "post", :action => ""}
%textarea{:name => "text"}= @cur_page[:text]
%button{:type => "submit"} Save
View
13 views/screen.sass
@@ -1,5 +1,6 @@
@import compass/reset
@import compass/utilities
+@import compass/utilities/general/min
@import compass/utilities/general/clearfix
@import compass/utilities/links/hover-link
@import compass/utilities/links/link-colors
@@ -40,6 +41,9 @@ body > header
background: #d00
color: #fdfdfd
+.hidden
+ display: none
+
.page
#wrapper
+display-box
@@ -52,9 +56,16 @@ body > header
+unstyled-link
article
line-height: 1.35em
+ +box-flex(4)
p
margin-bottom: 1em
- +box-flex(4)
+ textarea
+ display: block
+ width: 90%
+ +min-height(20em)
+ margin: 0 auto
+ button
+ margin: 1em 0 0 5%
header
text-align: right
border-bottom: #a2a2a2 dashed 1px
Please sign in to comment.
Something went wrong with that request. Please try again.