diff --git a/public/css/common.css b/public/css/common.css index f9dbeb385b..7921f26450 100644 --- a/public/css/common.css +++ b/public/css/common.css @@ -8,7 +8,13 @@ a { cursor: pointer; } -.content { +a.disabled, a.disabled:hover { + color: #888; + cursor: default; + text-decoration: none; +} + +.appframe { background-color: #fff; -webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.7); box-shadow: 0px 0px 6px rgba(0,0,0,0.7); diff --git a/public/js/wn/upload.js b/public/js/wn/upload.js index d5e1a919cd..a5506912ae 100644 --- a/public/js/wn/upload.js +++ b/public/js/wn/upload.js @@ -4,18 +4,40 @@ // parent, args, callback wn.upload = { make: function(opts) { - var $upload = $("
" + repl(wn._('Upload a file')+':
\ - \ - OR:

\ -

' - + (opts.sample_url || 'e.g. http://example.com/somefile.png') - + '


\ -
', { - action: wn.request.url - })).appendTo(opts.parent); + if(!opts.args) opts.args = {}; + var $upload = $('
\ +

' + + wn._('Upload a file') + ' | ' + + wn._('Attach as web link') + '

\ +
\ + \ +
\ + \ +
').appendTo(opts.parent); + $upload.find(".action-link").click(function() { + $upload.find(".action-attach").removeClass("disabled"); + $upload.find(".action-link").addClass("disabled"); + $upload.find(".action-attach-input").toggle(false); + $upload.find(".action-link-input").toggle(true); + return false; + }) + + $upload.find(".action-attach").click(function() { + $upload.find(".action-link").removeClass("disabled"); + $upload.find(".action-attach").addClass("disabled"); + $upload.find(".action-link-input").toggle(false); + $upload.find(".action-attach-input").toggle(true); + return false; + }) + // get the first file $upload.find(".btn-upload").click(function() { // convert functions to values @@ -51,23 +73,27 @@ wn.upload = { } var _upload_file = function() { - var msgbox = msgprint(wn._("Uploading...")); - return wn.call({ - "method": "uploadfile", - args: args, - callback: function(r) { - if(!r._server_messages) - msgbox.hide(); - if(r.exc) { - // if no onerror, assume callback will handle errors - opts.onerror ? opts.onerror(r) : opts.callback(null, null, r); - return; + if(opts.on_attach) { + opts.on_attach(args) + } else { + var msgbox = msgprint(wn._("Uploading...")); + return wn.call({ + "method": "uploadfile", + args: args, + callback: function(r) { + if(!r._server_messages) + msgbox.hide(); + if(r.exc) { + // if no onerror, assume callback will handle errors + opts.onerror ? opts.onerror(r) : opts.callback(null, null, r); + return; + } + opts.callback(r.message.fid, r.message.filename, r); + $(document).trigger("upload_complete", + [r.message.fid, r.message.filename]); } - opts.callback(r.message.fid, r.message.filename, r); - $(document).trigger("upload_complete", - [r.message.fid, r.message.filename]); - } - }); + }); + } } if(args.file_url) {