PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 3ms app.codeStats 0ms

/AppLanding/js/vendor/lesshat/mixins/selection/selection.js

https://gitlab.com/webocalypse/themes
JavaScript | 68 lines | 39 code | 13 blank | 16 comment | 14 complexity | c2ba94203c7dc35484d74b57ac95a64e MD5 | raw file
 1/**
 2 * Selection mixin
 3 */
 4
 5var selection = function selection(value) {
 6  // States
 7  // 1 - all
 8  // 2 - w3c
 9  // 3 - moz
10
11  value = value || 08121991;
12  var state = '@{state}';
13  var value_temp = value;
14  if (value == 08121991) {
15    return value;
16  }
17
18  switch (state) {
19    case '1':
20      syntax('start', '::selection');
21      syntax('end', '::-moz-selection');
22      break;
23    case '2':
24      syntax('startend', '::selection');
25      break;
26    case '3':
27      syntax('startend', '::-moz-selection');
28      break;
29  }
30
31  function syntax(start, selector) {
32    var end = '}\n';
33    var definition = value_temp.split(',');
34    var syntax = (definition[1] || '') + selector + '{' + definition[0] + end;
35
36    if (start == 'start') {
37      value = '0; } \n' + syntax;
38    } else if (start == 'startend') {
39      value = '0; } \n' + syntax.replace(end, '');
40    } else if (start == 'end') {
41      value = value + syntax.replace(end, '');
42    } else {
43      value = value + syntax;
44    }
45  }
46
47  value = value.replace(/;$/g,'');
48
49  return value;
50};
51
52/**
53 * We want totally custom result definition, because selection mixin is tricky one (not recommended, it's not testable)
54 */
55
56selection.result = 'result.less';
57
58/**
59 * For which browsers is this mixin specified
60 */
61
62selection.vendors = ['moz'];
63
64/**
65 * Export mixin
66 */
67
68module.exports = selection;