Permalink
Browse files

merging experimental

  • Loading branch information...
natew committed Apr 3, 2012
1 parent 0326a7e commit a3655b9ec343f496b9ed60fae968119db94a033c
@@ -1,102 +1,65 @@
$(function() {
- // Auto-expanding height for editor textareas
- var title = document.getElementById('text-title'),
- content = document.getElementById('text-content'),
- preview = false,
- saveInterval = 5000;
+ // Auto-expanding height for editor textareas
+ var title = document.getElementById('text-title'),
+ content = document.getElementById('text-content'),
+ preview = false;
- // If we're on the edit page
- if (title) {
- var changed = false;
+ // If we're on the edit page
+ if (title) {
+ var changed = false;
- // Auto expanding textareas. See _functions.js
- makeExpandingArea(title);
- makeExpandingArea(content);
+ // Auto expanding textareas. See _functions.js
+ makeExpandingArea(title);
+ makeExpandingArea(content);
- // Scroll window as we edit long posts
- $('#post_content').bind('keyup', function() {
- var $this = $(this),
- bottom = $this.offset().top + $this.height();
+ // Scroll window as we edit long posts
+ $('#post_content').bind('keyup', function() {
+ var $this = $(this),
+ bottom = $this.offset().top + $this.height();
- if (bottom > $(window).scrollTop() &&
- $this.prop("selectionStart") > ($this.val().length - $this.val().split('\n').slice(-1)[0].length)) {
- $(window).scrollTop(bottom);
- }
- });
-
- // Preview button
- $('#preview-button').click(function(e){
- e.preventDefault();
- if (preview) {
- $('#split').removeClass('preview');
- preview = false;
- } else {
- updatePreview();
- $('#split').addClass('preview');
- preview = true;
- }
- });
-
- // Set minimum height of content textarea
- $('#post_content').css('min-height', $(window).height() - $('#post_title').height() - 130);
-
- // Autosave and post preview
- $('#post_content,#post_title').bind('keyup', function(){
- changed = true;
- $('#save-button').val('Save').removeClass('saved').attr('disabled','');
-
- if (preview) {
- updatePreview();
- }
- });
-
- // Autosave
- setInterval(function(){
- if (changed) {
- changed = false;
- savePost();
- }
- }, saveInterval);
+ if (bottom > $(window).scrollTop() &&
+ $this.prop("selectionStart") > ($this.val().length - $this.val().split('\n').slice(-1)[0].length)) {
+ $(window).scrollTop(bottom);
+ }
+ });
- // Ajax save-button
- $('#save-button').click(function(){
- savePost();
- });
+ // Set minimum height of content textarea
+ $('#post_content').css('min-height', $(window).height() - $('#post_title').height() - 130);
- // // Preview pops open new window
- // var $form = $('form:first'),
- // original_action = $form.attr('action');
- // $('#preview-button').click(function(e) {
- // if (validateTitle()) {
- // $form.attr('action', '/preview');
- // $form.attr('target', '_blank');
- // $form.submit();
- // } else {
- // e.preventDefault();
- // }
- // });
+ // Preview pops open new window
+ var $form = $('form:first'),
+ original_action = $form.attr('action');
+ $('#preview-button').click(function(e) {
+ if (validateTitle()) {
+ $form.attr('action', '/preview');
+ $form.attr('target', '_blank');
+ $form.submit();
+ } else {
+ e.preventDefault();
+ }
+ });
- // Save button validates
- $('#save-button').click(function(e) {
- if (validateTitle()) {
- $form.attr('target', '_self');
- $form.attr('action', original_action);
- $form.submit();
+ // Save button validates
+ $('#save-button').click(function(e) {
+ if (validateTitle()) {
+ $form.attr('target', '_self');
+ $form.attr('action', original_action);
+ $form.submit();
} else {
- e.preventDefault();
+ e.preventDefault();
}
- });
+ });
- // Options menu
- $('.menu').toggle(function(){
- $(this).addClass('active');
- $($(this).attr('href')).addClass('visible');
- }, function() {
- $(this).removeClass('active');
- $($(this).attr('href')).removeClass('visible');
- });
+ // Options menu
+ $('.menu').toggle(function(){
+ $(this).addClass('active');
+ $($(this).attr('href')).addClass('visible');
+ }, function() {
+ $(this).removeClass('active');
+ $($(this).attr('href')).removeClass('visible');
+ });
- // Fade out save post notice
- $('.notice').delay(2000).fadeOut(500);
- }
+ // Fade out save post notice
+ $('.notice').delay(2000).fadeOut(500);
+ }
});
@@ -14,5 +14,4 @@
//= require jquery_ujs
//= require fitvids.js
//= require posts.js
-//= require showdown
//= require_tree ./admin
@@ -568,13 +568,4 @@ nav.pagination {
nav.pagination a {
margin-left: 10px;
- }
-
-span.experimental {
- position: absolute;
- top: 0;
- right: 10px;
- font-size: 11px;
- color: #999;
- z-index: 10000;
-}
+ }
@@ -8,7 +8,6 @@
</head>
<body class="admin <%= controller_name %> <%= action_name %>">
- <span class="experimental"><strong>Experimental branch</strong>! Watch out for bugs!</span>
<div id="admin">
<div id="save"></div>
<% if notice %><span class="notice"><%= notice %></span><% end %>

0 comments on commit a3655b9

Please sign in to comment.