This commit is contained in:
rolux 2010-07-24 03:30:08 +02:00
parent 7e789242a1
commit b264794968

View file

@ -107,7 +107,7 @@ $(function() {
{ id: "size", admin: true }, { id: "size", admin: true },
{ id: "pixels" } { id: "pixels" }
], ],
userSettings: { user: {
group: "guest", group: "guest",
ui: { ui: {
columns: ["id", "title", "director", "country", "year", "language", "runtime", "genre", "releasedate"], columns: ["id", "title", "director", "country", "year", "language", "runtime", "genre", "releasedate"],
@ -132,7 +132,7 @@ $(function() {
username: "" username: ""
} }
}, },
user = config.userSettings, user = config.user,
$ui = { $ui = {
groups: [] groups: []
}, },
@ -291,6 +291,14 @@ $(function() {
requestURL: "/api/" requestURL: "/api/"
}); });
$("<script>")
.attr({
src: "http://maps.google.com/maps/api/js?callback=foo&sensor=false",
type: "text/javascript"
})
.appendTo($body);
foo = function() {};
// MainMenu // MainMenu
$ui.mainMenu = new Ox.MainMenu({ $ui.mainMenu = new Ox.MainMenu({
@ -312,10 +320,10 @@ $(function() {
{ id: "user", title: "User", items: [ { id: "user", title: "User", items: [
{ id: "username", title: "User: not logged in", disabled: true }, { id: "username", title: "User: not logged in", disabled: true },
{}, {},
{ id: "preferences", title: "Preferences", disabled: true, keyboard: "control ," }, { id: "preferences", title: "Preferences...", disabled: true, keyboard: "control ," },
{}, {},
{ id: "register", title: "Create an Account..." }, { id: "register", title: "Create an Account..." },
{ id: "login", title: "Login..." } { id: "loginlogout", title: ["Login...", "Logout..."] }
] }, ] },
{ id: "list", title: "List", items: [ { id: "list", title: "List", items: [
{ id: "history", title: "History", items: [ { id: "history", title: "History", items: [
@ -403,6 +411,19 @@ $(function() {
}) }, }) },
{ id: "advancedfind", title: "Advanced Find...", keyboard: "shift control f" } { id: "advancedfind", title: "Advanced Find...", keyboard: "shift control f" }
] }, ] },
{ id: "data", title: "Data", items: [
{ id: "titles", title: "Manage Titles..." },
{ id: "names", title: "Manage Names..." },
{},
{ id: "posters", title: "Manage Stills..." },
{ id: "posters", title: "Manage Posters..." },
{},
{ id: "places", title: "Manage Places..." },
{ id: "events", title: "Manage Events..." },
{},
{ id: "users", title: "Manage Users..." },
{ id: "lists", title: "Manage Lists..." },
] },
{ id: "code", title: "Code", items: [ { id: "code", title: "Code", items: [
{ id: "download", title: "Download" }, { id: "download", title: "Download" },
{ id: "contribute", title: "Contribute" }, { id: "contribute", title: "Contribute" },
@ -759,42 +780,94 @@ $ui.statusbar = new Ox.Bar({
title: "About" title: "About"
}).open(); }).open();
}); });
Ox.Event.bind("click_login", function(event, data) { Ox.Event.bind("click_home", function(event, data) {
/* var $dialog = new Ox.Dialog({
var $form = $("<div>"), buttons: [
$username = new Ox.Input({ {
id: "username", click: function() {
label: "Username", $dialog.close();
labelWidth: 96, },
}).width(256).appendTo($form), id: "close",
$password = new Ox.Input({ value: "Close"
id: "password", }
label: "Password", ],
labelWidth: 96, height: 498,
type: "password" id: "home",
}).width(256).css({ marginTop: "8px" }).appendTo($form), title: config.appName,
*/ width: 800
}).open();
});
Ox.Event.bind("click_loginlogout", function(event, data) {
var $form = new Ox.Form({ var $form = new Ox.Form({
error: "Unknown username or wrong password", error: "Unknown username or wrong password",
id: "login",
items: [ items: [
{ {
element: new Ox.Input({ element: new Ox.Input({
autocorrect: function(value, blur) {
var length = value.length;
value = $.map(value.toLowerCase().split(""), function(v, i) {
if (new RegExp("[a-z0-9" + ((i == 0 || (i == length - 1 && blur)) ? "" : "\- ") + "]")(v)) {
return v
} else {
return null;
}
}).join("");
$.each(["--", "- ", " -", "--"], function(i, v) {
while (value.indexOf(v) > -1) {
value = value.replace(new RegExp(v, "g"), v[0]);
}
})
return value;
},
id: "username", id: "username",
label: "Username", label: "Username",
labelWidth: 96, labelWidth: 120,
}).width(256), validate: function(value, callback) {
regexp: /.+/ app.request("findUser", {
key: "username",
value: value,
operator: "="
}, function(result) {
Ox.print("result", result)
var valid = result.data.users.length == 1;
callback({
message: "Unknown Username",
valid: valid
});
});
}
}).width(300)
}, },
{ {
element: new Ox.Input({ element: new Ox.Input({
id: "password", id: "password",
label: "Password", label: "Password",
labelWidth: 96, labelWidth: 120,
type: "password" type: "password",
}).width(256), validate: /.+/
regexp: /.+/ }).width(300)
} }
] ],
submit: function(data, callback) {
app.request("login", data, function(result) {
if (result.status.code == 200) {
$dialog.close();
user = result.data.user;
$ui.mainMenu.getItem("username").options({
title: "User: " + user.username
});
$ui.mainMenu.getItem("preferences").options({
disabled: false
});
$ui.mainMenu.getItem("register").options({
disabled: true
});
} else {
callback([{ id: "password", message: "Incorrect Password" }]);
}
});
}
}), }),
$dialog = new Ox.Dialog({ $dialog = new Ox.Dialog({
buttons: [ buttons: [
@ -803,8 +876,8 @@ $ui.statusbar = new Ox.Bar({
click: function() { click: function() {
}, },
id: "create", id: "signup",
value: "Create Account..." value: "Sign up..."
}, },
{ {
click: function() { click: function() {
@ -818,23 +891,27 @@ $ui.statusbar = new Ox.Bar({
{ {
click: function() { click: function() {
$dialog.close(); $dialog.close();
$ui.mainMenu.getItem("loginlogout").toggleTitle();
}, },
id: "cancel", id: "cancel",
value: "Cancel" value: "Cancel"
}, },
{ {
click: function() { click: $form.submit,
},
disabled: true, disabled: true,
id: "login", id: "signin",
value: "Login" value: "Sign in"
} }
] ]
], ],
id: "login", id: "login",
title: "Login" minWidth: 332,
title: "Sign in",
width: 332
}).append($form).open(); }).append($form).open();
Ox.Event.bind("validate_login", function(event, data) {
$dialog[(data.valid ? "enable" : "disable") + "Button"]("signin");
});
}); });
Ox.Event.bind("change_viewmovies", function(event, data) { Ox.Event.bind("change_viewmovies", function(event, data) {
$ui.viewSelect.selectItem(data.id); $ui.viewSelect.selectItem(data.id);
@ -852,6 +929,33 @@ $ui.statusbar = new Ox.Bar({
Ox.Event.bind("change_find", function(event, data) { Ox.Event.bind("change_find", function(event, data) {
$ui.findInput.changeLabel(data.id); $ui.findInput.changeLabel(data.id);
}); });
Ox.Event.bind("click_places", function(event, data) {
var $map = new Ox.Map({
places: ["Boston", "Barcelona", "Berlin", "Beirut", "Bombay", "Bangalore", "Beijing"]
}).css({
height: "100%",
width: "100%"
}),
$dialog = new Ox.Dialog({
buttons: [
{
click: function() {
$dialog.close();
},
id: "close",
title: "Close",
value: "Close"
}
],
height: 498,
id: "places",
minHeight: 400,
minWidth: 600,
padding: 0,
title: "Manage Places",
width: 800
}).append($map).open(),
});
Ox.Event.bind("click_query", function(event, data) { Ox.Event.bind("click_query", function(event, data) {
var $dialog = new Ox.Dialog({ var $dialog = new Ox.Dialog({
buttons: [ buttons: [
@ -1075,21 +1179,25 @@ $ui.statusbar = new Ox.Bar({
}, function(result) { }, function(result) {
var item = result.data.items[0], var item = result.data.items[0],
title = item.title + (item.director ? " (" + item.director + ")" : ""), title = item.title + (item.director ? " (" + item.director + ")" : ""),
height = $window.height() - 40, documentHeight = $document.height(),
width = height * 0.75, dialogHeight = documentHeight - 40,
dialogWidth = parseInt((dialogHeight - 48) * 0.75),
$image = $("<img>") $image = $("<img>")
.attr({ .attr({
src: "http://0xdb.org/" + item.id + "/poster.large.jpg" src: "http://0xdb.org/" + item.id + "/poster.large.jpg"
}) })
.css({ .css({
height: height + "px", height: (dialogHeight - 48) + "px",
width: width + "px", width: dialogWidth + "px"
margin: "-16px -16px -16px -16px"
}) })
.one("load", function() { .load(function() {
var image = $image[0], var image = $image[0],
imageHeight = image.height, imageHeight = Math.min(image.height, documentHeight - 88),
imageWidth = image.width; imageWidth = parseInt(image.width * imageHeight / image.height);
$ui.previewDialog.options({
height: imageHeight + 48,
width: imageWidth
});
$image.css({ $image.css({
height: imageHeight + "px", height: imageHeight + "px",
width: imageWidth + "px" width: imageWidth + "px"
@ -1122,9 +1230,10 @@ $ui.statusbar = new Ox.Bar({
} }
} }
], ],
height: height, height: dialogHeight,
padding: 0,
title: title, title: title,
width: width width: dialogWidth
}) })
.append($image) .append($image)
.open(); .open();