+ confirmDialog: function(view, event, callback) {
+ $("#xos-confirm-dialog").dialog({
+ autoOpen: false,\r
+ modal: true,\r
+ buttons : {\r
+ "Confirm" : function() {\r
+ $(this).dialog("close");\r
+ if (event) {\r
+ view.trigger(event);\r
+ }\r
+ if (callback) {\r
+ callback();\r
+ }\r
+ },\r
+ "Cancel" : function() {\r
+ $(this).dialog("close");\r
+ }\r
+ }\r
+ });
+ $("#xos-confirm-dialog").dialog("open");
+ },
+
+ popupErrorDialog: function(responseText) {
+ try {
+ parsed_error=$.parseJSON(responseText);
+ width=300;
+ }
+ catch(err) {
+ parsed_error=undefined;
+ width=640; // django stacktraces like wide width
+ }
+ if (parsed_error) {
+ $("#xos-error-dialog").html(templateFromId("#xos-error-response")(parsed_error));
+ } else {
+ $("#xos-error-dialog").html(templateFromId("#xos-error-rawresponse")({responseText: responseText}))
+ }
+
+ $("#xos-error-dialog").dialog({
+ modal: true,
+ width: width,
+ buttons: {
+ Ok: function() { $(this).dialog("close"); }
+ }
+ });
+ },
+
+ hideLinkedItems: function(result) {
+ var index=0;
+ while (index<4) {\r
+ this["linkedObjs" + (index+1)].empty();\r
+ index = index + 1;\r
+ }\r
+ },\r
+\r
+ listViewShower: function(listViewName, collection_name, regionName, title) {\r
+ var app=this;\r
+ return function() {\r
+ app[regionName].show(new app[listViewName]);\r
+ app.hideLinkedItems();\r
+ $("#contentTitle").html(templateFromId("#xos-title-list")({"title": title}));\r
+ $("#detail").show();\r
+ $("#xos-listview-button-box").show();\r
+ $("#tabs").hide();\r
+ $("#xos-detail-button-box").hide();\r
+ }\r
+ },\r
+\r
+ addShower: function(detailName, collection_name, regionName, title) {\r
+ var app=this;\r
+ return function() {\r
+ model = new xos[collection_name].model();\r
+ detailViewClass = app[detailName];\r
+ detailView = new detailViewClass({model: model, collection:xos[collection_name]});\r
+ app[regionName].show(detailView);\r
+ $("#xos-detail-button-box").show();\r
+ $("#xos-listview-button-box").hide();\r
+ }\r
+ },\r
+\r
+ detailShower: function(detailName, collection_name, regionName, title) {\r
+ var app=this;\r
+ showModelId = function(model_id) {\r
+ $("#contentTitle").html(templateFromId("#xos-title-detail")({"title": title}));\r
+\r
+ collection = xos[collection_name];\r
+ model = collection.get(model_id);\r
+ if (model == undefined) {\r
+ app[regionName].show(new HTMLView({html: "failed to load object " + model_id + " from collection " + collection_name}));\r
+ } else {\r
+ detailViewClass = app[detailName];\r
+ detailView = new detailViewClass({model: model});\r
+ app[regionName].show(detailView);\r
+ detailView.showLinkedItems();\r
+ $("#xos-detail-button-box").show();\r
+ $("#xos-listview-button-box").hide();\r
+ }\r
+ }\r
+ return showModelId;\r
+ },\r
+\r
+ /* error handling callbacks */\r
+\r
+ hideError: function() {\r