Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[ljcom] r11659: LJSUP-11421: Cliend-side development for...

Committer: vkurkin
LJSUP-11421: Cliend-side development for Trava.ru
U   trunk/htdocs/js/editprofile.js
Modified: trunk/htdocs/js/editprofile.js
===================================================================
--- trunk/htdocs/js/editprofile.js	2012-03-30 08:16:05 UTC (rev 11658)
+++ trunk/htdocs/js/editprofile.js	2012-03-30 08:39:35 UTC (rev 11659)
@@ -378,4 +378,59 @@
 		})
 		// recalc after refresh
 		.filter(':checked').change();
-});
+
+	$(function () {
+		var uid = jQuery('#trava_uid').val();
+
+		if (!uid) {
+			return;
+		}
+
+		var element = jQuery('.music-settings-manage');
+		var select = jQuery('#music-settings-playlist-selection');
+		var playlistID = jQuery('#playlist_id');
+		var playlistName = jQuery('#playlist_name');
+		var state = {
+			error: 'music-settings-manage-state-system-error',
+			loading: 'music-settings-manage-state-loading',
+			loaded: 'music-settings-manage-state-loaded'
+		};
+
+		element.bind('travagetplaylists',
+			function (evt, data) {
+				jQuery(this).removeClass(state.loading);
+
+				if (data && data.playlists) {
+					var playlists = data.playlists;
+					var length = playlists.length;
+					var index = 0;
+					var playlist;
+
+					select.empty();
+					while (index < length) {
+						playlist = playlists[index++];
+						select.append('<option value="' + playlist.id + '">' + playlist.title + '</option>');
+					}
+
+					jQuery(this).addClass(state.loaded);
+				} else {
+					jQuery(this).addClass(state.error);
+				}
+			}).trava({
+				uid: uid
+			}).trava('getPlaylists');
+
+		jQuery('#music-settings-playlist-confirm').bind('click', function (evt) {
+			var selectedItem = select.find('option').eq(select.prop('selectedIndex'));
+
+			evt.preventDefault();
+			playlistID.val(selectedItem.val());
+			playlistName.text(selectedItem.text());
+		});
+
+		element.find('.music-playlist-system-error a').bind('click', function (evt) {
+			evt.preventDefault();
+			element.removeClass(state.error).addClass(state.loading).trava('getPlaylists');
+		});
+	});
+});
\ No newline at end of file

Tags: b_vladi, js, ljcom, vkurkin
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments