#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
         <td id="idolfields">
242
         <td id="idolfields">
243
 <?      if (!empty($Torrent['Artists'])) {
243
 <?      if (!empty($Torrent['Artists'])) {
244
           foreach ($Torrent['Artists'] as $Num => $Artist) { ?>
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
             <? if ($Num == 0) { ?>
246
             <? if ($Num == 0) { ?>
247
               <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
247
               <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
248
             <? }
248
             <? }
249
             }
249
             }
250
           } else { ?>
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
             <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
252
             <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
253
 <?        } ?>
253
 <?        } ?>
254
         </td>
254
         </td>

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

166
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
166
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
167
           <td class="label"><!--Artist name:--></td>
167
           <td class="label"><!--Artist name:--></td>
168
           <td class="ft_artistname">
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
           </td>
170
           </td>
171
         </tr>
171
         </tr>
172
         <tr id="album_torrent_name" class="ftr_advanced<?=$HideAdvanced?>">
172
         <tr id="album_torrent_name" class="ftr_advanced<?=$HideAdvanced?>">

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

173
 ?>
173
 ?>
174
         </td>
174
         </td>
175
         <td id="idolfields">
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
           <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
177
           <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
178
 <?
178
 <?
179
   for ($i = 1; $i < count($Artists); $i++) {
179
   for ($i = 1; $i < count($Artists); $i++) {

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

24
     serviceUrl : ARTIST_AUTOCOMPLETE_URL,
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
     $("#artist" + SELECTOR).autocomplete({
28
     $("#artist" + SELECTOR).autocomplete({
29
       deferRequestBy: 300,
29
       deferRequestBy: 300,
30
       serviceUrl : ARTIST_AUTOCOMPLETE_URL
30
       serviceUrl : ARTIST_AUTOCOMPLETE_URL
31
     });
31
     });
32
-    $("#artistsimilar" + SELECTOR).autocomplete({
33
-      deferRequestBy: 300,
34
-      serviceUrl : ARTIST_AUTOCOMPLETE_URL
35
-    });
36
   }
32
   }
37
   if (url.path == 'torrents' || url.path == 'upload' || url.path == 'collages' || url.path == 'requests' || url.path == 'top10' || (url.path == 'requests' && url.query['action'] == 'new')) {
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
     $("#tags" + SELECTOR).autocomplete({
34
     $("#tags" + SELECTOR).autocomplete({
46
       serviceUrl : TAGS_AUTOCOMPLETE_URL
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
     x.appendChild(document.createElement("br"));
95
     x.appendChild(document.createElement("br"));
96
     x.appendChild(ArtistField);
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
         $(ArtistField).autocomplete({
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
   x.appendChild(ArtistField);
307
   x.appendChild(ArtistField);
308
   x.appendChild(document.createTextNode('\n'));
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
       $(ArtistField).autocomplete({
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