chiliproject_side_by_side_wiki_edit 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ === 0.1.1 2012-12-06
2
+
3
+ * 1 enhancement:
4
+ * Layout is now managed by toggling classes on elements instead of
5
+ overriding styles inline through javascript
6
+
7
+ * 1 bug fix:
8
+ * The plugin is now also enabled when creating new wiki pages
9
+
1
10
  === 0.1.0 2012-09-28
2
11
 
3
12
  * 1 major enhancement:
@@ -1,20 +1,19 @@
1
- jQuery(function() {
2
- var $ = jQuery;
1
+ jQuery(function($) {
3
2
  var editor = $('textarea.wiki-edit');
3
+ var editor_parent = editor.parentsUntil('p').parent();
4
4
  var preview = $('div#preview');
5
5
  var preview_link = $('input[name=commit]').next();
6
6
 
7
- var disable = function() {
8
- editor.parentsUntil('p').parent().removeAttr('style');
9
- preview.removeAttr('style');
7
+ var disable_side_by_side_mode = function() {
8
+ editor_parent.add(preview).removeClass('side_by_side');
9
+ editor.off('scroll');
10
10
  $('#content').append(preview);
11
11
  };
12
12
 
13
- var enable = function() {
14
- var editorParent = editor.parentsUntil('p').parent();
13
+ var enable_side_by_side_mode = function() {
14
+ editor_parent.add(preview).addClass('side_by_side');
15
15
 
16
- editorParent.css('width', '49%').before(preview);
17
- preview.css({ 'float': 'right', 'width': '49%', 'margin-top': '5ex', 'overflow-y': 'scroll' });
16
+ editor_parent.before(preview);
18
17
  preview.height(editor.height() + 5);
19
18
 
20
19
  editor.scroll(preview, scroll_preview);
@@ -30,17 +29,17 @@ jQuery(function() {
30
29
  var target = $(event.data);
31
30
 
32
31
  target.scrollTop(source_position * (target[0].scrollHeight - target.innerHeight()));
33
- }
32
+ };
34
33
 
35
- var toggle_mode = function() {
34
+ var toggle_side_by_side_mode = function() {
36
35
  if(this.checked) {
37
- enable();
36
+ enable_side_by_side_mode();
38
37
  } else {
39
- disable();
38
+ disable_side_by_side_mode();
40
39
  }
41
- }
40
+ };
42
41
 
43
42
  preview_link.after($('<label for="side_by_side_mode">Show editor and preview side-by-side</label>'))
44
43
  .after($('<input id="side_by_side_mode" type="checkbox" />'));
45
- $('#side_by_side_mode').on('click', toggle_mode);
44
+ $('#side_by_side_mode').click(toggle_side_by_side_mode);
46
45
  });
@@ -0,0 +1,9 @@
1
+ .side_by_side {
2
+ width: 49.5%;
3
+ }
4
+
5
+ #preview.side_by_side {
6
+ float: right;
7
+ margin-top: 5ex;
8
+ overflow-y: scroll;
9
+ }
@@ -2,10 +2,25 @@ module ChiliprojectSideBySideWikiEdit
2
2
  module Hooks
3
3
  class ViewWikiEditHook < Redmine::Hook::ViewListener
4
4
  def view_layouts_base_html_head(context = {})
5
- if context[:controller] && context[:controller].is_a?(WikiController) && (context[:controller].action_name == 'edit')
6
- javascript_include_tag '/plugin_assets/chiliproject_side_by_side_wiki_edit/javascripts/side_by_side_edit.js'
5
+ if wiki_controller?(context) && extendable_action?(context)
6
+ asset_path = '/plugin_assets/chiliproject_side_by_side_wiki_edit'
7
+ [
8
+ javascript_include_tag("#{asset_path}/javascripts/side_by_side_edit.js"),
9
+ stylesheet_link_tag("#{asset_path}/stylesheets/side_by_side_edit.css")
10
+ ]
7
11
  end
8
12
  end
13
+
14
+ def extendable_action?(context)
15
+ # For some reason ChiliProject uses the show action instead of the new
16
+ # action to create new wiki pages. This does mean that the javascript
17
+ # and stylesheets get loaded on regular wiki pages as well
18
+ context[:controller] && ['show', 'edit'].include?(context[:controller].action_name)
19
+ end
20
+
21
+ def wiki_controller?(context)
22
+ context[:controller] && context[:controller].is_a?(WikiController)
23
+ end
9
24
  end
10
25
  end
11
26
  end
@@ -1,3 +1,3 @@
1
1
  module ChiliprojectSideBySideWikiEdit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -3,10 +3,6 @@ require 'rake/tasklib'
3
3
 
4
4
  class ChiliprojectSideBySideWikiEditTasks < Rake::TaskLib
5
5
  def initialize
6
- define
7
- end
8
-
9
- def define
10
6
  namespace :chiliproject_side_by_side_wiki_edit do
11
7
  desc "Install ChiliprojectSideBySideWikiEdit plugin (include assets, etc)"
12
8
  task :install => [:symlink_assets]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chiliproject_side_by_side_wiki_edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-28 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Allows side by side editor/preview functionality for ChiliProject wiki
15
15
  pages
@@ -27,6 +27,7 @@ files:
27
27
  - README.md
28
28
  - Rakefile
29
29
  - assets/javascripts/side_by_side_edit.js
30
+ - assets/stylesheets/side_by_side_edit.css
30
31
  - chiliproject_side_by_side_wiki_edit.gemspec
31
32
  - init.rb
32
33
  - lib/chiliproject_side_by_side_wiki_edit.rb
@@ -48,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
49
  version: '0'
49
50
  segments:
50
51
  - 0
51
- hash: 1310505938391298615
52
+ hash: 1742587861404646340
52
53
  required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  none: false
54
55
  requirements:
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
58
  version: '0'
58
59
  segments:
59
60
  - 0
60
- hash: 1310505938391298615
61
+ hash: 1742587861404646340
61
62
  requirements: []
62
63
  rubyforge_project:
63
64
  rubygems_version: 1.8.23