2014-10-10 17:26:42 +02:00
|
|
|
<link href="//thingspeak.com/codemirror/codemirror.css" rel="stylesheet" />
|
|
|
|
<link href="//thingspeak.com/codemirror/neat.css" rel="stylesheet" />
|
|
|
|
<script type="text/javascript" src="//thingspeak.com/codemirror/codemirror.js"></script>
|
|
|
|
<script type="text/javascript" src="//thingspeak.com/codemirror/xml.js"></script>
|
|
|
|
<script type="text/javascript" src="//thingspeak.com/codemirror/javascript.js"></script>
|
|
|
|
<script type="text/javascript" src="//thingspeak.com/codemirror/css.js"></script>
|
|
|
|
<script type="text/javascript" src="//thingspeak.com/codemirror/htmlmixed.js"></script>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
/* codemirror overrides */
|
|
|
|
pre { overflow: inherit !important; }
|
|
|
|
.activeline { background: #e8f2ff !important; }
|
|
|
|
.CodeMirror { border: 1px solid #ccc; }
|
|
|
|
.CodeMirror-scroll { height: 300px; }
|
|
|
|
</style>
|
|
|
|
|
2014-10-15 01:47:57 +02:00
|
|
|
<div class="col-sm-8 col-xs-12">
|
2014-02-17 18:05:39 +01:00
|
|
|
|
2014-07-23 19:45:15 +02:00
|
|
|
<ol class="breadcrumb" data-no-turbolink>
|
2014-02-17 18:05:39 +01:00
|
|
|
<li><%= link_to t(:plugins), plugins_path %></li>
|
2014-10-16 03:47:51 +02:00
|
|
|
<li><%= link_to plugin_path(@plugin.id), target: '_blank' do %><%= t(:plugin) %> <%= @plugin.id %><% end %></li>
|
2014-02-17 18:05:39 +01:00
|
|
|
<li class="active"><%= t(:edit) %></li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<%= form_for @plugin, :html => {:method => 'put', :class => 'form-horizontal'} do |c| %>
|
|
|
|
<%= error_messages_for 'plugin', :header_message => t(:try_again), :message => t(:plugin_error) %>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2014-10-15 01:47:57 +02:00
|
|
|
<label class="col-sm-2 col-xs-12 control-label"><%= t(:plugin_name) %></label>
|
|
|
|
<div class="col-sm-10 col-xs-12"><%= c.text_field :name, :class => 'form-control' %></div>
|
2014-02-17 18:05:39 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2014-10-15 01:47:57 +02:00
|
|
|
<label class="col-sm-2 col-xs-12 control-label"><%= t(:plugin_html) %></label>
|
|
|
|
<div class="col-sm-10 col-xs-12"><%= c.text_area :html, :class => 'form-control', :rows => 14 %></div>
|
2014-02-17 18:05:39 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2014-10-15 01:47:57 +02:00
|
|
|
<label class="col-sm-2 col-xs-12 control-label"><%= t(:plugin_css) %></label>
|
|
|
|
<div class="col-sm-10 col-xs-12"><%= c.text_area :css, :class => 'form-control', :rows => 14 %></div>
|
2014-02-17 18:05:39 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2014-10-15 01:47:57 +02:00
|
|
|
<label class="col-sm-2 col-xs-12 control-label"><%= t(:plugin_js) %></label>
|
|
|
|
<div class="col-sm-10 col-xs-12"><%= c.text_area :js, :class => 'form-control', :rows => 14 %></div>
|
2014-02-17 18:05:39 +01:00
|
|
|
</div>
|
|
|
|
|
2014-10-16 03:47:51 +02:00
|
|
|
<div class="form-group">
|
|
|
|
<div class="col-sm-offset-2 col-sm-10 col-xs-12">
|
|
|
|
<div class="checkbox">
|
|
|
|
<label>
|
2014-10-16 16:43:21 +02:00
|
|
|
<%= c.check_box :public_flag %>
|
|
|
|
<b><%= t(:plugin_public_flag) %></b>
|
2014-10-16 03:47:51 +02:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
<div class="form-group">
|
|
|
|
<label class="col-sm-2 control-label"></label>
|
2014-10-16 19:02:32 +02:00
|
|
|
<div class="col-sm-10"><p class="form-control-static"><%= c.submit t(:save_model, model: 'Plugin'), :class => 'btn btn-primary' %></p></div>
|
2014-02-17 18:05:39 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<% end %>
|
|
|
|
|
2014-03-14 00:16:35 +01:00
|
|
|
<br><br>
|
2014-02-17 18:05:39 +01:00
|
|
|
|
|
|
|
<h3><%= t(:plugin_delete_message) %></h3>
|
2014-10-16 19:02:32 +02:00
|
|
|
<%= button_to t(:delete_model, model: 'Plugin'), plugin_path(@plugin.id), :method => 'delete', :data => { :confirm => t(:confirm_plugin_delete) }, :class => 'btn btn-danger' %>
|
2014-02-17 18:05:39 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2014-10-10 17:26:42 +02:00
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
// when document is ready
|
2014-08-01 21:57:02 +02:00
|
|
|
$(document).on('page:load ready', function() {
|
2014-02-17 18:05:39 +01:00
|
|
|
|
2014-10-10 17:26:42 +02:00
|
|
|
// set html codemirror
|
|
|
|
var html_line = '';
|
|
|
|
var html_editor = CodeMirror.fromTextArea(document.getElementById("plugin_html"), {
|
|
|
|
lineNumbers: true,
|
|
|
|
indentUnit: 2,
|
|
|
|
extraKeys: {Tab: function(cm) { cm.replaceSelection(" ", "end"); }},
|
|
|
|
matchBrackets: true,
|
|
|
|
mode: "text/html",
|
|
|
|
height: '300px',
|
|
|
|
onCursorActivity: function() {
|
|
|
|
html_editor.setLineClass(html_line, null, null);
|
|
|
|
html_line = html_editor.setLineClass(html_editor.getCursor().line, null, "activeline");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// set css codemirror
|
|
|
|
var css_line = '';
|
|
|
|
var css_editor = CodeMirror.fromTextArea(document.getElementById("plugin_css"), {
|
|
|
|
lineNumbers: true,
|
|
|
|
indentUnit: 2,
|
|
|
|
extraKeys: {Tab: function(cm) { cm.replaceSelection(" ", "end"); }},
|
|
|
|
matchBrackets: true,
|
|
|
|
mode: "text/html",
|
|
|
|
height: '300px',
|
|
|
|
onCursorActivity: function() {
|
|
|
|
css_editor.setLineClass(css_line, null, null);
|
|
|
|
css_line = css_editor.setLineClass(css_editor.getCursor().line, null, "activeline");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// set js codemirror
|
|
|
|
var js_line = '';
|
|
|
|
var js_editor = CodeMirror.fromTextArea(document.getElementById("plugin_js"), {
|
|
|
|
lineNumbers: true,
|
|
|
|
indentUnit: 2,
|
|
|
|
extraKeys: {Tab: function(cm) { cm.replaceSelection(" ", "end"); }},
|
|
|
|
matchBrackets: true,
|
|
|
|
mode: "text/html",
|
|
|
|
height: '300px',
|
|
|
|
onCursorActivity: function() {
|
|
|
|
js_editor.setLineClass(js_line, null, null);
|
|
|
|
js_line = js_editor.setLineClass(js_editor.getCursor().line, null, "activeline");
|
|
|
|
}
|
|
|
|
});
|
2014-02-17 18:05:39 +01:00
|
|
|
|
|
|
|
// clears status message
|
|
|
|
function clearStatus() {
|
|
|
|
setTimeout(function() {
|
|
|
|
$('#status').html('');
|
|
|
|
}, 2500);
|
|
|
|
}
|
|
|
|
|
|
|
|
// event to capture update button click
|
|
|
|
$('#plugin_submit').click(
|
|
|
|
function() {
|
|
|
|
$.update(
|
|
|
|
// url to post to
|
|
|
|
'/plugins/ajax_update/<%= @plugin.id %>',
|
|
|
|
|
|
|
|
// data to send
|
|
|
|
{
|
|
|
|
plugin:
|
|
|
|
{
|
|
|
|
name: $('#plugin_name').val(),
|
2014-10-16 16:43:21 +02:00
|
|
|
public_flag: $('#plugin_public_flag').is(':checked'),
|
2014-02-17 18:05:39 +01:00
|
|
|
html: $('#plugin_html').val(),
|
|
|
|
css: $('#plugin_css').val(),
|
|
|
|
js: $('#plugin_js').val()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// if post was successful
|
|
|
|
function (response) {
|
|
|
|
var status = (response == '1') ? '<%= t(:saved) %>' : '<%= t(:saved_error) %>';
|
|
|
|
$('#status').html(status);
|
|
|
|
clearStatus();
|
|
|
|
},
|
|
|
|
|
|
|
|
// if post failed
|
|
|
|
function (response) {
|
|
|
|
$('#status').html('<%= t(:saved_error) %>');
|
|
|
|
clearStatus();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|