Browse Source

Merge pull request #75 from Vindexus/icon-preview

Added icon preview to the dropdown typeahead
Robert Autenrieth 8 years ago
parent
commit
d431862066
2 changed files with 40 additions and 1 deletions
  1. 19
    0
      generator/css/ui.css
  2. 21
    1
      generator/js/ui.js

+ 19
- 0
generator/css/ui.css View File

@@ -59,4 +59,23 @@
59 59
 
60 60
 .form-horizontal {
61 61
     margin-top: 10px;
62
+}
63
+
64
+
65
+.dropdown-menu>li>a {
66
+    padding-left: 35px;
67
+    position: relative;
68
+}
69
+
70
+.dropdown-menu a > span {
71
+    position: absolute;
72
+    left: 5px;
73
+    background-color: #000;
74
+    background-repeat: no-repeat;
75
+    background-position: center center;
76
+    width: 24px;
77
+    height: 24px;
78
+    background-size: auto 90%;
79
+    top: 50%;
80
+    margin-top: -12px;
62 81
 }

+ 21
- 1
generator/js/ui.js View File

@@ -456,7 +456,27 @@ function local_store_load() {
456 456
 $(document).ready(function () {
457 457
     local_store_load();
458 458
     ui_setup_color_selector();
459
-    $('.icon-list').typeahead({source:icon_names});
459
+    $('.icon-list').typeahead({
460
+        source:icon_names,
461
+        items: 'all',
462
+        render: function (items) {
463
+          var that = this;
464
+
465
+          items = $(items).map(function (i, item) {
466
+            i = $(that.options.item).data('value', item);
467
+            i.find('a').html(that.highlighter(item));
468
+            var classname = 'icon-' + item.split(' ').join('-').toLowerCase()
469
+            i.find('a').append('<span class="' + classname + '"></span>')
470
+            return i[0];
471
+          });
472
+
473
+          if (this.autoSelect) {
474
+            items.first().addClass('active');
475
+          }
476
+          this.$menu.html(items);
477
+          return this;
478
+        }
479
+    });
460 480
 
461 481
     $("#button-generate").click(ui_generate);
462 482
     $("#button-load").click(function () { $("#file-load").click(); });

Loading…
Cancel
Save