Browse Source

Add live style previews to profile edit page

spaghetti 8 years ago
parent
commit
8121e03890

+ 4
- 6
sections/user/edit.php View File

@@ -145,13 +145,11 @@ echo $Val->GenerateJS('userform');
145 145
 <?  foreach ($Stylesheets as $Style) { ?>
146 146
             <div class="preview_wrapper">
147 147
               <div class="preview_image" name="<?=($Style['Name'])?>">
148
-                <a href="<?=STATIC_SERVER.'stylespreview/full_'.$Style['Name'].'.png'?>" target="_blank">
149
-                  <img src="<?=STATIC_SERVER.'stylespreview/thumb_'.$Style['Name'].'.png'?>" alt="<?=$Style['Name']?>" />
150
-                </a>
148
+                <img src="<?=STATIC_SERVER.'stylespreview/thumb_'.$Style['Name'].'.png'?>" alt="<?=$Style['Name']?>" />
149
+                <p class="preview_name">
150
+                  <label><input type="radio" name="stylesheet_gallery" value="<?=($Style['ID'])?>" /> <?=($Style['ProperName'])?></label>
151
+                </p>
151 152
               </div>
152
-              <p class="preview_name">
153
-                <label><input type="radio" name="stylesheet_gallery" value="<?=($Style['ID'])?>" /> <?=($Style['ProperName'])?></label>
154
-              </p>
155 153
             </div>
156 154
 <?  } ?>
157 155
           </div>

+ 31
- 0
static/functions/cssgallery.js View File

@@ -14,8 +14,13 @@ $(document).ready(function () {
14 14
     var radiobutton = parent.find('input');
15 15
     radiobutton.prop('checked', true);
16 16
     $('select#stylesheet').val(radiobutton.attr('value'));
17
+    $('select#stylesheet').change();
17 18
     $('input#styleurl').val('');
18 19
   })
20
+  // Passthrough image click to radio button
21
+  $('.preview_image').click(function(e) {
22
+    e.currentTarget.children[1].children[0].children[0].click()
23
+  })
19 24
   // If the drop-down is changed, select the appropriate item in gallery, clear the custom CSS field
20 25
   $('select#stylesheet').change(function() {
21 26
     var radiobutton = $('input[name="stylesheet_gallery"][value="' + $(this).val() + '"]');
@@ -44,4 +49,30 @@ $(document).ready(function () {
44 49
       $('#toggle_css_gallery').text($(this).is(':visible') ? 'Hide gallery' : 'Show gallery');
45 50
     });
46 51
   });
52
+  document.querySelectorAll('[name=style_additions\\[\\]]').forEach(function(el) {
53
+    el.addEventListener('change', function(e) {
54
+      if (e.target.checked) {
55
+        document.body.classList.add('style_'+e.target.value)
56
+      } else {
57
+        document.body.classList.remove('style_'+e.target.value)
58
+      }
59
+    })
60
+  })
61
+  var userstyle = $('link[rel=stylesheet][title]')[0]
62
+  $('select#stylesheet').on('change', function(e) {
63
+    var changetext = e.target.options[e.target.selectedIndex].text.toLowerCase()
64
+    userstyle.href = userstyle.href.replace(/\/[^\/]+?\/style.css/, '/'+changetext+'/style.css')
65
+    $('.style_addition').each(function(i, el){
66
+      if (el.id == 'style_addition_'+changetext) {
67
+        if (el.children.length) {
68
+          el.classList.remove('hidden')
69
+          $('#style_additions_tr')[0].classList.remove('hidden')
70
+        } else {
71
+          $('#style_additions_tr')[0].classList.add('hidden')
72
+        }
73
+      } else {
74
+        el.classList.add('hidden')
75
+      }
76
+    })
77
+  })
47 78
 });

+ 1
- 1
static/functions/user_settings.js View File

@@ -145,4 +145,4 @@ function fetchPushbulletDevices(apikey) {
145 145
       $('#pushdevice').html('<option>' + textStatus + '</option>');
146 146
     }
147 147
   });
148
-}
148
+}

+ 1
- 3
static/styles/global.css View File

@@ -518,13 +518,11 @@ tr.torrent .bookmark>a:after {
518 518
 .preview_wrapper {
519 519
   position: relative;
520 520
   display: inline-block;
521
-  width: 29%;
522
-  height: 120px;
521
+  width: 40%;
523 522
   margin: 0 10px;
524 523
 }
525 524
 .preview_image {
526 525
   display: block;
527
-  height: 80px;
528 526
   cursor: pointer;
529 527
   overflow: hidden;
530 528
 }

BIN
static/stylespreview/full_beluga-oppai.png View File


BIN
static/stylespreview/full_beluga.png View File


BIN
static/stylespreview/full_oppai.png View File


BIN
static/stylespreview/thumb_beluga-oppai.png View File


Loading…
Cancel
Save