From 263d556c172a048a386e0524c69c4fc04ada300d Mon Sep 17 00:00:00 2001 From: luchenqun Date: Thu, 2 Mar 2017 10:16:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E5=9D=80=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/images/copy.ico | Bin 0 -> 1150 bytes public/index.html | 1 + .../controllers/bookmark-info-controller.js | 18 ++++++ .../controllers/bookmarks-controller.js | 54 ++++++++++++------ .../scripts/controllers/search-controller.js | 18 ++++++ public/scripts/controllers/tags-controller.js | 18 ++++++ public/scripts/externe/clipboard.min.js | 7 +++ public/views/bookmark-info.html | 2 +- public/views/bookmarks.html | 2 +- public/views/search.html | 2 +- public/views/tags.html | 2 +- 11 files changed, 101 insertions(+), 23 deletions(-) create mode 100644 public/images/copy.ico create mode 100644 public/scripts/externe/clipboard.min.js diff --git a/public/images/copy.ico b/public/images/copy.ico new file mode 100644 index 0000000000000000000000000000000000000000..7a59c5a93be4d0f90b42d240c1084cd2845e3a1a GIT binary patch literal 1150 zcmb_bp$@_@6g&bR1R)5rO!5r~!Y826NF)NyuOJZ!K4CZ{pb&^jBqSIT1l)x-DNRaC z!dq_FzTUmpbsJFO)o6hC9FrQ*0?;LxV&tHHKXN8g{Z<#^*!l0+ ztM6g-L;oYSV-Naf?0#bXtuDkN|I+CZ@;;~;5H?h+G!y-0Sp;pPwWR0L`&ONAm|BC! hs<$SJ2=r_pajybbgFX3h1H|rFIX7SORD?|(cmYAWpril* literal 0 HcmV?d00001 diff --git a/public/index.html b/public/index.html index 2a911eb..f18a662 100644 --- a/public/index.html +++ b/public/index.html @@ -62,5 +62,6 @@ + diff --git a/public/scripts/controllers/bookmark-info-controller.js b/public/scripts/controllers/bookmark-info-controller.js index d79459f..da8da1b 100644 --- a/public/scripts/controllers/bookmark-info-controller.js +++ b/public/scripts/controllers/bookmark-info-controller.js @@ -41,6 +41,24 @@ app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$win } } + $scope.copy = function(id, url) { + var clipboard = new Clipboard('#detailurl'+id, { + text: function() { + return url; + } + }); + + clipboard.on('success', function(e) { + toastr.success(url + '
已复制到您的剪切板', "提示"); + clipboard.destroy(); + }); + + clipboard.on('error', function(e) { + toastr.error(url + '
复制失败', "提示"); + clipboard.destroy(); + }); + } + function transition() { var data = ['scale', 'fade', 'fade up', 'fade down', 'fade left', 'fade right', 'horizontal flip', 'vertical flip', 'drop', 'fly left', 'fly right', 'fly up', 'fly down', 'swing left', 'swing right', 'swing up', diff --git a/public/scripts/controllers/bookmarks-controller.js b/public/scripts/controllers/bookmarks-controller.js index 2b5fa1e..87452b5 100644 --- a/public/scripts/controllers/bookmarks-controller.js +++ b/public/scripts/controllers/bookmarks-controller.js @@ -105,6 +105,24 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' }); } + $scope.copy = function(id, url) { + var clipboard = new Clipboard('#url'+id, { + text: function() { + return url; + } + }); + + clipboard.on('success', function(e) { + toastr.success(url + '
已复制到您的剪切板', "提示"); + clipboard.destroy(); + }); + + clipboard.on('error', function(e) { + toastr.error(url + '
复制失败', "提示"); + clipboard.destroy(); + }); + } + $scope.jumpToTags = function(tagId) { $state.go('tags', { tagId: tagId, @@ -180,32 +198,30 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', ' login: true, index: 0 }); - // transition(); + transition(); }) .catch((err) => console.log('getBookmarks err', err)); } function transition() { - setTimeout(function() { - var data = ['scale', 'fade', 'fade up', 'fade down', 'fade left', 'fade right', 'horizontal flip', - 'vertical flip', 'drop', 'fly left', 'fly right', 'fly up', 'fly down', 'swing left', 'swing right', 'swing up', - 'swing down', 'browse', 'browse right', 'slide down', 'slide up', 'slide left', 'slide right' - ]; - var t = data[parseInt(Math.random() * 1000) % data.length]; + var data = ['scale', 'fade', 'fade up', 'fade down', 'fade left', 'fade right', 'horizontal flip', + 'vertical flip', 'drop', 'fly left', 'fly right', 'fly up', 'fly down', 'swing left', 'swing right', 'swing up', + 'swing down', 'browse', 'browse right', 'slide down', 'slide up', 'slide left', 'slide right' + ]; + var t = data[parseInt(Math.random() * 1000) % data.length]; - var className = 'js-segment-navigate'; - if ($scope.showStyle == 'card') { - className = 'js-segment-card' - } else if ($scope.showStyle == 'table') { - className = 'js-table-bookmarks' - } - $('.' + className).transition('hide'); - $('.' + className).transition({ - animation: t, - duration: 500, - }); - }, 10) + var className = 'js-segment-navigate'; + if ($scope.showStyle == 'card') { + className = 'js-segment-card' + } else if ($scope.showStyle == 'table') { + className = 'js-table-bookmarks' + } + $('.' + className).transition('hide'); + $('.' + className).transition({ + animation: t, + duration: 500, + }); } // TODO: 我要将编辑按钮固定在容器的右上角 $(window).resize(updateEditPos); diff --git a/public/scripts/controllers/search-controller.js b/public/scripts/controllers/search-controller.js index 36fe28c..df23808 100644 --- a/public/scripts/controllers/search-controller.js +++ b/public/scripts/controllers/search-controller.js @@ -108,6 +108,24 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi pubSubService.publish('TagCtr.storeBookmark', b); } + $scope.copy = function(id, url) { + var clipboard = new Clipboard('#searchurl'+id, { + text: function() { + return url; + } + }); + + clipboard.on('success', function(e) { + toastr.success(url + '
已复制到您的剪切板', "提示"); + clipboard.destroy(); + }); + + clipboard.on('error', function(e) { + toastr.error(url + '
复制失败', "提示"); + clipboard.destroy(); + }); + } + $scope.search = function(page) { var params = {} params.userRange = $('.js-user-range').dropdown('get value'); diff --git a/public/scripts/controllers/tags-controller.js b/public/scripts/controllers/tags-controller.js index 272c108..ccadaad 100644 --- a/public/scripts/controllers/tags-controller.js +++ b/public/scripts/controllers/tags-controller.js @@ -126,6 +126,24 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim }); } + $scope.copy = function(id, url) { + var clipboard = new Clipboard('#tagurl'+id, { + text: function() { + return url; + } + }); + + clipboard.on('success', function(e) { + toastr.success(url + '
已复制到您的剪切板', "提示"); + clipboard.destroy(); + }); + + clipboard.on('error', function(e) { + toastr.error(url + '
复制失败', "提示"); + clipboard.destroy(); + }); + } + $scope.toggleMode = function() { $scope.edit = !$scope.edit; if (!$scope.edit) { diff --git a/public/scripts/externe/clipboard.min.js b/public/scripts/externe/clipboard.min.js new file mode 100644 index 0000000..1993676 --- /dev/null +++ b/public/scripts/externe/clipboard.min.js @@ -0,0 +1,7 @@ +/*! + * clipboard.js v1.6.1 + * https://zenorocha.github.io/clipboard.js + * + * Licensed MIT © Zeno Rocha + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Clipboard=e()}}(function(){var e,t,n;return function e(t,n,o){function i(a,c){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[a]={exports:{}};t[a][0].call(s.exports,function(e){var n=t[a][1][e];return i(n?n:e)},s,s.exports,e,t,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function e(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function e(){var t=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function e(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function e(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function e(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function e(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function e(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function e(){this.removeFake()}},{key:"action",set:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function e(){return this._action}},{key:"target",set:function e(t){if(void 0!==t){if(!t||"object"!==("undefined"==typeof t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function e(){return this._target}}]),e}();e.exports=c})},{select:5}],8:[function(t,n,o){!function(i,r){if("function"==typeof e&&e.amd)e(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,t("./clipboard-action"),t("tiny-emitter"),t("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(e,t,n,o){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}var u=i(t),s=i(n),f=i(o),d=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText}},{key:"listenClick",value:function e(t){var n=this;this.listener=(0,f.default)(t,"click",function(e){return n.onClick(e)})}},{key:"onClick",value:function e(t){var n=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})}},{key:"defaultAction",value:function e(t){return l("action",t)}},{key:"defaultTarget",value:function e(t){var n=l("target",t);if(n)return document.querySelector(n)}},{key:"defaultText",value:function e(t){return l("text",t)}},{key:"destroy",value:function e(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof t?[t]:t,o=!!document.queryCommandSupported;return n.forEach(function(e){o=o&&!!document.queryCommandSupported(e)}),o}}]),t}(s.default);e.exports=h})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)}); \ No newline at end of file diff --git a/public/views/bookmark-info.html b/public/views/bookmark-info.html index fe100b1..c32187b 100644 --- a/public/views/bookmark-info.html +++ b/public/views/bookmark-info.html @@ -20,7 +20,7 @@ ng-click="jumpToUrl(bookmark.url, bookmark.id)" favicon-err="./images/favicon/{{bookmark.id}}.ico" title="点击跳转到原页面"> - 网页地址:{{bookmark.url}} + 网页地址{{bookmark.url}}
diff --git a/public/views/bookmarks.html b/public/views/bookmarks.html index 24a7d7e..4cd4a56 100644 --- a/public/views/bookmarks.html +++ b/public/views/bookmarks.html @@ -68,7 +68,7 @@ - {{ bookmark.url }} + {{ bookmark.url }} {{ bookmark.click_count }} {{ bookmark.created_at }} diff --git a/public/views/search.html b/public/views/search.html index 17af20f..8d64d21 100644 --- a/public/views/search.html +++ b/public/views/search.html @@ -136,7 +136,7 @@ - {{ bookmark.url }} + {{ bookmark.url }} {{ bookmark.click_count }} {{ bookmark.created_at }} diff --git a/public/views/tags.html b/public/views/tags.html index 4b98b20..eff2f20 100644 --- a/public/views/tags.html +++ b/public/views/tags.html @@ -69,7 +69,7 @@ - {{ bookmark.url }} + {{ bookmark.url }} {{ bookmark.click_count }} {{ bookmark.created_at }}