From 8f89a11002e3b1ae6694c3341cc93eddb809ee56 Mon Sep 17 00:00:00 2001 From: Merrick Zhang Date: Thu, 16 Jan 2014 21:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=96=87=E5=AD=97=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=B8=8D=E8=BF=87=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=AE=9E=E7=8E=B0=E6=96=87=E5=AD=97=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=85=B1=E4=BA=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/www/img/ic_share.png | Bin 0 -> 1217 bytes src/www/js/app.js | 32 ++++ src/www/js/bfb_bootstrap.js | 314 +++++++++++++++++++----------------- src/www/main.html | 7 +- 4 files changed, 198 insertions(+), 155 deletions(-) create mode 100644 src/www/img/ic_share.png diff --git a/src/www/img/ic_share.png b/src/www/img/ic_share.png new file mode 100644 index 0000000000000000000000000000000000000000..c2b0b95e027f6f6dd56c14b8fb09902904193f65 GIT binary patch literal 1217 zcmV;y1U~zTP)R5Lpb7Au>dU$YO|DYca`}YqeVJ=WlOs7X0Wz zvLRWK#~!2$NW-P2r9fB1giR;HrbdiSQ%EDQ$&cnuy0cYFk|7H5_4U<+&j#>o`y1H< zVRT;uz`p3z?`Q}NoaN=^Ks!VLh`l?G>E-|F98%}A(Nw}tg&z|Io6s{4Lz|L9Tu5Q8 z3P4l~(jX%zoG99ac_yM=dIlEgDOG@>+Al9JrX^BK0Ie_ZLLH7f(N@MDwE~#T?jTcwe8|SW!UqFiZAr@EC7C5 zN~#Vfhq|UXaUh3DR|Jobk7fp5I8clX2R%@OP0 z(HyZS0qD!>&U@LX(nvfA@}rYl46%oYhg2aA`7w-7C6neK(1}4QAZ~1IU_)f1aSuQ= z6aj|kJhAUwsMj+zNz36qG-xV3GR|Yhs$mStiYd>7`uc`O>AV5qNOo-+_xJaS8V%q7 z8^)5y9YeFULEPNjoEg>trtwXHGs76_@k$F(fJ`0M@V$X7jG_F#k%RKM&?F7(ySuxY zXVLH+56Rj^31cmj?HMp+D+~+5S9 zFGmp^aSp2Ni6=zmSkNJ@szM}dIPulG#9GXw(yOa0oA?rvRaH-K zL)_or#{mIvmZ{uSa3O!kD1dUG;s6NTRIMinZ3Nye3P4ouo3fvEd3lK|k7Kc}j_ziE z{00BP!9kGmYi52SMt~wj+-nQ~n${zLOd+z$z3gL%43WhU86rbuh%AQ45E&vvWHCgB f$Pmk|KLQK@!+1w9I5gJa00000NkvXXu0mjfjJ_)$ literal 0 HcmV?d00001 diff --git a/src/www/js/app.js b/src/www/js/app.js index daf43e8..1adb64e 100644 --- a/src/www/js/app.js +++ b/src/www/js/app.js @@ -9,6 +9,7 @@ var app = { // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); + //window.addEventListener('oncontextmenu', app.onContextMenu); }, // deviceready Event Handler // @@ -73,6 +74,7 @@ var app = { if (id === 'menu') { loadContent(element, id); } + }; bb.init(config); @@ -437,4 +439,34 @@ function tabswitcher() { } else { bb.actionBar.highlightAction(g('a3')); } +} +///////////////////////////////////////////文字选择与共享//////////////////////////////////////////////// + + + +function shareText() { + var selectedItem = getSelText(); + if (selectedItem) { + Invoke.shareText(selectedItem); + } else { + Toast.regular("您未选择要分享的内容", 1000); + } +} + +function getSelText() +{ + if (window.getSelection) + { + return window.getSelection(); + } + else if (document.getSelection) + { + return document.getSelection(); + } + else if (document.selection) + { + return document.selection.createRange().text; + } + else + return ""; } \ No newline at end of file diff --git a/src/www/js/bfb_bootstrap.js b/src/www/js/bfb_bootstrap.js index ce5ab07..affce9a 100644 --- a/src/www/js/bfb_bootstrap.js +++ b/src/www/js/bfb_bootstrap.js @@ -103,176 +103,188 @@ var Invoke = { }; blackberry.invoke.card.invokeTargetPicker(request, title, - // success - function() { - }, - // error - function(e) { - }); - }, - // blackberry world - blackberryWorld: { - // vendor page - app: function(id) { - blackberry.invoke.invoke({ - target: 'sys.appworld', - action: 'bb.action.OPEN', - uri: 'appworld://content/' + id - }, - // success - function() { - }, - // error - function() { - }); - } - }, - // email - email: function(to, subject, body) { - var message = to + '?subject=' + subject + '&body=' + body; - blackberry.invoke.invoke({ - target: 'sys.pim.uib.email.hybridcomposer', - action: 'bb.action.OPEN, bb.action.SENDMAIL', - type: 'message/rfc822', - uri: 'mailto:' + message - }); - }, - // blackberry maps - maps: function(address) { - blackberry.invoke.invoke({ - action: 'bb.action.NAVIGATETO', - type: 'application/vnd.blackberry.string.address', - data: address - }); - }, - // nfc - nfc: function(uri) { - blackberry.invoke.invoke({ - target: "sys.NFCViewer", - action: "bb.action.SHARE", - uri: uri - }, function() { - }, function() { + function() { + }, + function(e) { }); - }, - // twitter - twitter: function(shareText) { - blackberry.invoke.invoke({ - target: "Twitter", - action: "bb.action.SHARE", - type: "text/plain", - data: shareText - }, function() { - }, function() { + }, + shareText: function(t) { + var title = 'Share'; + var request = { + action: 'bb.action.SHARE', + data: t, + target_type: ["APPLICATION", "VIEWER", "CARD"] + }; + + blackberry.invoke.card.invokeTargetPicker(request, title, + function() { + }, + function(e) { }); + }, + // blackberry world + blackberryWorld: { + // vendor page + app: function(id) { + blackberry.invoke.invoke({ + target: 'sys.appworld', + action: 'bb.action.OPEN', + uri: 'appworld://content/' + id }, - //facebook - facebook: function(shareText) { - blackberry.invoke.invoke({ - target: "Facebook", - action: "bb.action.SHARE", - type: "text/plain", - data: shareText - }, function() { - }, function() { - }); + // success + function() { }, - utils: { - // filepicker - filePicker: function(success, cancel, failure) { + // error + function() { + }); + } + }, + // email + email: function(to, subject, body) { + var message = to + '?subject=' + subject + '&body=' + body; + blackberry.invoke.invoke({ + target: 'sys.pim.uib.email.hybridcomposer', + action: 'bb.action.OPEN, bb.action.SENDMAIL', + type: 'message/rfc822', + uri: 'mailto:' + message + }); + }, + // blackberry maps + maps: function(address) { + blackberry.invoke.invoke({ + action: 'bb.action.NAVIGATETO', + type: 'application/vnd.blackberry.string.address', + data: address + }); + }, + // nfc + nfc: function(uri) { + blackberry.invoke.invoke({ + target: "sys.NFCViewer", + action: "bb.action.SHARE", + uri: uri + }, function() { + }, function() { + }); + }, + // twitter + twitter: function(shareText) { + blackberry.invoke.invoke({ + target: "Twitter", + action: "bb.action.SHARE", + type: "text/plain", + data: shareText + }, function() { + }, function() { + }); + }, + //facebook + facebook: function(shareText) { + blackberry.invoke.invoke({ + target: "Facebook", + action: "bb.action.SHARE", + type: "text/plain", + data: shareText + }, function() { + }, function() { + }); + }, + utils: { + // filepicker + filePicker: function(success, cancel, failure) { - var details = { - mode: blackberry.invoke.card.FILEPICKER_MODE_PICKER, - viewMode: blackberry.invoke.card.FILEPICKER_VIEWER_MODE_GRID, - sortBy: blackberry.invoke.card.FILEPICKER_SORT_BY_NAME, - sortOrder: blackberry.invoke.card.FILEPICKER_SORT_ORDER_DESCENDING - }; + var details = { + mode: blackberry.invoke.card.FILEPICKER_MODE_PICKER, + viewMode: blackberry.invoke.card.FILEPICKER_VIEWER_MODE_GRID, + sortBy: blackberry.invoke.card.FILEPICKER_SORT_BY_NAME, + sortOrder: blackberry.invoke.card.FILEPICKER_SORT_ORDER_DESCENDING + }; - blackberry.invoke.card.invokeFilePicker(details, function(path) { - success(path); - }, - // cancel callback - function(reason) { - cancel(reason); - }, - // error callback - function(error) { - if (error) { - failure(error); - } - } - ); - }, - // camera - camera: function(success, cancel, failure) { - var mode = blackberry.invoke.card.CAMERA_MODE_PHOTO; - blackberry.invoke.card.invokeCamera(mode, function(path) { - success(path); + blackberry.invoke.card.invokeFilePicker(details, function(path) { + success(path); + }, + // cancel callback + function(reason) { + cancel(reason); }, - function(reason) { - cancel(reason); - }, + // error callback function(error) { if (error) { failure(error); } } ); - } - } - }; + }, + // camera + camera: function(success, cancel, failure) { + var mode = blackberry.invoke.card.CAMERA_MODE_PHOTO; + blackberry.invoke.card.invokeCamera(mode, function(path) { + success(path); + }, + function(reason) { + cancel(reason); + }, + function(error) { + if (error) { + failure(error); + } + } + ); + } + } +}; - /* ============================================================================================== - * TOASTS - https://developer.blackberry.com/html5/apis/blackberry.ui.toast.html - * =========================================================================================== */ +/* ============================================================================================== + * TOASTS - https://developer.blackberry.com/html5/apis/blackberry.ui.toast.html + * =========================================================================================== */ - var Toast = { - regular: function(text, timeout) { - try { - timeout = timeout || false; - var options = { - timeout: timeout - }; - blackberry.ui.toast.show(text, options); - } catch (e) { - console.log('toast: ' + text); - } - }, - withButton: function(text, btnText, btnCallback, timeout) { - try { - timeout = timeout || false; - var options = { - timeout: timeout, - buttonText: btnText, - buttonCallback: eval(btnCallback) - }; - blackberry.ui.toast.show(text, options, timeout); - } catch (e) { - console.log('toast: ' + text); - } - } - }; +var Toast = { + regular: function(text, timeout) { + try { + timeout = timeout || false; + var options = { + timeout: timeout + }; + blackberry.ui.toast.show(text, options); + } catch (e) { + console.log('toast: ' + text); + } + }, + withButton: function(text, btnText, btnCallback, timeout) { + try { + timeout = timeout || false; + var options = { + timeout: timeout, + buttonText: btnText, + buttonCallback: eval(btnCallback) + }; + blackberry.ui.toast.show(text, options, timeout); + } catch (e) { + console.log('toast: ' + text); + } + } +}; - /* =========================================================================================== - * SPINNERS - https://github.com/blackberry/bbUI.js/wiki/Activity-Indicator - * ======================================================================================== */ +/* =========================================================================================== + * SPINNERS - https://github.com/blackberry/bbUI.js/wiki/Activity-Indicator + * ======================================================================================== */ // spinner divs in spinners.html - var Spinner = { - 'lastOn': false, - off: function() { - if (Spinner.lastOn) { - var el = document.getElementById('spinner-' + Spinner.lastOn); - el.style.display = 'none'; - } - }, - on: function(size) { - Spinner['lastOn'] = size; - var el = document.getElementById('spinner-' + size); - el.style.display = 'block'; - } - }; \ No newline at end of file +var Spinner = { + 'lastOn': false, + off: function() { + if (Spinner.lastOn) { + var el = document.getElementById('spinner-' + Spinner.lastOn); + el.style.display = 'none'; + } + }, + on: function(size) { + Spinner['lastOn'] = size; + var el = document.getElementById('spinner-' + size); + el.style.display = 'block'; + } +}; \ No newline at end of file diff --git a/src/www/main.html b/src/www/main.html index 6143a22..9bd9e70 100644 --- a/src/www/main.html +++ b/src/www/main.html @@ -1,5 +1,5 @@ -
+
@@ -12,7 +12,7 @@

-
如果长时间未显示
请退出重试并检查网络连接。
+
如果长时间未显示
请退出重试并检查网络连接。
@@ -26,7 +26,7 @@
-
+

@@ -49,5 +49,4 @@
去评分
设置
-
\ No newline at end of file