From accc5e5286728e65a913ad5cbc31e3f282ecf045 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Thu, 22 Nov 2012 02:06:55 +0100 Subject: [PATCH] fixed #69 --- Mac/ViewDelegate.m | 10 +++++++++ WebKit/css/default.css | 15 +++++++------- WebKit/scripts/controller/Oauth.js | 2 +- WebKit/scripts/controller/Timeline.js | 6 ++++++ WebKit/scripts/helper/Core.js | 30 ++++++++++++++++++++++++--- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Mac/ViewDelegate.m b/Mac/ViewDelegate.m index 4bc16ba..aa3d466 100644 --- a/Mac/ViewDelegate.m +++ b/Mac/ViewDelegate.m @@ -39,6 +39,16 @@ NSLog(@"jsa<%@>: %@", viewName, message); } +- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame { + NSInteger result = NSRunCriticalAlertPanel(NSLocalizedString(@"Tentia", @""), // title + message, // message + NSLocalizedString(@"OK", @""), // default button + NSLocalizedString(@"Cancel", @""), // alt button + nil); + return NSAlertDefaultReturn == result; + return NO; +} + - (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id )listener { [listener ignore]; [[NSWorkspace sharedWorkspace] openURL:[request URL]]; diff --git a/WebKit/css/default.css b/WebKit/css/default.css index cce3efd..fc84b85 100644 --- a/WebKit/css/default.css +++ b/WebKit/css/default.css @@ -134,12 +134,6 @@ p { margin-right: 5px; } -.delete { - font-weight: normal; - color: #555; - font-size: 1.2em; -} - .direct-message { color: #555; } @@ -231,7 +225,7 @@ li:first-child:hover .date { border-top: 0; } -.reply_to, .retweet { +.reply_to, .retweet, .remove { width: 15px; height: 12px; position: absolute; @@ -241,7 +235,7 @@ li:first-child:hover .date { display: none; } -li:hover .reply_to, li:hover .retweet { +li:hover .reply_to, li:hover .retweet, li:hover .remove { display: block; } @@ -249,3 +243,8 @@ li:hover .reply_to, li:hover .retweet { top: 18px; background-position: -192px 0; } + +.remove { + background-position: -128px 0; + top: 20px; +} diff --git a/WebKit/scripts/controller/Oauth.js b/WebKit/scripts/controller/Oauth.js index 3233967..ef5b1f9 100644 --- a/WebKit/scripts/controller/Oauth.js +++ b/WebKit/scripts/controller/Oauth.js @@ -154,7 +154,7 @@ function(HostApp, Paths, Hmac) { } Oauth.prototype.logout = function() { - + return false; } return Oauth; diff --git a/WebKit/scripts/controller/Timeline.js b/WebKit/scripts/controller/Timeline.js index d5869bd..49e11a0 100644 --- a/WebKit/scripts/controller/Timeline.js +++ b/WebKit/scripts/controller/Timeline.js @@ -113,6 +113,12 @@ function(Core, Paths, HostApp, URI) { Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, callback); } + Timeline.prototype.remove = function(id) { + var _this = this; + var callback = function(data) { _this.getNewData(); } + Core.prototype.remove.call(this, id, callback); + } + return Timeline; }); \ No newline at end of file diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js index a4478e8..d00246a 100644 --- a/WebKit/scripts/helper/Core.js +++ b/WebKit/scripts/helper/Core.js @@ -36,6 +36,12 @@ function(jQuery, Paths, URI, HostApp, Followings) { retweet.innerText = " "; retweet.href = "#"; // item.appendChild(retweet); // FIXME + + var remove = a.cloneNode(); + remove.className = "remove"; + remove.innerText = " "; + remove.href = "#"; + item.appendChild(remove); var image = document.createElement("img"); @@ -124,7 +130,8 @@ function(jQuery, Paths, URI, HostApp, Followings) { ago: ago, source: source, geo: geo, - images: images + images: images, + remove: remove } return jQuery.extend(true, {}, this.template); @@ -135,9 +142,18 @@ function(jQuery, Paths, URI, HostApp, Followings) { var _this = this; var template = this.getTemplate(); - + template.item.id = "post-" + status.id; + if (HostApp.stringForKey("entity") == status.entity) { + template.remove.onclick = function() { + _this.remove(status.id); + return false; + } + } else { + template.remove.style.display = "none"; + } + template.reply_to.onclick = function() { var mentions = []; @@ -256,7 +272,15 @@ function(jQuery, Paths, URI, HostApp, Followings) { data["mentions"] = mentions; } - Paths.getURL(url.toString(), http_method, callback, JSON.stringify(data)); // FIXME: error callback + Paths.getURL(url.toString(), http_method, callback, JSON.stringify(data)); + } + + Core.prototype.remove = function(id, callback) { + + if (confirm("Really delete this post?")) { + var url = URI(Paths.mkApiRootPath("/posts/" + id)); + Paths.getURL(url.toString(), "DELETE", callback); + } }