Last files of migration to slim

This commit is contained in:
Alexander Meindl 2017-12-15 12:05:26 +01:00
parent 2f407e451b
commit 4ee6fa2993
8 changed files with 82 additions and 79 deletions

View File

@ -1,19 +0,0 @@
<%= javascript_tag do %>
$(function() {
// when the #search field changes
$('#search').live_observe_field(2, function() {
var form = $('#query_form'); // grab the form wrapping the search bar.
var url = form.attr('action');
form.find('[name="c[]"] option').each(function(i, elem){
$(elem).attr('selected', true)
})
var formData = form.serialize();
form.find('[name="c[]"] option').each(function(i, elem){
$(elem).attr('selected', false)
})
$.get(url, formData, function(data) { // perform an AJAX get, the trailing function is what happens on successful get.
$("#query-result-list").html(data); // replace the "results" div with the result of action taken
});
});
});
<% end %>

View File

@ -0,0 +1,18 @@
javascript:
$(function() {
// when the #search field changes
$('#search').live_observe_field(2, function() {
var form = $('#query_form'); // grab the form wrapping the search bar.
var url = form.attr('action');
form.find('[name="c[]"] option').each(function(i, elem) {
$(elem).attr('selected', true)
})
var formData = form.serialize();
form.find('[name="c[]"] option').each(function(i, elem) {
$(elem).attr('selected', false)
})
$.get(url, formData, function(data) { // perform an AJAX get, the trailing function is what happens on successful get.
$("#query-result-list").html(data); // replace the "results" div with the result of action taken
});
});
});

View File

@ -1,29 +0,0 @@
<% options = {} if options.nil? %>
<%= javascript_tag do %>
$('#<%= field_id %>').select2({
ajax: {
url: '<%= ajax_url %>',
dataType: 'json',
delay: 250,
data: function(params) {
return { q: params.term };
},
processResults: function(data, params) {
return { results: data };
},
cache: true
},
placeholder: '<%= options[:placeholder].present? ? options[:placeholder] : ' ' %>',
allowClear: <%= options[:allow_clear].present? && options[:allow_clear] ? 'true' : 'false' %>,
minimumInputLength: 0,
width: '60%',
templateResult: formatState
});
function formatState (opt) {
if (opt.loading) return opt.name;
var $opt = $('<span>' + opt.name_with_icon + '</span>');
return $opt;
};
<% end %>

View File

@ -0,0 +1,31 @@
- options = {} if options.nil?
javascript:
$("##{field_id}").select2({
ajax: {
url: "#{ajax_url}",
dataType: 'json',
delay: 250,
data: function(params) {
return {
q: params.term
};
},
processResults: function(data, params) {
return {
results: data
};
},
cache: true
},
placeholder: "#{options[:placeholder].presence}",
allowClear: #{options[:allow_clear].present? && options[:allow_clear] ? 'true' : 'false'},
minimumInputLength: 0,
width: '60%',
templateResult: formatState
});
function formatState(opt) {
if (opt.loading) return opt.name;
var $opt = $('<span>' + opt.name_with_icon + '</span>');
return $opt;
};

View File

@ -1,15 +0,0 @@
<div id="month-calendar-<%= id %>" class="month-calendar"></div>
<%= javascript_tag do %>
$('#month-calendar-<%= id %>').datepicker({
language: "<%= locale %>",
calendarWeeks: <%= options[:show_weeks] %>,
todayHighlight: true,
multidate: true,
disableTouchKeyboard: true,
defaultViewDate: { year: <%= options[:year] %>, month: <%= options[:month] %>, day: 1 }
});
<% unless selected.empty? %>
$('#month-calendar-<%= id %>').datepicker('setDates', <%= selected %>);
<% end %>
<% end %>

View File

@ -0,0 +1,17 @@
.month-calendar id="month-calendar-#{id}"
javascript:
$("#month-calendar-#{id}").datepicker({
language: "#{locale}",
calendarWeeks: #{options[:show_weeks]},
todayHighlight: true,
multidate: true,
disableTouchKeyboard: true,
defaultViewDate: {
year: #{options[:year]},
month: #{options[:month]},
day: 1
}
});
- unless selected.empty?
javascript:
$('#month-calendar-#{id}').datepicker('setDates', #{selected});

View File

@ -1,16 +0,0 @@
<div class="cryptocompare">
<script type="text/javascript">
var scripts = document.getElementsByTagName("script");
var embedder = scripts[ scripts.length - 1 ];
(function (){
var appName = encodeURIComponent(window.location.hostname);
if(appName==""){appName="local";}
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
var theUrl = '<%= raw url %>';
s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + "app=" + appName;
embedder.parentNode.appendChild(s);
})();
</script>
</div>

View File

@ -0,0 +1,16 @@
.cryptocompare
javascript:
var scripts = document.getElementsByTagName("script");
var embedder = scripts[scripts.length - 1];
(function() {
var appName = encodeURIComponent(window.location.hostname);
if (appName == "") {
appName = "local";
}
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
var theUrl = "#{raw url}";
s.src = theUrl + (theUrl.indexOf("?") >= 0 ? "&" : "?") + "app=" + appName;
embedder.parentNode.appendChild(s);
})();