radio buttons for attachments
authorJan Szejko <janek37@gmail.com>
Thu, 2 Feb 2017 13:04:23 +0000 (14:04 +0100)
committerJan Szejko <janek37@gmail.com>
Thu, 2 Feb 2017 13:04:23 +0000 (14:04 +0100)
src/editor/views/attachments/attachments.js

index 45366ff..31d8095 100644 (file)
@@ -28,17 +28,21 @@ var attachmentLibrary = function(callback, params) {
         dataType: 'json',
         success: function(data, status, jqxhr) {
             for (var i in data) {
         dataType: 'json',
         success: function(data, status, jqxhr) {
             for (var i in data) {
-                var img = $("<img style='margin-right: 1em'>")
+                var img = $("<img style='margin-right: 1em'>");
+                var input = $("<input type='radio' name='attachment'>");
+                var label = $("<label/>");
                 var div = $("<div style='border: 1px solid white'/>");
                 var div = $("<div style='border: 1px solid white'/>");
-                div.append(img);
-                div.append(data[i]['name'])
+                label.append(input);
+                label.append(img);
+                label.append(data[i]['name']);
                 img.attr("src", data[i]['thumbnail_url']);
                 img.attr("title", data[i]['name']);
                 img.attr("src", data[i]['thumbnail_url']);
                 img.attr("title", data[i]['name']);
+                input.attr('id', 'attachment' + i);
+                label.attr('for', 'attachment' + i);
+                div.append(label);
                 div.attr("data-output", 'file://' + data[i]['name']);
                 div.on('click', function() {
                 div.attr("data-output", 'file://' + data[i]['name']);
                 div.on('click', function() {
-                    $("div", body).attr('style', 'border: 1px solid white');
-                    $("div", body).removeClass('active');
-                    $(this).attr('style', 'border: 1px solid black');
+                    $("div.active", body).removeClass('active');
                     $(this).addClass('active');
                 });
                 body.append(div);
                     $(this).addClass('active');
                 });
                 body.append(div);