#69 Add autocomplete to artist fields in upload and torrent search page

Open
xoru wants to merge 6 commits from xoru/Gazelle:upload-artist-autocomplete into master

+ 2
- 2
classes/torrent_form.class.php View File

@@ -242,13 +242,13 @@ Source: <input type="text" value="<?=Users::get_upload_sources()[0]?>" size="20"
242 242
         <td id="idolfields">
243 243
 <?      if (!empty($Torrent['Artists'])) {
244 244
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
245
-            <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?>/>
245
+            <input type="text" id="idols_<?=$Num?>" name="idols[]" size="45" value="<?=display_str($Artist['name'])?>" <?=$this->Disabled?><? Users::has_autocomplete_enabled('other'); ?>/>
246 246
             <? if ($Num == 0) { ?>
247 247
               <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
248 248
             <? }
249 249
             }
250 250
           } else { ?>
251
-            <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?> />
251
+            <input type="text" id="idols_0" name="idols[]" size="45" value="" <?=$this->Disabled?><? Users::has_autocomplete_enabled('other'); ?>/>
252 252
             <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
253 253
 <?        } ?>
254 254
         </td>

+ 1
- 1
sections/torrents/browse.php View File

@@ -166,7 +166,7 @@ View::show_header('Browse Torrents', 'browse');
166 166
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
167 167
           <td class="label"><!--Artist name:--></td>
168 168
           <td class="ft_artistname">
169
-            <input type="search" spellcheck="false" size="65" name="artistname" class="inputtext smaller fti_advanced" placeholder="Artist name" value="<?Format::form('artistname')?>" />
169
+            <input type="search" spellcheck="false" size="65" id="artist" name="artistname" class="inputtext smaller fti_advanced" placeholder="Artist name" value="<?Format::form('artistname')?>"<? Users::has_autocomplete_enabled('other'); ?>/>
170 170
           </td>
171 171
         </tr>
172 172
         <tr id="album_torrent_name" class="ftr_advanced<?=$HideAdvanced?>">

+ 1
- 1
sections/torrents/editgroup.php View File

@@ -173,7 +173,7 @@ if ($CategoryID == 1) {
173 173
 ?>
174 174
         </td>
175 175
         <td id="idolfields">
176
-          <input type="text" id="idol_0" name="idols[]" size="45" value="<?=$Artists[0]['name']?>"/>
176
+          <input type="text" id="idols_0" name="idols[]" size="45" value="<?=$Artists[0]['name']?>"<? Users::has_autocomplete_enabled('other'); ?>/>
177 177
           <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
178 178
 <?
179 179
   for ($i = 1; $i < count($Artists); $i++) {

+ 13
- 5
static/functions/autocomplete.js View File

@@ -24,15 +24,11 @@ function initAutocomplete() {
24 24
     serviceUrl : ARTIST_AUTOCOMPLETE_URL,
25 25
   });
26 26
 
27
-  if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist' || (url.path == 'requests' && url.query['action'] == 'new') || url.path == 'collages') {
27
+  if (url.path == 'torrents' || url.path == 'upload' || url.path == 'artist' || (url.path == 'requests' && url.query['action'] == 'new')) {
28 28
     $("#artist" + SELECTOR).autocomplete({
29 29
       deferRequestBy: 300,
30 30
       serviceUrl : ARTIST_AUTOCOMPLETE_URL
31 31
     });
32
-    $("#artistsimilar" + SELECTOR).autocomplete({
33
-      deferRequestBy: 300,
34
-      serviceUrl : ARTIST_AUTOCOMPLETE_URL
35
-    });
36 32
   }
37 33
   if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
38 34
     $("#tags" + SELECTOR).autocomplete({
@@ -46,5 +42,17 @@ function initAutocomplete() {
46 42
       serviceUrl : TAGS_AUTOCOMPLETE_URL
47 43
     });
48 44
   }
45
+  if (url.path == 'upload' || (url.path == 'torrents' && url.query['action'] == 'editgroup')) {
46
+    $("#idols_0" + SELECTOR).autocomplete({
47
+      deferRequestBy: 300,
48
+      serviceUrl : ARTIST_AUTOCOMPLETE_URL
49
+    });
50
+  }
51
+  if (url.path == 'requests' && url.query['action'] == 'new') {
52
+    $("#artist_0" + SELECTOR).autocomplete({
53
+      deferRequestBy: 300,
54
+      serviceUrl : ARTIST_AUTOCOMPLETE_URL
55
+    });
56
+  }
49 57
 
50 58
 };

+ 4
- 3
static/functions/requests.js View File

@@ -95,10 +95,11 @@ function AddArtistField() {
95 95
     x.appendChild(document.createElement("br"));
96 96
     x.appendChild(ArtistField);
97 97
 
98
-    if ($("#artist").data("gazelle-autocomplete")) {
99
-      $(ArtistField).live('focus', function() {
98
+    if ($("#artist_0").data("gazelle-autocomplete")) {
99
+      $(ArtistField).on('focus', function() {
100 100
         $(ArtistField).autocomplete({
101
-          serviceUrl : 'artist.php?action=autocomplete'
101
+          deferRequestBy: 300,
102
+          serviceUrl : ARTIST_AUTOCOMPLETE_URL
102 103
         });
103 104
       });
104 105
     }

+ 4
- 3
static/functions/upload.js View File

@@ -307,10 +307,11 @@ function AddArtistField() {
307 307
   x.appendChild(ArtistField);
308 308
   x.appendChild(document.createTextNode('\n'));
309 309
 
310
-  if ($("#idol").data("gazelle-autocomplete")) {
311
-    $(ArtistField).live('focus', function() {
310
+  if ($("#idols_0").data("gazelle-autocomplete")) {
311
+    $(ArtistField).on('focus', function() {
312 312
       $(ArtistField).autocomplete({
313
-        serviceUrl : 'artist.php?action=autocomplete'
313
+        deferRequestBy: 300,
314
+        serviceUrl : ARTIST_AUTOCOMPLETE_URL
314 315
       });
315 316
     });
316 317
   }

Loading…
Cancel
Save