Skip to content

Commit

Permalink
The new editor works when tabs aren't used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zach Perrault committed Nov 19, 2015
1 parent aa14dce commit 0ad1603
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 137 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ gem 'jquery-ui-rails'

gem 'redis-rails'
gem 'puma'
gem 'ace-rails-ap'


2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
ace-rails-ap (4.0.1)
actionmailer (3.2.22)
actionpack (= 3.2.22)
mail (~> 2.5.4)
Expand Down Expand Up @@ -247,6 +248,7 @@ PLATFORMS
ruby

DEPENDENCIES
ace-rails-ap
active_record_or
bullet
cancan
Expand Down
50 changes: 19 additions & 31 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
*= require jquery.autocomplete.min
*= require jquery.lightbox_me
*= require jquery-ui-timepicker-addon
*= require codemirror/codemirror
*= require codemirror/clike
*= require codemirror/xml
*= require overlay.js
*= require ace-rails-ap
*= require ace/mode-xml
*= require ace/theme-textmate
*= require highcharts
*= require_self
*= */
Expand Down Expand Up @@ -166,33 +165,22 @@ $(document).ready(function() {

// add Codemirror with $ animation to highlight XML/plist/bash syntax in package list
$("textarea[data-format]").each(function () {
var format = $(this).attr("data-format");
var toRefresh = function(){
editor.refresh();
}
var editor = CodeMirror.fromTextArea(this, {
onFocus: function() {
//$ animation goes here
$(editor.getWrapperElement()).animate({
height: "300px"
},
400, "swing", toRefresh);
},
onBlur: function() {
$(editor.getWrapperElement()).animate({
height: "78px"
},
400, "swing", toRefresh);
},
lineNumbers: true,
matchBrackets: true,
mode: format,
onCursorActivity: function() {
editor.setLineClass(hlLine, null);
hlLine = editor.setLineClass(editor.getWrapperElement().line, "activeline");
}
});
var hlLine = editor.setLineClass(0, "activeline");
var textarea = $(this);
var mode = textarea.data('format');
var editDiv = $('<div>', {
position: 'absolute',
width: textarea.width(),
height: textarea.height(),
'class': textarea.attr('class')
}).insertBefore(textarea);
textarea.css('display', 'none');
var editor = ace.edit(editDiv[0]);
editor.getSession().setValue(textarea.val());
editor.getSession().setMode("ace/mode/" + mode);
editor.setTheme("ace/theme/textmate");
editor.getSession().on('change', function () {
textarea.val(editor.getSession().getValue());
});
});

function hideAllUninstallField(){
Expand Down
3 changes: 0 additions & 3 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
*= require dropdown/theme
*= require dropdown/styles
*= require dropdown/theme
*= require codemirror/codemirror
*= require codemirror/clike
*= require codemirror/xml
*= require style
*/
2 changes: 1 addition & 1 deletion app/assets/stylesheets/codemirror/codemirror.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.CodeMirror {
overflow: auto;
height: 78px;
height: 300px;
line-height: 1em;
font-family: monospace;
font-size: 9pt;
Expand Down
12 changes: 2 additions & 10 deletions app/assets/stylesheets/style.css.erb
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ label {
cursor:pointer;
}

textarea {
/* textarea {
height:auto;
width:587px; /*temporty fix in firefox, by giving a fixed value for the width*/
}
} */

/* Record header */

Expand Down Expand Up @@ -255,14 +255,6 @@ table.form {
width:auto;
}

.toggle_container textarea{
height:100px;
}

.toggle_container .CodeMirror{

}

table tbody .odd{
background: #F4F4F4;
}
Expand Down
159 changes: 67 additions & 92 deletions app/views/packages/_edit_package_tabs.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="tabs">
<div >
<ul>
<li><a href="#basics"><span>Basics</span></a></li>
<li><a href="#advanced"><span>Advanced</span></a></li>
Expand Down Expand Up @@ -158,7 +158,7 @@
Uninstall Install Script
<%= helpful_info("Enter the content of the Uninstall script here") %>
</h4>
<div id="postinstall_script_container" class="toggle_container">
<div id="postinstall_script_container">
<%= f.text_area :uninstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
<!-- <hr /> -->
Expand Down Expand Up @@ -209,98 +209,73 @@

<!-- Third tab starts here -->
<div id="plists">
<table class="form">

<tr>
<td colspan="2">
<h4>
Receipts
<%= helpful_info("Must be a valid plist with an array as the root object") %>
</h4>
<div id="receipts_plist_container" class="toggle_container">
<%= f.text_area :receipts_plist, :size => "80x20", "data-format" => 'xml' %>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<h4>
Installs
<%= helpful_info("Must be a valid plist with an array as the root object") %>
</h4>
<div id="installs_plist_container" class="toggle_container">
<%= f.text_area :installs_plist, :size => "80x20", "data-format" => 'xml' %>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<h4>
Raw tags
<%= f.select :raw_mode_id, options_for_select([[Package.raw_mode(0),0],[Package.raw_mode(1),1],[Package.raw_mode(2),2]],@package.raw_mode_id) %>
<%= helpful_info("Raw tags allow the ability to add extra Plist tags to the manifest. Must be formatted as a valid plist with a dictionary at the root. If you define a tag that is already defined above, the raw tag overwrites it. In append mode, the tags are added to the info plist. In exclusive mode, only the tags shown here are used.") %>
</h4>
<div id="raw_tags_container" class="toggle_container">
<%= text_area_tag "package[raw_tags_plist]", (@package.raw_tags_plist unless @package.raw_tags.nil?), :size => "80x15", "data-format" => 'xml' %>
</div>
</td>
</tr>
</table>
<div>
<h4>
Receipts
<%= helpful_info("Must be a valid plist with an array as the root object") %>
</h4>
<div id="receipts_plist_container">
<%= f.text_area :receipts_plist, :size => "80x20", "data-format" => 'xml' %>
</div>
</div>
<div>
<h4>
Installs
<%= helpful_info("Must be a valid plist with an array as the root object") %>
</h4>
<%= f.text_area :installs_plist, :size => "80x20", "data-format" => 'xml' %>
<div id="installs_plist_container_asdf" data-format="xml" class="editor">
</div>
</div>
<div>
<h4>
Raw tags
<%= f.select :raw_mode_id, options_for_select([[Package.raw_mode(0),0],[Package.raw_mode(1),1],[Package.raw_mode(2),2]],@package.raw_mode_id) %>
<%= helpful_info("Raw tags allow the ability to add extra Plist tags to the manifest. Must be formatted as a valid plist with a dictionary at the root. If you define a tag that is already defined above, the raw tag overwrites it. In append mode, the tags are added to the info plist. In exclusive mode, only the tags shown here are used.") %>
</h4>
<div id="raw_tags_container">
<%= text_area_tag "package[raw_tags_plist]", (@package.raw_tags_plist unless @package.raw_tags.nil?), :size => "80x15", "data-format" => 'xml' %>
</div>
</div>
</div>

<!-- Fourth tab starts here -->
<div id="scripts">
<table class="form">

<tr>
<td colspan="2">

<h4>
Pre Install Script
<%= helpful_info("Enter the content of the script here to run before the installation") %>
</h4>
<div id="preinstall_script_container" class="toggle_container">
<%= f.text_area :preinstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</td>
</tr>

<tr>
<td colspan="2">
<h4>
Post Install Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="postinstall_script_container" class="toggle_container">
<%= f.text_area :postinstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</td>
</tr>

<tr>
<td colspan="2">
<h4>
Pre Uninstall Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="preuninstall_script_container" class="toggle_container">
<%= f.text_area :preuninstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</td>
</tr>

<tr>
<td colspan="2">
<h4>
Post Uninstall Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="postuninstall_script_container" class="toggle_container">
<%= f.text_area :postuninstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</td>
</tr>

</table>
<div>
<h4>
Pre Install Script
<%= helpful_info("Enter the content of the script here to run before the installation") %>
</h4>
<div id="preinstall_script_container">
<%= f.text_area :preinstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</div>
<div>
<h4>
Post Install Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="postinstall_script_container">
<%= f.text_area :postinstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</div>
<div>
<h4>
Pre Uninstall Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="preuninstall_script_container">
<%= f.text_area :preuninstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</div>
<div>
<h4>
Post Uninstall Script
<%= helpful_info("Enter the content of the script here to run after the installation") %>
</h4>
<div id="postuninstall_script_container">
<%= f.text_area :postuninstall_script, :size => "80x20", "data-format" => 'text/x-csrc' %>
</div>
</div>
</div>
</div>
</div>

0 comments on commit 0ad1603

Please sign in to comment.