Added rico.js to the javascript libraries

Added rename playlist functionality. (click wait click on a playlist,
type new name hit return) WARNING this will remove the smart playlist
spec, use it only on static playlists (which you can't even add through
the web interface)
This commit is contained in:
Anders Betnér 2006-03-27 20:26:12 +00:00
parent 453aa41077
commit 8b46f4f586
6 changed files with 2925 additions and 3 deletions

View File

@ -8,6 +8,7 @@
@ispage smart.html:<script type="text/javascript" src="smart.js"></script>:@ @ispage smart.html:<script type="text/javascript" src="smart.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@ @ispage playlist.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="lib-js/script.aculo.us/builder.js"></script>:@ @ispage playlist.html:<script type="text/javascript" src="lib-js/script.aculo.us/builder.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="lib-js/rico.js"></script>:@
@ispage playlist.html:<script type="text/javascript" src="playlist.js"></script>:@ @ispage playlist.html:<script type="text/javascript" src="playlist.js"></script>:@
<script type="text/javascript" src="mt-daapd.js"></script> <script type="text/javascript" src="mt-daapd.js"></script>
</head> </head>

View File

@ -3,6 +3,6 @@
SUBDIRS=script.aculo.us SUBDIRS=script.aculo.us
jslibdir = ${pkgdatadir}/admin-root/lib-js jslibdir = ${pkgdatadir}/admin-root/lib-js
jslib_DATA = prototype.js jslib_DATA = prototype.js rico.js
EXTRA_DIST = prototype.js EXTRA_DIST = prototype.js rico.js

2820
admin-root/lib-js/rico.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,12 @@
padding-left: 2ex; padding-left: 2ex;
padding-top: 1ex; padding-top: 1ex;
} }
#edit_playlist_name {
position: absolute;
font: icon;
width: 25ex;
display: none;
}
</style> </style>
<div id="search_div"> <div id="search_div">
<label for="search">search</label> <label for="search">search</label>
@ -41,7 +47,8 @@
<select id="source" name="select" size="20"> <select id="source" name="select" size="20">
<option value="1">Library</option> <option value="1">Library</option>
</select> </select><br />
<input type="text" id="edit_playlist_name" value="" />
<div id="busymsg" style="text-align:center;color:red; visibility: hidden;">Busy ...</div> <div id="busymsg" style="text-align:center;color:red; visibility: hidden;">Busy ...</div>
<a href="javascript:add()">Add static playlist</a> <a href="javascript:add()">Add static playlist</a>
</div> </div>

View File

@ -9,12 +9,32 @@ function initPlaylist() {
Query.send('genres'); Query.send('genres');
Event.observe('search','keypress',Search.keyPress); Event.observe('search','keypress',Search.keyPress);
Event.observe('source','change',EventHandler.sourceChange); Event.observe('source','change',EventHandler.sourceChange);
Event.observe('source','click',EventHandler.sourceClick);
Event.observe('genres','change',EventHandler.genresChange); Event.observe('genres','change',EventHandler.genresChange);
Event.observe('artists','change',EventHandler.artistsChange); Event.observe('artists','change',EventHandler.artistsChange);
Event.observe('albums','change',EventHandler.albumsChange); Event.observe('albums','change',EventHandler.albumsChange);
Event.observe(document,'click',GlobalEvents.click);
Event.observe('edit_playlist_name','keypress',EditPlaylistName.keyPress);
// Firefox remebers the search box value on page reload // Firefox remebers the search box value on page reload
Field.clear('search'); Field.clear('search');
} }
var GlobalEvents = {
_listeners: [],
click: function (e) {
GlobalEvents._listeners.each(function (name) {
name.click(e);
});
},
addListener: function (el) {
this._listeners.push(el);
},
removeListener: function (el) {
this._listeners = this._listeners.findAll(function (element) {
return (element != el);
});
}
}
// TODO // TODO
// Find a decent spinner instad of the busy text // Find a decent spinner instad of the busy text
// Handle 'all' in select boxes // Handle 'all' in select boxes
@ -34,8 +54,81 @@ var Search = {
} }
} }
}; };
var EditPlaylistName = {
playlistId: '',
playlistName: '',
_getOptionElement: function () {
return option = $A($('source').getElementsByTagName('option')).find(function (el) {
return (el.value == EditPlaylistName.playlistId);
});
},
keyPress: function (e) {
input = $('edit_playlist_name');
if (e.keyCode == Event.KEY_ESC) {
EditPlaylistName.hide();
}
if (e.keyCode == Event.KEY_RETURN) {
EditPlaylistName.save();
}
},
save: function () {
input = $('edit_playlist_name');
var url = '/databases/1/containers/edit?output=xml';
url += '&dmap.itemid=' + EditPlaylistName.playlistId;
url += '&dmap.itemname=' + input.value.encode();
new Ajax.Request(url ,{method: 'get',onComplete:EditPlaylistName.response});
var option = EditPlaylistName._getOptionElement();
option.text = input.value;
EditPlaylistName.hide();
},
show: function () {
input = $('edit_playlist_name');
input.style.top = RicoUtil.toViewportPosition(el).y+ 'px';
input.value = this.playlistName;
input.style.display = 'block';
Field.activate(input);
GlobalEvents.addListener(this);
},
hide: function () {
$('edit_playlist_name').style.display = 'none';
EditPlaylistName.playlistId = '';
GlobalEvents.removeListener(this);
},
response: function (request) {
},
click: function (e) {
if (EditPlaylistName.playlistId) {
// EditPlaylistName.save();
}
}
}
var EventHandler = { var EventHandler = {
sourceClickCount: [],
sourceClick: function (e) {
var playlistId = Event.element(e).value;
if (1 == playlistId) {
// do nothing for Library
return;
}
if (EventHandler.sourceClickCount[playlistId]) {
EventHandler.sourceClickCount[playlistId]++
} else {
EventHandler.sourceClickCount[playlistId] = 1;
}
if (EventHandler.sourceClickCount[playlistId] > 1) {
el = Event.element(e);
if (!el.text) {
// Firefox generates and event when clicking in and empty area
// of the select box
return;
}
EditPlaylistName.playlistId = el.value;
EditPlaylistName.playlistName = el.text;
EditPlaylistName.show();
}
},
sourceChange: function (e) { sourceChange: function (e) {
EventHandler.sourceClickCount = [];
Query.clearSelection('genres'); Query.clearSelection('genres');
Query.clearSelection('artists'); Query.clearSelection('artists');
Query.clearSelection('albums'); Query.clearSelection('albums');

View File

@ -87,6 +87,7 @@ Section "MainSection" SEC01
File "..\..\admin-root\applet.html" File "..\..\admin-root\applet.html"
SetOutPath "$INSTDIR\admin-root\lib-js" SetOutPath "$INSTDIR\admin-root\lib-js"
File "..\..\admin-root\lib-js\prototype.js" File "..\..\admin-root\lib-js\prototype.js"
File "..\..\admin-root\lib-js\rico.js"
SetOutPath "$INSTDIR\admin-root\lib-js\script.aculo.us" SetOutPath "$INSTDIR\admin-root\lib-js\script.aculo.us"
File "..\..\admin-root\lib-js\script.aculo.us\builder.js" File "..\..\admin-root\lib-js\script.aculo.us\builder.js"
File "..\..\admin-root\lib-js\script.aculo.us\controls.js" File "..\..\admin-root\lib-js\script.aculo.us\controls.js"