Просмотр исходного кода

Merge pull request #654 from kvch/toggle-button

new toggle button - closes #284, #625
Adam Tauber 8 лет назад
Родитель
Сommit
49403dbbda

+ 1
- 1
searx/static/themes/oscar/css/logicodev.min.css
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 1
- 1
searx/static/themes/oscar/css/pointhi.min.css
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 57
- 0
searx/static/themes/oscar/less/logicodev/onoff.less Просмотреть файл

1
+.onoff-checkbox {
2
+    width:15%;
3
+}
4
+.onoffswitch {
5
+    position: relative;
6
+    width: 110px;
7
+    -webkit-user-select:none;
8
+    -moz-user-select:none;
9
+    -ms-user-select: none;
10
+}
11
+.onoffswitch-checkbox {
12
+    display: none;
13
+}
14
+.onoffswitch-label {
15
+    display: block;
16
+    overflow: hidden;
17
+    cursor: pointer;
18
+    border: 2px solid #FFFFFF !important;
19
+    border-radius: 50px !important;
20
+}
21
+.onoffswitch-inner {
22
+    display: block;
23
+    transition: margin 0.3s ease-in 0s;
24
+}
25
+
26
+.onoffswitch-inner:before, .onoffswitch-inner:after {
27
+    display: block;
28
+    float: left;
29
+    width: 50%;
30
+    height: 30px;
31
+    padding: 0;
32
+    line-height: 40px;
33
+    font-size: 20px;
34
+    box-sizing: border-box;
35
+    content: "";
36
+    background-color: #EEEEEE;
37
+}
38
+
39
+.onoffswitch-switch {
40
+    display: block;
41
+    width: 37px;
42
+    background-color: @light-green;
43
+    position: absolute;
44
+    top: 0;
45
+    bottom: 0;
46
+    right: 0px;
47
+    border: 2px solid #FFFFFF !important;
48
+    border-radius: 50px !important;
49
+    transition: all 0.3s ease-in 0s;
50
+}
51
+.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
52
+    margin-right: 0;
53
+}
54
+.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
55
+    right: 71px;
56
+    background-color: #A1A1A1;
57
+}

+ 2
- 0
searx/static/themes/oscar/less/logicodev/oscar.less Просмотреть файл

6
 
6
 
7
 @import "checkbox.less";
7
 @import "checkbox.less";
8
 
8
 
9
+@import "onoff.less";
10
+
9
 @import "results.less";
11
 @import "results.less";
10
 
12
 
11
 @import "infobox.less";
13
 @import "infobox.less";

+ 57
- 0
searx/static/themes/oscar/less/pointhi/onoff.less Просмотреть файл

1
+.onoff-checkbox {
2
+    width:15%;
3
+}
4
+.onoffswitch {
5
+    position: relative;
6
+    width: 110px;
7
+    -webkit-user-select:none;
8
+    -moz-user-select:none;
9
+    -ms-user-select: none;
10
+}
11
+.onoffswitch-checkbox {
12
+    display: none;
13
+}
14
+.onoffswitch-label {
15
+    display: block;
16
+    overflow: hidden;
17
+    cursor: pointer;
18
+    border: 2px solid #FFFFFF !important;
19
+    border-radius: 50px !important;
20
+}
21
+.onoffswitch-inner {
22
+    display: block;
23
+    transition: margin 0.3s ease-in 0s;
24
+}
25
+
26
+.onoffswitch-inner:before, .onoffswitch-inner:after {
27
+    display: block;
28
+    float: left;
29
+    width: 50%;
30
+    height: 30px;
31
+    padding: 0;
32
+    line-height: 40px;
33
+    font-size: 20px;
34
+    box-sizing: border-box;
35
+    content: "";
36
+    background-color: #EEEEEE;
37
+}
38
+
39
+.onoffswitch-switch {
40
+    display: block;
41
+    width: 37px;
42
+    background-color: #00CC00;
43
+    position: absolute;
44
+    top: 0;
45
+    bottom: 0;
46
+    right: 0px;
47
+    border: 2px solid #FFFFFF !important;
48
+    border-radius: 50px !important;
49
+    transition: all 0.3s ease-in 0s;
50
+}
51
+.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
52
+    margin-right: 0;
53
+}
54
+.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
55
+    right: 71px;
56
+    background-color: #A1A1A1;
57
+}

