Skip to content

Commit 14e1c4d

Browse files
author
Florian Kissling
committed
JavaScript indention.
1 parent 44c64cf commit 14e1c4d

3 files changed

Lines changed: 156 additions & 145 deletions

File tree

docs/announcements-4.0.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,10 @@ <h3 id="removed-initselection">
379379
</p>
380380

381381
<pre class="prettyprint linenums">
382-
$.fn.select2.amd.require(
383-
['select2/data/array', 'select2/utils'],
384-
function (ArrayData, Utils) {
382+
$.fn.select2.amd.require([
383+
'select2/data/array',
384+
'select2/utils'
385+
], function (ArrayData, Utils) {
385386
function CustomData ($element, options) {
386387
CustomData.__super__.constructor.call(this, $element, options);
387388
}
@@ -505,9 +506,10 @@ <h3 id="query-to-data-adapter">
505506
</p>
506507

507508
<pre class="prettyprint linenums">
508-
$.fn.select2.amd.require(
509-
['select2/data/array', 'select2/utils'],
510-
function (ArrayData, Utils) {
509+
$.fn.select2.amd.require([
510+
'select2/data/array',
511+
'select2/utils'
512+
], function (ArrayData, Utils) {
511513
function CustomData ($element, options) {
512514
CustomData.__super__.constructor.call(this, $element, options);
513515
}
@@ -746,5 +748,5 @@ <h3>.select2("enable")</h3>
746748
</div>
747749

748750
<script type="text/javascript">
749-
prettyPrint();
751+
prettyPrint();
750752
</script>

docs/examples.html

Lines changed: 145 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -52,87 +52,95 @@ <h1>
5252
{% include js-source-states.html %}
5353

5454
<script type="text/javascript">
55-
var $states = $(".js-source-states");
56-
var statesOptions = $states.html();
57-
$states.remove();
55+
var $states = $(".js-source-states");
56+
var statesOptions = $states.html();
57+
$states.remove();
5858

59-
$(".js-states").append(statesOptions);
59+
$(".js-states").append(statesOptions);
6060

61-
$("[data-fill-from]").each(function () {
62-
var $this = $(this);
61+
$("[data-fill-from]").each(function () {
62+
var $this = $(this);
6363

64-
var codeContainer = $this.data("fill-from");
65-
var $container = $(codeContainer);
64+
var codeContainer = $this.data("fill-from");
65+
var $container = $(codeContainer);
6666

67-
var code = $.trim($container.html());
67+
var code = $.trim($container.html());
6868

69-
$this.text(code);
70-
$this.addClass("prettyprint linenums");
71-
});
72-
73-
prettyPrint();
69+
$this.text(code);
70+
$this.addClass("prettyprint linenums");
71+
});
7472

75-
$.fn.select2.amd.require(
76-
["select2/core", "select2/utils", "select2/compat/matcher"],
77-
function (Select2, Utils, oldMatcher) {
78-
var $basicSingle = $(".js-example-basic-single");
79-
var $basicMultiple = $(".js-example-basic-multiple");
80-
var $limitMultiple = $(".js-example-basic-multiple-limit");
73+
prettyPrint();
8174

82-
var $dataArray = $(".js-example-data-array");
83-
var $dataArraySelected = $(".js-example-data-array-selected");
75+
$.fn.select2.amd.require([
76+
"select2/core",
77+
"select2/utils",
78+
"select2/compat/matcher"
79+
], function (Select2, Utils, oldMatcher) {
80+
var $basicSingle = $(".js-example-basic-single");
81+
var $basicMultiple = $(".js-example-basic-multiple");
82+
var $limitMultiple = $(".js-example-basic-multiple-limit");
8483

85-
var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];
84+
var $dataArray = $(".js-example-data-array");
85+
var $dataArraySelected = $(".js-example-data-array-selected");
8686

87-
var $ajax = $(".js-example-data-ajax");
87+
var data = [
88+
{ id: 0, text: 'enhancement' },
89+
{ id: 1, text: 'bug' },
90+
{ id: 2, text: 'duplicate' },
91+
{ id: 3, text: 'invalid' },
92+
{ id: 4, text: 'wontfix' }
93+
];
8894

89-
var $disabledResults = $(".js-example-disabled-results");
95+
var $ajax = $(".js-example-data-ajax");
9096

91-
var $tags = $(".js-example-tags");
97+
var $disabledResults = $(".js-example-disabled-results");
9298

93-
var $matcherStart = $('.js-example-matcher-start');
99+
var $tags = $(".js-example-tags");
94100

95-
var $diacritics = $(".js-example-diacritics");
96-
var $language = $(".js-example-language");
101+
var $matcherStart = $('.js-example-matcher-start');
97102

98-
$.fn.select2.defaults.set("width", "100%");
103+
var $diacritics = $(".js-example-diacritics");
104+
var $language = $(".js-example-language");
99105

100-
$basicSingle.select2();
101-
$basicMultiple.select2();
102-
$limitMultiple.select2({
103-
maximumSelectionLength: 2
104-
});
106+
$.fn.select2.defaults.set("width", "100%");
105107

106-
function formatState (state) {
107-
if (!state.id) {
108-
return state.text;
109-
}
110-
var $state = $(
111-
'<span>' +
112-
'<img src="vendor/images/flags/' +
113-
state.element.value.toLowerCase() +
114-
'.png" class="img-flag" /> ' +
115-
state.text +
116-
'</span>'
117-
);
118-
return $state;
119-
};
120-
121-
$(".js-example-templating").select2({
122-
templateResult: formatState,
123-
templateSelection: formatState
124-
});
125-
126-
$dataArray.select2({
127-
data: data
128-
});
108+
$basicSingle.select2();
109+
$basicMultiple.select2();
110+
$limitMultiple.select2({
111+
maximumSelectionLength: 2
112+
});
129113

130-
$dataArraySelected.select2({
131-
data: data
132-
});
133-
134-
function formatRepo (repo) {
135-
if (repo.loading) return repo.text;
114+
function formatState (state) {
115+
if (!state.id) {
116+
return state.text;
117+
}
118+
var $state = $(
119+
'<span>' +
120+
'<img src="vendor/images/flags/' +
121+
state.element.value.toLowerCase() +
122+
'.png" class="img-flag" /> ' +
123+
state.text +
124+
'</span>'
125+
);
126+
return $state;
127+
};
128+
129+
$(".js-example-templating").select2({
130+
templateResult: formatState,
131+
templateSelection: formatState
132+
});
133+
134+
$dataArray.select2({
135+
data: data
136+
});
137+
138+
$dataArraySelected.select2({
139+
data: data
140+
});
141+
142+
function formatRepo (repo) {
143+
if (repo.loading) return repo.text;
136144

137145
var markup = "<div class='select2-result-repository clearfix'>" +
138146
"<div class='select2-result-repository__avatar'><img src='" + repo.owner.avatar_url + "' /></div>" +
@@ -150,97 +158,97 @@ <h1>
150158
"</div>" +
151159
"</div></div>";
152160

153-
return markup;
154-
}
161+
return markup;
162+
}
155163

156-
function formatRepoSelection (repo) {
157-
return repo.full_name || repo.text;
158-
}
164+
function formatRepoSelection (repo) {
165+
return repo.full_name || repo.text;
166+
}
159167

160-
$ajax.select2({
161-
ajax: {
162-
url: "https://api.github.com/search/repositories",
163-
dataType: 'json',
164-
delay: 250,
165-
data: function (params) {
166-
return {
167-
q: params.term, // search term
168-
page: params.page
169-
};
170-
},
171-
processResults: function (data, params) {
172-
// parse the results into the format expected by Select2
173-
// since we are using custom formatting functions we do not need to
174-
// alter the remote JSON data, except to indicate that infinite
175-
// scrolling can be used
176-
params.page = params.page || 1;
177-
178-
return {
179-
results: data.items,
180-
pagination: {
181-
more: (params.page * 30) < data.total_count
182-
}
183-
};
168+
$ajax.select2({
169+
ajax: {
170+
url: "https://api.github.com/search/repositories",
171+
dataType: 'json',
172+
delay: 250,
173+
data: function (params) {
174+
return {
175+
q: params.term, // search term
176+
page: params.page
177+
};
178+
},
179+
processResults: function (data, params) {
180+
// parse the results into the format expected by Select2
181+
// since we are using custom formatting functions we do not need to
182+
// alter the remote JSON data, except to indicate that infinite
183+
// scrolling can be used
184+
params.page = params.page || 1;
185+
186+
return {
187+
results: data.items,
188+
pagination: {
189+
more: (params.page * 30) < data.total_count
190+
}
191+
};
192+
},
193+
cache: true
184194
},
185-
cache: true
186-
},
187-
escapeMarkup: function (markup) { return markup; },
188-
minimumInputLength: 1,
189-
templateResult: formatRepo,
190-
templateSelection: formatRepoSelection
191-
});
195+
escapeMarkup: function (markup) { return markup; },
196+
minimumInputLength: 1,
197+
templateResult: formatRepo,
198+
templateSelection: formatRepoSelection
199+
});
192200

193-
$(".js-example-disabled").select2();
194-
$(".js-example-disabled-multi").select2();
201+
$(".js-example-disabled").select2();
202+
$(".js-example-disabled-multi").select2();
195203

196-
$(".js-example-responsive").select2();
204+
$(".js-example-responsive").select2();
197205

198-
$disabledResults.select2();
206+
$disabledResults.select2();
199207

200-
$(".js-example-programmatic").select2();
201-
$(".js-example-programmatic-multi").select2();
208+
$(".js-example-programmatic").select2();
209+
$(".js-example-programmatic-multi").select2();
202210

203-
$eventSelect.select2();
211+
$eventSelect.select2();
204212

205-
$tags.select2({
206-
tags: ['red', 'blue', 'green']
207-
});
213+
$tags.select2({
214+
tags: ['red', 'blue', 'green']
215+
});
208216

209-
$(".js-example-tokenizer").select2({
210-
tags: true,
211-
tokenSeparators: [',', ' ']
212-
});
217+
$(".js-example-tokenizer").select2({
218+
tags: true,
219+
tokenSeparators: [',', ' ']
220+
});
221+
222+
function matchStart (term, text) {
223+
if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) {
224+
return true;
225+
}
213226

214-
function matchStart (term, text) {
215-
if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) {
216-
return true;
227+
return false;
217228
}
218229

219-
return false;
220-
}
230+
$matcherStart.select2({
231+
matcher: oldMatcher(matchStart)
232+
});
221233

222-
$matcherStart.select2({
223-
matcher: oldMatcher(matchStart)
224-
});
234+
$(".js-example-basic-hide-search").select2({
235+
minimumResultsForSearch: Infinity
236+
});
225237

226-
$(".js-example-basic-hide-search").select2({
227-
minimumResultsForSearch: Infinity
228-
});
238+
$diacritics.select2();
229239

230-
$diacritics.select2();
240+
$language.select2({
241+
language: "es"
242+
});
231243

232-
$language.select2({
233-
language: "es"
234-
});
244+
$(".js-example-theme-single").select2({
245+
theme: "classic"
246+
});
235247

236-
$(".js-example-theme-single").select2({
237-
theme: "classic"
238-
});
248+
$(".js-example-theme-multiple").select2({
249+
theme: "classic"
250+
});
239251

240-
$(".js-example-theme-multiple").select2({
241-
theme: "classic"
252+
$(".js-example-rtl").select2();
242253
});
243-
244-
$(".js-example-rtl").select2();
245-
});
246254
</script>

docs/options.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ <h1>
3232
</div>
3333
</div>
3434

35-
<script type="text/javascript">prettyPrint();
35+
<script type="text/javascript">
36+
prettyPrint();
3637
</script>

0 commit comments

Comments
 (0)