CC-2436: Save pulldown settings

Move the code that updates the database for the "show entries" dropdown to
a more appropriate place.
This commit is contained in:
Yuchen Wang 2011-11-16 16:12:58 -05:00
parent 4820bb617b
commit 1fd29def27
2 changed files with 38 additions and 38 deletions

View file

@ -574,7 +574,7 @@ class Application_Model_Preference
public static function GetCalendarTimeScale() { public static function GetCalendarTimeScale() {
$val = self::GetValue("calendar_time_scale", true /* user specific */); $val = self::GetValue("calendar_time_scale", true /* user specific */);
if(strlen($val) == 0) { if(strlen($val) == 0) {
$val = 'month'; $val = "month";
} }
return $val; return $val;
} }
@ -590,9 +590,14 @@ class Application_Model_Preference
/** /**
* Retrieves the number of entries to show preference in library under Playlist Builder. * Retrieves the number of entries to show preference in library under Playlist Builder.
* Defaults to 10 if no entry exists
*/ */
public static function GetLibraryNumEntries() { public static function GetLibraryNumEntries() {
return self::GetValue("library_num_entries", true /* user specific */); $val = self::GetValue("library_num_entries", true /* user specific */);
if(strlen($val) == 0) {
$val = "10";
}
return $val;
} }
/** /**

View file

@ -122,6 +122,7 @@ function dtRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
function dtDrawCallback() { function dtDrawCallback() {
addLibraryItemEvents(); addLibraryItemEvents();
addMetadataQtip(); addMetadataQtip();
saveNumEntriesSetting();
} }
function addProgressIcon(id) { function addProgressIcon(id) {
@ -280,15 +281,20 @@ function addMetadataQtip(){
} }
/** /**
* Use user preference for number of entries to show; * Updates pref db when user changes the # of entries to show
* defaults to 10 if preference was never set */
function saveNumEntriesSetting() {
$('select[name=library_display_length]').change(function() {
var url = '/Library/set-num-entries/format/json';
$.post(url, {numEntries: $(this).val()});
});
}
/**
* Use user preference for number of entries to show
*/ */
function getNumEntriesPreference(data) { function getNumEntriesPreference(data) {
var numEntries = data.libraryInit.numEntries; return parseInt(data.libraryInit.numEntries);
if(numEntries == '') {
numEntries = '10';
}
return parseInt(numEntries);
} }
function createDataTable(data) { function createDataTable(data) {
@ -327,24 +333,13 @@ function createDataTable(data) {
"bStateSave": true "bStateSave": true
}); });
dTable.fnSetFilteringDelay(350); dTable.fnSetFilteringDelay(350);
// Updates pref db when user changes the # of entries to show
$('select[name=library_display_length]').change(function() {
var url = '/Library/set-num-entries/format/json';
$.post(url, {numEntries: $(this).val()},
function(json){
if(json.error) {
alert(json.error);
}
});
});
} }
$(document).ready(function() { $(document).ready(function() {
$('.tabs').tabs(); $('.tabs').tabs();
$.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable $.ajax({ url: "/Api/library-init/format/json", dataType:"json", success:createDataTable,
, error:function(jqXHR, textStatus, errorThrown){}}); error:function(jqXHR, textStatus, errorThrown){}});
checkImportStatus() checkImportStatus()
setInterval( "checkImportStatus()", 5000 ); setInterval( "checkImportStatus()", 5000 );