Revert "only load select2 on story submit form"
This reverts commit 71045a52ee
.
This only has a small effect on js size and is flaky. Need a significantly
bigger change, like dropping jquery altogether.
This commit is contained in:
parent
4be8ba1154
commit
4e96034253
|
@ -1,7 +1,6 @@
|
|||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery_class
|
||||
//= require autosize
|
||||
//= require_tree .
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -287,43 +286,40 @@ var _Lobsters = Class.extend({
|
|||
},
|
||||
|
||||
runSelect2: function() {
|
||||
/* .each to avoid running on pages without select2 */
|
||||
$("#story_tags_a").each(function(_index, el) {
|
||||
$(el).select2({
|
||||
formatSelection: function(what) {
|
||||
return what.id;
|
||||
},
|
||||
matcher: function(term, text) {
|
||||
return text.toUpperCase().indexOf(term.toUpperCase()) >= 0;
|
||||
},
|
||||
sortResults: function(results, container, query) {
|
||||
if (query.term) {
|
||||
var tmatches = [];
|
||||
var dmatches = [];
|
||||
$("#story_tags_a").select2({
|
||||
formatSelection: function(what) {
|
||||
return what.id;
|
||||
},
|
||||
matcher: function(term, text) {
|
||||
return text.toUpperCase().indexOf(term.toUpperCase()) >= 0;
|
||||
},
|
||||
sortResults: function(results, container, query) {
|
||||
if (query.term) {
|
||||
var tmatches = [];
|
||||
var dmatches = [];
|
||||
|
||||
/* prefer tag matches first, then description matches */
|
||||
for (var x in results) {
|
||||
var r = results[x];
|
||||
/* prefer tag matches first, then description matches */
|
||||
for (var x in results) {
|
||||
var r = results[x];
|
||||
|
||||
if (r.id.toUpperCase().indexOf(query.term.toUpperCase()) == 0)
|
||||
tmatches.push(r);
|
||||
else
|
||||
dmatches.push(r);
|
||||
}
|
||||
|
||||
tmatches = tmatches.sort(function(a, b) {
|
||||
return a.text.localeCompare(b.text);
|
||||
});
|
||||
dmatches = dmatches.sort(function(a, b) {
|
||||
return a.text.localeCompare(b.text);
|
||||
});
|
||||
|
||||
return tmatches.concat(dmatches);
|
||||
if (r.id.toUpperCase().indexOf(query.term.toUpperCase()) == 0)
|
||||
tmatches.push(r);
|
||||
else
|
||||
dmatches.push(r);
|
||||
}
|
||||
|
||||
return results;
|
||||
tmatches = tmatches.sort(function(a, b) {
|
||||
return a.text.localeCompare(b.text);
|
||||
});
|
||||
dmatches = dmatches.sort(function(a, b) {
|
||||
return a.text.localeCompare(b.text);
|
||||
});
|
||||
|
||||
return tmatches.concat(dmatches);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -392,8 +388,6 @@ $(document).ready(function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
Lobsters.runSelect2();
|
||||
|
||||
$("select[name=message\\[hat_id\\]]").change(function() {
|
||||
$(this).siblings("input[name=message\\[mod_note\\]]")
|
||||
.prop("checked", !!$(this).find('option:selected').data('modnote'));
|
||||
|
@ -512,6 +506,8 @@ $(document).ready(function() {
|
|||
});
|
||||
});
|
||||
|
||||
Lobsters.runSelect2();
|
||||
|
||||
$(document).on("click", "div.markdown_help_toggler .markdown_help_label",
|
||||
function() {
|
||||
$(this).parents("div.markdown_help_toggler").first().
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<%= javascript_include_tag 'select2' %>
|
||||
|
||||
<%= render :partial => "stories/form_errors", :locals => { :f => f, :story => f.object } %>
|
||||
|
||||
<div class="box">
|
||||
|
|
Loading…
Reference in New Issue