Skip to content

Commit 553fb3c

Browse files
committed
LukyVj#61 updated demo.
1 parent b160c62 commit 553fb3c

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

source/javascripts/demo.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,31 @@ document.getElementById('all-but').addEventListener('keyup', function(){
211211
// each
212212
///////////////////////////////
213213

214-
function each(num) {
215-
function injectStyle(num){
214+
function each(numa, numb) {
215+
function injectStyle(numa, numb){
216216
document.getElementById('style-each').innerHTML = `ul.each li { ${preStyle} }`;
217-
document.getElementById('style-each').innerHTML += `.each li:nth-child(${num}n){
218-
${selectedStyle}
217+
218+
if (numb == 0) {
219+
document.getElementById('style-each').innerHTML += `.each li:nth-child(${numa}n){
220+
${selectedStyle}
221+
}
222+
`
223+
}
224+
else {
225+
document.getElementById('style-each').innerHTML += `.each li:nth-child(${numa}n + ${numb}){
226+
${selectedStyle}
227+
}
228+
`
219229
}
220-
`
221230
}
222231

223-
var newStyle = injectStyle(num);
232+
var newStyle = injectStyle(numa, numb);
224233

225234
}
226235
document.getElementById('each').addEventListener('keyup', function(){
227-
each(this.innerHTML)
236+
var vala = document.getElementById('each-every').innerHTML;
237+
var valb = document.getElementById('each-from').innerHTML;
238+
each(vala, valb)
228239
})
229240

230241
///////////////////////////////

source/layouts/partials/_demo.html.haml

+5-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
:preserve
158158
<span class="param">@include</span> n-between(<span class="num" contenteditable id="n-between-a">3</span>,<span class="num" contenteditable id="n-between-b">3</span>,<span class="num" contenteditable id="n-between-c">13</span>)
159159
<span class="comment"> // This mixin uses 3 arguments, the first one is equal to N item,
160-
// the second is the starting item and the thirs the end item. </span>
160+
// the second is the starting item and the third the end item. </span>
161161

162162
%ul.n-between
163163
%li 1
@@ -200,9 +200,11 @@
200200
%header
201201
%h3 each
202202
%pre
203-
%code
203+
%code#each
204204
:preserve
205-
<span class="param"> @include</span> each(<span class="num" contenteditable id="each">3</span>)
205+
<span class="param"> @include</span> each(<span class="num" contenteditable id="each-every">3</span>,<span class="num" contenteditable id="each-from">0</span>)
206+
<span class="comment"> // This mixin uses 2 arguments, the first one is equal to N item,
207+
// the second is the starting item and can be omitted, the default value is 0. </span>
206208

207209
<span class="comment"> // Alias of each()</span>
208210
<span class="param"> @include</span> every(<span class="num" contenteditable id="each">3</span>)

0 commit comments

Comments
 (0)