Browse Source

Merge pull request #654 from kvch/toggle-button

new toggle button - closes #284, #625
Adam Tauber 8 years ago
parent
commit
49403dbbda

+ 1
- 1
searx/static/themes/oscar/css/logicodev.min.css
File diff suppressed because it is too large
View File


+ 1
- 1
searx/static/themes/oscar/css/pointhi.min.css
File diff suppressed because it is too large
View File


+ 57
- 0
searx/static/themes/oscar/less/logicodev/onoff.less View File

@@ -0,0 +1,57 @@
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 View File

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

+ 57
- 0
searx/static/themes/oscar/less/pointhi/onoff.less View File

@@ -0,0 +1,57 @@
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 View File

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

+ 6
- 4
searx/templates/oscar/macros.html View File

@@ -68,9 +68,11 @@
68 68
 {%- endmacro %}
69 69
 
70 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 77
     </div>
76 78
 {%- endmacro %}

+ 8
- 2
searx/templates/oscar/preferences.html View File

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