Go live/add to service via list

This commit is contained in:
Jonathan Corwin 2011-05-20 23:30:20 +01:00
parent d4e83ae45a
commit bbbf0d3435
3 changed files with 15 additions and 11 deletions

View File

@ -757,7 +757,7 @@ class ServiceManager(QtGui.QWidget):
""" """
Called by a signal to select a specific item. Called by a signal to select a specific item.
""" """
self.setItem(int(message[0])) self.setItem(int(message))
def setItem(self, index): def setItem(self, index):
""" """

View File

@ -109,7 +109,7 @@
<input type="search" name="search-text" id="search-text" value="" /> <input type="search" name="search-text" id="search-text" value="" />
</div> </div>
<a href="#" id="search-submit" data-role="button">Search</a> <a href="#" id="search-submit" data-role="button">Search</a>
<ul data-role="listview" data-inset="true" data-split-icon="plus"> <ul data-role="listview" data-inset="true">
</div> </div>
</div> </div>
</body> </body>

View File

@ -219,22 +219,23 @@ window.OpenLP = {
} }
else { else {
$.each(data.results.items, function (idx, value) { $.each(data.results.items, function (idx, value) {
var li = $("<li>"); var li = $("<li><ul>").text(value[1]);
li.append($("<a href=\"#\">").text(value[1]).click(function () { li.append($("<ul><li><a id=\"go-live\" href=\"#\">Go Live</a></li>" +
OpenLP.goLive(value[0]); "<li><a id =\"add-service\" href=\"#\">Add To Service</a></li></ul>"));
})); li.find("a").attr("value", value[0]);
li.append($("<a href=\"#\">").click(function () {
OpenLP.addToService(value[0]);
}));
ul.append(li); ul.append(li);
}); });
ul.find("#go-live").click(OpenLP.goLive);
ul.find("#add-service").click(OpenLP.addToService);
} }
ul.listview("refresh"); ul.listview("refresh");
} }
); );
return false; return false;
}, },
goLive: function (id) { goLive: function (event) {
var item = OpenLP.getElement(event);
var id = item.attr("value");
var text = JSON.stringify({"request": {"id": id}}); var text = JSON.stringify({"request": {"id": id}});
$.getJSON( $.getJSON(
"/api/" + $("#search-plugin").val() + "/live", "/api/" + $("#search-plugin").val() + "/live",
@ -242,11 +243,14 @@ window.OpenLP = {
$.mobile.changePage("slide-controller"); $.mobile.changePage("slide-controller");
return false; return false;
}, },
addToService: function (id) { addToService: function (event) {
var item = OpenLP.getElement(event);
var id = item.attr("value");
var text = JSON.stringify({"request": {"id": id}}); var text = JSON.stringify({"request": {"id": id}});
$.getJSON( $.getJSON(
"/api/" + $("#search-plugin").val() + "/add", "/api/" + $("#search-plugin").val() + "/add",
{"data": text}) {"data": text})
history.back();
return false; return false;
} }
} }