+ 2
- 0
searx/static/themes/oscar/less/pointhi/oscar.less Просмотреть файл

2
 
2
 
3
 @import "checkbox.less";
3
 @import "checkbox.less";
4
 
4
 
5
+@import "onoff.less";
6
+
5
 @import "results.less";
7
 @import "results.less";
6
 
8
 
7
 @import "infobox.less";
9
 @import "infobox.less";

+ 6
- 4
searx/templates/oscar/macros.html Просмотреть файл

68
 {%- endmacro %}
68
 {%- endmacro %}
69
 
69
 
70
 {% macro checkbox_toggle(id, blocked) -%}
70
 {% macro checkbox_toggle(id, blocked) -%}
71
-    <div class="checkbox">
72
-        <input class="hidden" type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} />
73
-        <label class="btn btn-success label_hide_if_checked" for="{{ id }}">{{ _('Block') }}</label>
74
-        <label class="btn btn-danger label_hide_if_not_checked" for="{{ id }}">{{ _('Allow') }}</label>
71
+    <div class="onoffswitch">
72
+        <input type="checkbox" id="{{ id }}" name="{{ id }}"{% if blocked %} checked="checked"{% endif %} class="onoffswitch-checkbox">
73
+        <label class="onoffswitch-label" for="{{ id }}">
74
+            <span class="onoffswitch-inner"></span>
75
+            <span class="onoffswitch-switch"></span>
76
+        </label>
75
     </div>
77
     </div>
76
 {%- endmacro %}
78
 {%- endmacro %}

+ 8
- 2
searx/templates/oscar/preferences.html Просмотреть файл

164
                             {% if not search_engine.private %}
164
                             {% if not search_engine.private %}
165
                                 <tr>
165
                                 <tr>
166
                                     {% if not rtl %}
166
                                     {% if not rtl %}
167
-                                    <td>{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}</td>
167
+                                    <td class="onoff-checkbox">
168
+                                        {{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}
169
+                                    </td>
168
                                     <th>{{ search_engine.name }}</th>
170
                                     <th>{{ search_engine.name }}</th>
169
 				    <td>{{ shortcuts[search_engine.name] }}</td>
171
 				    <td>{{ shortcuts[search_engine.name] }}</td>
170
 				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
172
 				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
176
 				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
178
 				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
177
 				    <td>{{ shortcuts[search_engine.name] }}</td>
179
 				    <td>{{ shortcuts[search_engine.name] }}</td>
178
                                     <th>{{ search_engine.name }}</th>
180
                                     <th>{{ search_engine.name }}</th>
179
-                                    <td>{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}</td>
181
+                                    <td class="onoff-checkbox">
182
+                                        {{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}
183
+                                    </td>
180
                                     {% endif %}
184
                                     {% endif %}
181
                                 </tr>
185
                                 </tr>
182
                             {% endif %}
186
                             {% endif %}
203
                             <div class="panel-body">
207
                             <div class="panel-body">
204
                                 <div class="col-xs-6 col-sm-4 col-md-6">{{ _(plugin.description) }}</div>
208
                                 <div class="col-xs-6 col-sm-4 col-md-6">{{ _(plugin.description) }}</div>
205
                                 <div class="col-xs-6 col-sm-4 col-md-6">
209
                                 <div class="col-xs-6 col-sm-4 col-md-6">
210
+                                    <div class="onoff-checkbox">
206
                                     {{ checkbox_toggle('plugin_' + plugin.id, plugin.id not in allowed_plugins) }}
211
                                     {{ checkbox_toggle('plugin_' + plugin.id, plugin.id not in allowed_plugins) }}
212
+                                    </div>
207
                                 </div>
213
                                 </div>
208
                             </div>
214
                             </div>
209
                         </div>
215
                         </div>