Skip to content

Commit c8262dd

Browse files
committed
Add copy reply support
1 parent a8b4fa5 commit c8262dd

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"angular-moment": "~0.9.2",
88
"angular-elastic": "~2.4.2",
99
"to-markdown": "~0.0.3",
10-
"angular-markdown-directive": "~0.3.1"
10+
"angular-markdown-directive": "~0.3.1",
11+
"ngCordova": "~0.1.14-alpha"
1112
},
1213
"devDependencies": {},
1314
"overrides": {

www/app/app.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
angular.module('ionic-nodeclub', [
22
'ionic'
3+
'ngCordova'
34
'restangular'
45
'angularMoment'
56
'btford.markdown'

www/app/directives/focusOn.directive.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ angular.module('ionic-nodeclub')
66
scope.$on 'focusOn', (event, name) ->
77
$timeout ->
88
if name is attrs.focusOn
9-
console.log 'focusOn', attrs.focusOn
109
element[0].focus()

www/app/replies/replies.controller.coffee

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ angular.module('ionic-nodeclub')
66
$scope
77
$state
88
$filter
9+
$window
910
authService
1011
$ionicModal
1112
$stateParams
1213
topicService
1314
$ionicLoading
15+
$cordovaClipboard
1416
$ionicActionSheet
1517
$ionicScrollDelegate
1618
) ->
1719

20+
$ionicModal
21+
.fromTemplateUrl('app/replies/reply-preview-modal.html', scope: $scope)
22+
.then (modal) ->
23+
$scope.replyModal = modal
24+
1825
loadReplies = (refresh) ->
1926
$scope.loading = true
2027
topicService.getReplies($stateParams.topicId, refresh)
@@ -27,12 +34,6 @@ angular.module('ionic-nodeclub')
2734
$scope.loading = false
2835
$scope.$broadcast('scroll.refreshComplete')
2936

30-
31-
$ionicModal
32-
.fromTemplateUrl('app/replies/reply-preview-modal.html', scope: $scope)
33-
.then (modal) ->
34-
$scope.replyModal = modal
35-
3637
angular.extend $scope,
3738
loading: false
3839
error: null
@@ -86,7 +87,14 @@ angular.module('ionic-nodeclub')
8687
buttonClicked: (index) ->
8788
switch index
8889
when 0
89-
console.log 'copy...', $filter('toMarkdown')(reply.content)
90+
text = $filter('toMarkdown')(reply.content)
91+
if $window.cordova
92+
$cordovaClipboard
93+
.copy text
94+
.then ->
95+
toast '已拷贝到粘贴板'
96+
else
97+
console.log 'copy...' + text
9098
when 1
9199
quote = $filter('toMarkdown')(reply.content)
92100
quote = '\n' + quote.trim().replace(/([^\n]+)\n*/g, '>$1\n>\n')
@@ -122,12 +130,9 @@ angular.module('ionic-nodeclub')
122130
]
123131
buttonClicked: (index) ->
124132
switch index
125-
when 0
126-
$scope.sendReply()
127-
when 1
128-
$scope.replyModal.show()
129-
else
130-
$scope.clearNewReply()
133+
when 0 then $scope.sendReply()
134+
when 1 then $scope.replyModal.show()
135+
else $scope.clearNewReply()
131136
return true
132137

133138
$scope.doRefresh()

www/app/user/user.controller.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ angular.module('ionic-nodeclub')
1414
'collect_topics'
1515
else
1616
'recent_topics'
17-
console.log 'user', $scope.user
1817

1918
angular.extend $scope,
2019
user: null

0 commit comments

Comments
 (0)