@@ -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 ()
0 commit comments