diff --git a/CHANGELOG b/CHANGELOG index e40974192..06aedf03d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,21 +3,23 @@ === Edge * Simplify admin tab API [Jim Gay, John Long, Sean Cribbs] + +=== 0.9.0 RC1 (October 9, 2009) + +* Turned on HAML's "ugly" whitespace mode in production [John Muhl] +* Use HTML 5 doctype. [John Muhl] +* Miscellaneous HTML standards improvements [John Muhl] * Fixed bug where pages were being cached in dev mode. This has been a problem since switching to Rack::Cache. [Jason Garber] * Snippets are now only accessible to people with the "Designer" role. [John Long] * Renamed "Developer" role to "Designer". [John Long] -* Invoke sudo on unix systems when installing the gem using rake [John Long] -* Undefine prototype rake tasks in instance mode. [Sean Cribbs] * Verify that the cache directory exists before trying to store a response. [Sean Cribbs] * Fix page-part deletion in JS. [Sean Cribbs] * Don't cache extension-defined javascripts, but do cache the defaults. [Sean Cribbs] * Fix dev-site behavior when 'dev.host' is configured. [Chris Ricca] -* Use HTML 5 doctype. [John Muhl] * Concatenate admin javascript files. [John Muhl] * Use more descriptive page titles. [John Muhl] * Allow non-standard controller methods for render_region. [Jim Gay] * Updated to use Radius 0.6.1. [John Long] -* Use root_path instead of "/" on View Site link. [John Long] * Correct type on content-type and move to more/hide language. [John Long] * Add some helpful shortcut keys. [Sean Cribbs] * Implemented "Blade" user-interface. [John Long, Chris Parrish, Daniel Beach, Brandon Mathis, Sean Cribbs, Ben Morrow, John Muhl] diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 86f6af798..a32190ebc 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -5,6 +5,7 @@ core: === Edge +* Jason Garber * Chris Ricca * Jim Gay * John Muhl diff --git a/app/models/standard_tags.rb b/app/models/standard_tags.rb index a65c7117a..b2244183f 100644 --- a/app/models/standard_tags.rb +++ b/app/models/standard_tags.rb @@ -774,6 +774,10 @@ class TagError < StandardError; end page's URL * @selected@ specifies the state of the link when the current page matches is a child of the specified url + # @if_last@ renders its contents within a @normal@, @here@ or + @selected@ tag if the item is the last in the navigation elements + # @if_first@ renders its contents within a @normal@, @here@ or + @selected@ tag if the item is the first in the navigation elements The @between@ tag specifies what should be inserted in between each of the links. @@ -798,11 +802,13 @@ class TagError < StandardError; end key = parts.join(':') [key.strip, value.strip] end - pairs.each do |title, url| + pairs.each_with_index do |(title, url), i| compare_url = remove_trailing_slash(url) page_url = remove_trailing_slash(self.url) hash[:title] = title hash[:url] = url + tag.locals.first_child = i == 0 + tag.locals.last_child = i == pairs.length - 1 case page_url when compare_url result << (hash[:here] || hash[:selected] || hash[:normal]).call @@ -828,6 +834,30 @@ class TagError < StandardError; end end end + desc %{ + Renders the containing elements if the element is the first + in the navigation list + + *Usage:* + +
...
+ }
+ tag 'navigation:if_first' do |tag|
+ tag.expand if tag.locals.first_child
+ end
+
+ desc %{
+ Renders the containing elements if the element is the last
+ in the navigation list
+
+ *Usage:*
+
+ ...
+ }
+ tag 'navigation:if_last' do |tag|
+ tag.expand if tag.locals.last_child
+ end
+
desc %{
Renders the containing elements only if Radiant in is development mode.
diff --git a/app/views/admin/layouts/_form.html.haml b/app/views/admin/layouts/_form.html.haml
index 2e6a98504..b20bbd0f5 100644
--- a/app/views/admin/layouts/_form.html.haml
+++ b/app/views/admin/layouts/_form.html.haml
@@ -1,4 +1,4 @@
-- form_for [:admin, @layout], :html => {:onsubmit_status => onsubmit_status(@layout)} do |f|
+- form_for [:admin, @layout], :html => {'data-onsubmit_status' => onsubmit_status(@layout)} do |f|
= f.hidden_field :lock_version
= render_region :form_top
.form_area
diff --git a/app/views/admin/layouts/index.html.haml b/app/views/admin/layouts/index.html.haml
index ba4953e7e..3e90c864f 100644
--- a/app/views/admin/layouts/index.html.haml
+++ b/app/views/admin/layouts/index.html.haml
@@ -1,7 +1,7 @@
- @page_title = 'Layouts - ' + default_page_title
.outset
- - render_region :top
+ = render_region :top
%table#layouts.index
%thead
%tr
diff --git a/app/views/admin/layouts/remove.html.haml b/app/views/admin/layouts/remove.html.haml
index a6cc180af..ed5cf1443 100644
--- a/app/views/admin/layouts/remove.html.haml
+++ b/app/views/admin/layouts/remove.html.haml
@@ -9,7 +9,7 @@
= image('layout', :alt => '')
= h @layout.name
-- form_for [:admin, @layout], :html => { :method => 'delete', :onsubmit_status=>"Removing layout…" } do
+- form_for [:admin, @layout], :html => { :method => 'delete', 'data-onsubmit_status'=>"Removing layout…" } do
%p.buttons
%input.button{:type=>"submit", :value=>"Delete Layout"}/
or
diff --git a/app/views/admin/page_parts/_page_part.html.haml b/app/views/admin/page_parts/_page_part.html.haml
index 931d99798..01b8725bf 100644
--- a/app/views/admin/page_parts/_page_part.html.haml
+++ b/app/views/admin/page_parts/_page_part.html.haml
@@ -1,4 +1,4 @@
-.page{:id => "page_#{page_part.name.to_slug}", :"data-caption"=>h(page_part.name)}
+.page{:id => "page_#{page_part.name.to_slug}", 'data-caption'=>h(page_part.name)}
.part{:id => "part-#{page_part.name.to_slug}"}
= hidden_field_tag "page[parts_attributes][#{page_part_counter}][name]", page_part.name, :id => "part_#{page_part.name.to_slug}_name"
= hidden_field_tag "page[parts_attributes][#{page_part_counter}][id]", page_part.id, :id => "part_#{page_part_counter}_id", :class => "id_input"
diff --git a/app/views/admin/pages/_popups.html.haml b/app/views/admin/pages/_popups.html.haml
index df995132f..87fbfd146 100644
--- a/app/views/admin/pages/_popups.html.haml
+++ b/app/views/admin/pages/_popups.html.haml
@@ -6,7 +6,7 @@
%p
%label{:for => 'part_name_field'} Name
= f.text_field :name, :id => 'part_name_field', :maxlength => 100, :style => "width: 15em", :class => "textbox big"
- = hidden_field_tag 'index', @page.parts.size, :id => 'page_part_index_field'
+ = hidden_field_tag 'index', 0, :id => 'page_part_index_field'
%p.buttons
= submit_tag "Add Part", :id => 'add_part_button', :class => "button"
or
diff --git a/app/views/admin/pages/edit.html.haml b/app/views/admin/pages/edit.html.haml
index a8ac521c0..a14d3d819 100644
--- a/app/views/admin/pages/edit.html.haml
+++ b/app/views/admin/pages/edit.html.haml
@@ -6,9 +6,9 @@
- main.edit_header do
%h1 Edit Page
- main.edit_form do
- - form_for :page, @page, :url => admin_page_path(@page), :html => {:method => :put, :multipart => true, :id => 'edit_page'} do |fields|
+ - form_for :page, @page, :url => admin_page_path(@page), :html => {:method => :put, :multipart => true, :id => 'edit_page', 'data-onsubmit_status'=>"Saving Changes…"} do |fields|
= render :partial => "fields", :object => fields
- main.edit_popups do
= render :partial => "popups"
-- content_for 'page_scripts', page_edit_javascripts
\ No newline at end of file
+- content_for 'page_scripts', page_edit_javascripts
diff --git a/app/views/admin/pages/new.html.haml b/app/views/admin/pages/new.html.haml
index 0bc061951..2c9e0c479 100644
--- a/app/views/admin/pages/new.html.haml
+++ b/app/views/admin/pages/new.html.haml
@@ -4,9 +4,9 @@
- main.edit_header do
%h1 New Page
- main.edit_form do
- - form_for :page, @page, :url => admin_pages_path, :html => {:id => 'new_page', :multipart => true} do |f|
+ - form_for :page, @page, :url => admin_pages_path, :html => {:id => 'new_page', :multipart => true, 'data-onsubmit_status'=>"Creating page…"} do |f|
= render :partial => "fields", :object => f
- main.edit_popups do
= render :partial => "popups"
-- content_for 'page_scripts', page_edit_javascripts
\ No newline at end of file
+- content_for 'page_scripts', page_edit_javascripts
diff --git a/app/views/admin/pages/remove.html.haml b/app/views/admin/pages/remove.html.haml
index 8b595c1a3..2a3c64162 100644
--- a/app/views/admin/pages/remove.html.haml
+++ b/app/views/admin/pages/remove.html.haml
@@ -14,7 +14,7 @@
%tbody
= render_node @page, :simple => true
-- form_for [:admin, @page.becomes(Page)], :html => {:method => :delete, :onsubmit_status=>"Removing pages…"} do
+- form_for [:admin, @page.becomes(Page)], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing pages…"} do
%p.buttons
%input.button{:type=>"submit", :value=>"Delete Pages"}/
or
diff --git a/app/views/admin/preferences/edit.html.haml b/app/views/admin/preferences/edit.html.haml
index 8327b12fa..42317f054 100644
--- a/app/views/admin/preferences/edit.html.haml
+++ b/app/views/admin/preferences/edit.html.haml
@@ -6,7 +6,7 @@
- main.edit_header do
%h1 Personal Preferences
- main.edit_form do
- - form_for @user, :url => admin_preferences_url, :html => { :method => :put, :onsubmit_status => "Saving preferences…" } do |f|
+ - form_for @user, :url => admin_preferences_url, :html => { :method => :put, 'data-onsubmit_status' => "Saving preferences…" } do |f|
= render_region :form_top
- render_region :form do |form|
diff --git a/app/views/admin/snippets/_form.html.haml b/app/views/admin/snippets/_form.html.haml
index 2acb45bdc..4aae3bdd5 100644
--- a/app/views/admin/snippets/_form.html.haml
+++ b/app/views/admin/snippets/_form.html.haml
@@ -1,4 +1,4 @@
-- form_for [:admin, @snippet], :html => {:onsubmit_status => onsubmit_status(@snippet)} do |f|
+- form_for [:admin, @snippet], :html => {'data-onsubmit_status' => onsubmit_status(@snippet)} do |f|
= f.hidden_field :lock_version
= render_region :form_top
.form_area
diff --git a/app/views/admin/snippets/index.html.haml b/app/views/admin/snippets/index.html.haml
index ffe6d98a1..e6f5b35c5 100644
--- a/app/views/admin/snippets/index.html.haml
+++ b/app/views/admin/snippets/index.html.haml
@@ -1,7 +1,7 @@
- @page_title = 'Snippets - ' + default_page_title
.outset
- - render_region :top
+ = render_region :top
%table#snippets.index
%thead
%tr
diff --git a/app/views/admin/snippets/remove.html.haml b/app/views/admin/snippets/remove.html.haml
index f6a65da27..f849cc3d4 100644
--- a/app/views/admin/snippets/remove.html.haml
+++ b/app/views/admin/snippets/remove.html.haml
@@ -12,7 +12,7 @@
= image('snippet', :alt => "")
%span.title= @snippet.name
-- form_for [:admin, @snippet], :html => {:method => :delete, :onsubmit_status=>"Removing snippet…"} do
+- form_for [:admin, @snippet], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing snippet…"} do
%p.buttons
%input.button{:type=>"submit", :value=>"Delete Snippet"}/
or
diff --git a/app/views/admin/users/remove.html.haml b/app/views/admin/users/remove.html.haml
index 5c6844847..4c8fb60a3 100644
--- a/app/views/admin/users/remove.html.haml
+++ b/app/views/admin/users/remove.html.haml
@@ -11,7 +11,7 @@
%td.user
%span.title= @user.name
-- form_for [:admin, @user], :html => { :method => :delete, :onsubmit_status=>"Removing user…" } do
+- form_for [:admin, @user], :html => { :method => :delete, 'data-onsubmit_status'=>"Removing user…" } do
%p.buttons
%input.button{:type=>"submit", :value=>"Delete User"}/
or
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index f73ba0c3a..b3e597613 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -1,7 +1,7 @@
-
-%html{html_attrs}
+!!!
+%html{:lang=>"en-US"}
%head
- %meta{"http-equiv"=>"Content-type", :content=>"text/html;charset=utf-8"}/
+ %meta{:charset=>"utf-8"}/
%title= @page_title || default_page_title
- @stylesheets.uniq.each do |stylesheet|
= stylesheet_link_tag stylesheet
diff --git a/config/environment.rb b/config/environment.rb
index 3bc2658be..a96ef9ab6 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -75,4 +75,7 @@
inflect.uncountable 'config'
end
end
-end
\ No newline at end of file
+end
+
+Haml::Template.options[:format] = :html5
+Haml::Template.options[:ugly] = true if ENV['RAILS_ENV'] == 'production'
diff --git a/lib/generators/instance/templates/instance_environment.rb b/lib/generators/instance/templates/instance_environment.rb
index 488c9746f..d48d9e807 100644
--- a/lib/generators/instance/templates/instance_environment.rb
+++ b/lib/generators/instance/templates/instance_environment.rb
@@ -75,4 +75,7 @@
inflect.uncountable 'config'
end
end
-end
\ No newline at end of file
+end
+
+Haml::Template.options[:format] = :html5
+Haml::Template.options[:ugly] = true if ENV['RAILS_ENV'] == 'production'
diff --git a/lib/radiant/admin_ui.rb b/lib/radiant/admin_ui.rb
index 469722dfd..2dc6e10ca 100644
--- a/lib/radiant/admin_ui.rb
+++ b/lib/radiant/admin_ui.rb
@@ -209,7 +209,6 @@ def load_default_snippet_regions
edit.form_bottom.concat %w{edit_buttons edit_timestamp}
end
snippet.index = RegionSet.new do |index|
- index.top.concat %w{help_text}
index.thead.concat %w{title_header modify_header}
index.tbody.concat %w{title_cell modify_cell}
index.bottom.concat %w{new_button}
@@ -226,7 +225,6 @@ def load_default_layout_regions
edit.form_bottom.concat %w{edit_buttons edit_timestamp}
end
layout.index = RegionSet.new do |index|
- index.top.concat %w{help_text}
index.thead.concat %w{title_header modify_header}
index.tbody.concat %w{title_cell modify_cell}
index.bottom.concat %w{new_button}
diff --git a/lib/radiant/extension/script.rb b/lib/radiant/extension/script.rb
index 4998c4c01..6019d2e98 100644
--- a/lib/radiant/extension/script.rb
+++ b/lib/radiant/extension/script.rb
@@ -31,6 +31,12 @@ class Action
def rake(command)
`rake #{command} RAILS_ENV=#{RAILS_ENV}`
end
+
+ def file_utils
+ FileUtils
+ end
+
+ delegate :cd, :cp_r, :rm_r, :to => :file_utils
end
class Installer < Action
@@ -46,8 +52,8 @@ def install
end
def copy_to_vendor_extensions
- FileUtils.cp_r(self.path, File.expand_path(File.join(RAILS_ROOT, 'vendor', 'extensions', name)))
- FileUtils.rm_r(self.path)
+ cp_r(self.path, File.expand_path(File.join(RAILS_ROOT, 'vendor', 'extensions', name)))
+ rm_r(self.path)
end
def migrate
@@ -75,7 +81,7 @@ def migrate_down
end
def remove_extension_directory
- FileUtils.rm_r(File.join(RAILS_ROOT, 'vendor', 'extensions', name))
+ rm_r(File.join(RAILS_ROOT, 'vendor', 'extensions', name))
end
end
@@ -95,7 +101,7 @@ def install
def checkout
self.path = File.join(Dir.tmpdir, name)
- system "cd #{Dir.tmpdir}; #{checkout_command}"
+ cd(Dir.tmpdir) { system "#{checkout_command}" }
end
end
@@ -136,10 +142,14 @@ def checkout_command
def checkout
if project_in_git?
system "git submodule add #{url} vendor/extensions/#{name}"
- system "cd vendor/extensions/#{name}; git submodule init && git submodule update"
+ cd(File.join('vendor', 'extensions', name)) do
+ system "git submodule init && git submodule update"
+ end
else
super
- system "cd #{path}; git submodule init && git submodule update"
+ cd(path) do
+ system "git submodule init && git submodule update"
+ end
end
end
@@ -166,7 +176,10 @@ def download
end
def unpack
- output = `cd #{Dir.tmpdir}; gem unpack #{filename.split('-').first}`
+ output = nil
+ cd(Dir.tmpdir) do
+ output = `gem unpack #{filename.split('-').first}`
+ end
self.path = output.match(/'(.*)'/)[1]
end
end
@@ -177,7 +190,8 @@ def filename
end
def unpack
- output = `cd #{Dir.tmpdir}; tar xvf #{filename}`
+ output = nil
+ cd(Dir.tmpdir) { output = `tar xvf #{filename}` }
self.path = File.join(Dir.tmpdir, output.split(/\n/).first.split('/').first)
end
end
@@ -188,7 +202,7 @@ def filename
end
def unpack
- system "cd #{Dir.tmpdir}; gunzip #{self.filename}"
+ cd(Dir.tmpdir) { system "gunzip #{self.filename}" }
@unpacked = true
super
end
@@ -200,7 +214,7 @@ def filename
end
def unpack
- system "cd #{Dir.tmpdir}; bunzip2 #{self.filename}"
+ cd(Dir.tmpdir) { system "bunzip2 #{self.filename}" }
@unpacked = true
super
end
@@ -208,7 +222,8 @@ def unpack
class Zip < Download
def unpack
- output = `cd #{Dir.tmpdir}; unzip #{filename} -d #{name}`
+ output = nil
+ cd(Dir.tmpdir) { output = `unzip #{filename} -d #{name}` }
self.path = File.join(Dir.tmpdir, name)
end
end
diff --git a/public/javascripts/admin/codearea.js b/public/javascripts/admin/codearea.js
index 79e36d959..f3fb0a6a8 100644
--- a/public/javascripts/admin/codearea.js
+++ b/public/javascripts/admin/codearea.js
@@ -1,5 +1,6 @@
-// Based on code from:
+// Originally based on code from:
// http://ajaxian.com/archives/handling-tabs-in-textareas
+
var CodeAreaBehavior = Behavior.create({
initialize: function() {
new CodeArea(this.element);
@@ -15,52 +16,150 @@ var CodeArea = Class.create({
onkeydown: function(event) {
// Set desired tab - defaults to two space softtab
var tab = " ";
+ var tabStop = tab.length;
- var t = event.target;
- var ss = t.selectionStart;
- var se = t.selectionEnd;
+ var t = this.element;
- // Tab key - insert tab expansion
- if (event.keyCode == 9) {
- event.preventDefault();
- if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
- // Special case of multi line selection
- // In case selection was not of entire lines (e.g. selection begins in the middle of a line)
- // we ought to tab at the beginning as well as at the start of every following line.
- var pre = t.value.slice(0,ss);
- var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab);
- var post = t.value.slice(se,t.value.length);
- t.value = pre.concat(tab).concat(sel).concat(post);
- t.selectionStart = ss + tab.length;
- t.selectionEnd = se + tab.length;
- } else {
- // "Normal" case (no selection or selection on one line only)
- t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length));
- if (ss == se) {
- t.selectionStart = t.selectionEnd = ss + tab.length;
+ if (Prototype.Browser.IE) {
+ // Very limited support for IE
+
+ if (event.keyCode == Event.KEY_TAB && !event.shiftKey) {
+ event.preventDefault();
+ document.selection.createRange().text = tab;
+ }
+
+ } else {
+ // Safari and Firefox
+
+ // If this is the tab key, make the selection start at the begining and end of lines for
+ // multi-line selections
+ if (event.keyCode == Event.KEY_TAB) this.normalizeSelection(t);
+
+ var ss = t.selectionStart;
+ var se = t.selectionEnd;
+
+ if (event.keyCode == Event.KEY_TAB) {
+ // Tab key
+
+ event.preventDefault();
+
+ if (event.shiftKey) {
+ // Shift + Tab
+
+ if (t.value.slice(ss,se).indexOf("\n") != -1) {
+ // Special case of multi line selection
+
+ var pre = t.value.slice(0, ss)
+ var sel = t.value.slice(ss, se)
+ var post = t.value.slice(se, t.value.length);
+
+ // Back off one tab
+ sel = sel.replace(new RegExp("^" + tab, "gm"), '')
+
+ // Put everything back together
+ t.value = pre.concat(sel).concat(post);
+
+ // Readjust the selection
+ t.selectionStart = pre.length;
+ t.selectionEnd = pre.length + sel.length;
+
+ } else {
+ // "Normal" case (no selection or selection on one line only)
+
+ if (t.value.slice(ss - tabStop, ss) == tab) {
+ // Only unindent if there is a tab before the cursor
+
+ t.value = t.value.slice(0, ss - tabStop).concat(t.value.slice(ss, t.value.length));
+ t.selectionStart = ss - tabStop;
+ t.selectionEnd = se - tabStop;
+ }
+ }
} else {
- t.selectionStart = ss + tab.length;
- t.selectionEnd = se + tab.length;
+ // Tab
+
+ if (ss != se && t.value.slice(ss, se).indexOf("\n") != -1) {
+ // Special case of multi line selection
+
+ // In case selection was not of entire lines (e.g. selection begins in the middle of a line)
+ // we ought to tab at the beginning as well as at the start of every following line.
+ var pre = t.value.slice(0, ss);
+ var sel = t.value.slice(ss, se);
+ var post = t.value.slice(se, t.value.length);
+
+ // Indent one tab
+ sel = sel.replace(/^/gm, tab)
+
+ // Put everything back together
+ t.value = pre.concat(sel).concat(post);
+
+ // Readjust the selection
+ t.selectionStart = pre.length;
+ t.selectionEnd = pre.length + sel.length;
+
+ } else {
+ // "Normal" case (no selection or selection on one line only)
+
+ t.value = t.value.slice(0, ss).concat(tab).concat(t.value.slice(ss, t.value.length));
+ if (ss == se) {
+ t.selectionStart = t.selectionEnd = ss + tabStop;
+ } else {
+ t.selectionStart = ss + tabStop;
+ t.selectionEnd = se + tabStop;
+ }
+ }
}
+
+ } else if (event.keyCode == Event.KEY_BACKSPACE && ss == se && t.value.slice(ss - tabStop, ss) == tab) {
+ // Backspace - delete preceding tab expansion, if it exists and nothing is selected
+
+ event.preventDefault();
+ t.value = t.value.slice(0, ss - tabStop).concat(t.value.slice(ss, t.value.length));
+ t.selectionStart = ss - tabStop;
+ t.selectionEnd = se - tabStop;
+
+ } else if (event.keyCode == Event.KEY_DELETE && t.value.slice(se, se + tabStop) == tab) {
+ // Delete key - delete following tab expansion, if exists
+
+ event.preventDefault();
+ t.value = t.value.slice(0, ss).concat(t.value.slice(ss + tabStop ,t.value.length));
+ t.selectionStart = t.selectionEnd = ss;
+
+ } else if (event.keyCode == Event.KEY_LEFT && t.value.slice(ss - tabStop, ss) == tab) {
+ // Left arrow - move across the tab in one go
+
+ event.preventDefault();
+ t.selectionStart = t.selectionEnd = ss - tabStop;
+ } else if (event.keyCode == Event.KEY_RIGHT && t.value.slice(ss, ss + tabStop) == tab) {
+ // Left/right arrow - move across the tab in one go
+
+ event.preventDefault();
+ t.selectionStart = t.selectionEnd = ss + tabStop;
+
}
- } else if (event.keyCode == Event.KEY_BACKSPACE && t.value.slice(ss - tab.length,ss) == tab) {
- // Backspace key - delete preceding tab expansion, if exists
- event.preventDefault();
- t.value = t.value.slice(0,ss - tab.length).concat(t.value.slice(ss,t.value.length));
- t.selectionStart = t.selectionEnd = ss - tab.length;
- } else if (event.keyCode == Event.KEY_DELETE && t.value.slice(se,se + tab.length) == tab) {
- // Delete key - delete following tab expansion, if exists
- event.preventDefault();
- t.value = t.value.slice(0,ss).concat(t.value.slice(ss + tab.length,t.value.length));
- t.selectionStart = t.selectionEnd = ss;
- } else if (event.keyCode == Event.KEY_LEFT && t.value.slice(ss - tab.length,ss) == tab) {
- // Left arrow key - move across the tab in one go
- event.preventDefault();
- t.selectionStart = t.selectionEnd = ss - tab.length;
- } else if (event.keyCode == Event.KEY_RIGHT && t.value.slice(ss,ss + tab.length) == tab) {
- // Left/right arrow keys - move across the tab in one go
- event.preventDefault();
- t.selectionStart = t.selectionEnd = ss + tab.length;
+ }
+ },
+
+ normalizeSelection: function(textarea) {
+ var b = 0;
+ var value = textarea.value;
+ var e = textarea.length;
+ var ss = textarea.selectionStart;
+ var se = textarea.selectionEnd;
+
+ if (ss != se && textarea.value.slice(ss, se).indexOf("\n") != -1) {
+ // If multi-line adjust the selection
+
+ // If the end of the line is selected back off one character
+ if (textarea.value.slice(se - 1, se) == "\n") se = se - 1;
+
+ // If the selection does not end with a new line or the end of the document increment until it does
+ while ((se < e) && (textarea.value.slice(se, se + 1) != "\n")) se += 1;
+
+ // If the selection does not begin at a new line or the begining of the document back off until it does
+ while ((ss > b) && (textarea.value.slice(ss - 1, ss) != "\n")) ss -= 1;
+
+ textarea.selectionStart = ss;
+ textarea.selectionEnd = se;
}
}
});
\ No newline at end of file
diff --git a/public/javascripts/admin/status.js b/public/javascripts/admin/status.js
index ea89d35b0..5a7df3dfd 100644
--- a/public/javascripts/admin/status.js
+++ b/public/javascripts/admin/status.js
@@ -10,10 +10,10 @@
*
* Event.addBehavior({'form': Status.FormBehavior()});
*
- * And then add an "onsubmit_status" to each form that you want to display
+ * And then add an "data-onsubmit_status" to each form that you want to display
* a status message on submit for:
*
- *