├── Procfile ├── .bowerrc ├── platforms ├── platforms.json └── ios │ ├── .gitignore │ ├── Ruby China │ ├── .gitignore │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── icon.png │ │ │ ├── icon-40.png │ │ │ ├── icon-50.png │ │ │ ├── icon-60.png │ │ │ ├── icon-72.png │ │ │ ├── icon-76.png │ │ │ ├── icon@2x.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small@2x.png │ │ │ ├── icon-small@3x.png │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default~iphone.png │ │ │ ├── Default@2x~iphone.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ └── Contents.json │ ├── Ruby China-Prefix.pch │ ├── Bridging-Header.h │ ├── Classes │ │ ├── AppDelegate.h │ │ ├── MainViewController.h │ │ ├── AppDelegate.m │ │ ├── MainViewController.m │ │ └── MainViewController.xib │ ├── main.m │ ├── Ruby China-Info.plist │ └── config.xml │ ├── frameworks.json │ ├── Ruby China.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── jason.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── jason.xcuserdatad │ │ ├── xcschemes │ │ ├── xcschememanagement.plist │ │ └── Ruby China.xcscheme │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── ios.json ├── resources ├── android │ ├── splash │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png │ └── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png ├── icon.png ├── splash.png ├── icon_trans.png └── ios │ ├── icon │ ├── icon.png │ ├── icon-40.png │ ├── icon-50.png │ ├── icon-60.png │ ├── icon-72.png │ ├── icon-76.png │ ├── icon@2x.png │ ├── icon-40@2x.png │ ├── icon-50@2x.png │ ├── icon-60@2x.png │ ├── icon-60@3x.png │ ├── icon-72@2x.png │ ├── icon-76@2x.png │ ├── icon-small.png │ ├── icon-small@2x.png │ └── icon-small@3x.png │ └── splash │ ├── Default-667h.png │ ├── Default-736h.png │ ├── Default~iphone.png │ ├── Default@2x~iphone.png │ ├── Default-568h@2x~iphone.png │ ├── Default-Landscape-736h.png │ ├── Default-Landscape~ipad.png │ ├── Default-Portrait~ipad.png │ ├── Default-Landscape@2x~ipad.png │ └── Default-Portrait@2x~ipad.png ├── www ├── img │ ├── ionic.png │ └── default_avatar.png ├── js │ ├── filters │ │ ├── filter.module.js │ │ └── exlink.filter.js │ ├── services │ │ ├── service.module.js │ │ ├── camera.service.js │ │ ├── user.service.js │ │ ├── auth.service.js │ │ ├── topic.service.js │ │ └── base.service.js │ ├── controllers │ │ ├── controller.module.js │ │ ├── user.controller.js │ │ ├── notifications.controller.js │ │ ├── topics.controller.js │ │ ├── topic.controller.js │ │ └── main.controller.js │ ├── app.js │ └── core │ │ ├── core.module.js │ │ ├── run.core.js │ │ ├── config.core.js │ │ └── route.core.js ├── templates │ ├── modals │ │ ├── code_selector.html │ │ ├── reply.html │ │ ├── login.html │ │ └── new_topic.html │ ├── notifications │ │ ├── nodechanged.html │ │ ├── follow.html │ │ ├── topic.html │ │ ├── mention.html │ │ └── topicreply.html │ ├── notifications.html │ ├── topics.html │ ├── menu.html │ ├── user │ │ └── profile.html │ └── topic.html └── index.html ├── docs └── images │ ├── doc_1.png │ ├── doc_2.png │ └── doc_3.png ├── ionic.project ├── .editorconfig ├── bower.json ├── .gitignore ├── scss ├── style.scss ├── _topics.scss ├── _notifications.scss ├── _menu.scss ├── _user.scss ├── _topic.scss ├── _base.scss └── _markdown.scss ├── LICENSE ├── hooks ├── after_prepare │ ├── 020_remove_sass_from_platforms.js │ ├── 050_clean_obfuscation.js │ ├── 030_clean_dev_files_from_platforms.js │ ├── 010_add_platform_class.js │ └── 040_move_dist_files_to_platforms.js ├── before_prepare │ └── 01_jshint.js └── README.md ├── package.json ├── README.md ├── gulpfile.js └── config.xml /Procfile: -------------------------------------------------------------------------------- 1 | ionic: ionic serve -w chrome -a -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "www/lib" 3 | } 4 | -------------------------------------------------------------------------------- /platforms/platforms.json: -------------------------------------------------------------------------------- 1 | { 2 | "ios": "4.1.1" 3 | } -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /platforms/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.perspectivev3 3 | *.pbxuser 4 | .DS_Store 5 | build/ 6 | -------------------------------------------------------------------------------- /www/img/ionic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/www/img/ionic.png -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/icon.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/splash.png -------------------------------------------------------------------------------- /docs/images/doc_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/docs/images/doc_1.png -------------------------------------------------------------------------------- /docs/images/doc_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/docs/images/doc_2.png -------------------------------------------------------------------------------- /docs/images/doc_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/docs/images/doc_3.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.perspectivev3 3 | *.pbxuser 4 | .DS_Store 5 | build/ 6 | -------------------------------------------------------------------------------- /resources/icon_trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/icon_trans.png -------------------------------------------------------------------------------- /resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /www/img/default_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/www/img/default_avatar.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /www/js/filters/filter.module.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('app.filter', []) 6 | 7 | })(); 8 | -------------------------------------------------------------------------------- /resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /www/js/services/service.module.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('app.service', []); 6 | 7 | })(); 8 | -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /www/js/controllers/controller.module.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('app.controller', []); 6 | 7 | })(); 8 | -------------------------------------------------------------------------------- /resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /platforms/ios/frameworks.json: -------------------------------------------------------------------------------- 1 | { 2 | "SafariServices.framework": 1, 3 | "AddressBook.framework": 1, 4 | "libsqlite3.tbd": 1, 5 | "libz.tbd": 1 6 | } -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-50.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-72.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-50@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-72@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small@2x.png -------------------------------------------------------------------------------- /platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-china/ruby-china-ionic/HEAD/platforms/ios/Ruby China/Images.xcassets/AppIcon.appiconset/icon-small@3x.png -------------------------------------------------------------------------------- /www/templates/modals/code_selector.html: -------------------------------------------------------------------------------- 1 |
15 | @{{ vm.user.login }} 16 |
17 |' + message + '
', 85 | okText: '知道了' 86 | }); 87 | } 88 | 89 | // 弹出确认框 90 | function confirm(title, subTitle, message) { 91 | return $ionicPopup.confirm({ 92 | title: title, 93 | subTitle: subTitle, 94 | template: '' + message + '
', 95 | okText: '确认', 96 | cancelText: '取消' 97 | }) 98 | .then(function(res) { 99 | return res; 100 | }); 101 | } 102 | 103 | // 弹出加载界面 104 | // 可传入Spinner类型和消息 105 | function showLoading(style, message) { 106 | return $ionicLoading.show({ 107 | template: '' + 109 | message + '
', 110 | duration: 6000 // 为避免卡死,6秒后如无反应则隐藏 111 | }); 112 | } 113 | 114 | // 结束加载动画 115 | function hideLoading() { 116 | $ionicLoading.hide(); 117 | } 118 | 119 | // 注册模态框 120 | function registModal(template_url, modal_id, scope, opts) { 121 | var defaults = { 122 | scope: scope, 123 | animation: 'slide-in-up' 124 | }; 125 | var options = _.merge(defaults, opts); 126 | return $ionicModal.fromTemplateUrl(template_url, options) 127 | .then(function(modal) { 128 | if (_.indexOf(_.pluck(modals, "id"), modal_id) === -1) { 129 | modals.push({ 130 | id: modal_id, 131 | modal: modal 132 | }); 133 | return modals; 134 | } 135 | }); 136 | } 137 | 138 | // 弹出模态框 139 | function showModal(modal_id) { 140 | changeStatusBar(1); 141 | var modal = _.find(modals, "id", modal_id).modal; 142 | return modal.show(); 143 | } 144 | 145 | // 隐藏模态框 146 | function hideModal(modal_id) { 147 | statusBar(statusBarStyle); 148 | var modal = _.find(modals, "id", modal_id).modal; 149 | return modal.hide(); 150 | } 151 | 152 | // 回收所有模态框 153 | function recycleModals() { 154 | _.forEach(modals, function(modal) { 155 | modal.modal.remove(); 156 | }); 157 | modals = []; 158 | } 159 | 160 | // 回收某个模态框 161 | function recycleModalById(modal_id) { 162 | var modal = _.find(modals, "id", modal_id).modal; 163 | modal.remove(); 164 | modals = _.reject(modals, "id", modal_id); 165 | } 166 | 167 | // 保留某个模态框 168 | function reserveModalById(modal_id) { 169 | var modal = _.find(modals, "id", modal_id).modal; 170 | _.forEach(modals, function(m) { 171 | if (modal.id !== m.modal.id) { 172 | m.modal.remove(); 173 | } 174 | }); 175 | modals = _.select(modals, "id", modal_id); 176 | } 177 | 178 | // 弹出 ActionSheet 179 | function showActionSheet(buttons, titleText, cancelText, buttonsCb, destructiveText, destructiveCb) { 180 | var options = { 181 | buttons: buttons, 182 | titleText: titleText, 183 | cancelText: cancelText, 184 | buttonClicked: buttonsCb, 185 | destructiveText: destructiveText, 186 | destructiveButtonClicked: destructiveCb 187 | }; 188 | return $ionicActionSheet.show(options); 189 | } 190 | 191 | // 上传图片 192 | function uploadPicture(file) { 193 | var q = $q.defer(); 194 | var url = rbchina_api.url_prefix + '/photos.json'; 195 | showLoading('lines', '上传中...'); 196 | var data = new FormData(); 197 | var ext = file.split(',')[0].split(':')[1].split(';')[0].split('/')[1]; 198 | data.append("file", dataURItoBlob(file), "photo." + ext); // 调了半天原来是这里Blob要加个name 199 | $http.post(url, data, { 200 | params: { 201 | access_token: AuthService.getAccessToken() 202 | }, 203 | transformRequest: angular.identity, 204 | headers: { 205 | 'Content-Type': undefined 206 | } 207 | }) 208 | .success(function(result) { 209 | hideLoading(); 210 | q.resolve(result); 211 | }) 212 | .error(function(err) { 213 | hideLoading(); 214 | q.reject(err); 215 | }); 216 | return q.promise; 217 | } 218 | 219 | // https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller 220 | function openUrl(url) { 221 | // console.debug(url); 222 | url = encodeURI(url); 223 | 224 | SafariViewController.isAvailable(function(available) { 225 | if (available) { 226 | SafariViewController.show({ 227 | url: url, 228 | animated: false, // default true, note that 'hide' will reuse this preference (the 'Done' button will always animate though) 229 | enterReaderModeIfAvailable: false // default false 230 | }, 231 | // this success handler will be invoked for the lifecycle events 'opened', 'loaded' and 'closed' 232 | function(result) {}, 233 | function(msg) {}) 234 | } else { 235 | // potentially powered by InAppBrowser because that (currently) clobbers window.open 236 | var options = { 237 | location: 'yes', 238 | clearcache: 'yes', 239 | toolbar: 'yes' 240 | }; 241 | $cordovaInAppBrowser.open(url, '_blank', options) 242 | .then(function(event) { 243 | // success 244 | }) 245 | .catch(function(event) { 246 | // error 247 | }); 248 | } 249 | }) 250 | } 251 | 252 | function dismissSafari() { 253 | SafariViewController.hide(); 254 | } 255 | 256 | function statusBar(style) { 257 | statusBarStyle = style; 258 | changeStatusBar(style); 259 | } 260 | 261 | function changeStatusBar(style) { 262 | if (!window.StatusBar) { 263 | return; 264 | } 265 | 266 | if (style == 0) { 267 | StatusBar.styleLightContent(); 268 | } else { 269 | StatusBar.styleDefault(); 270 | } 271 | } 272 | } 273 | 274 | // base64字符串转图片格式 275 | function dataURItoBlob(dataURI) { 276 | // convert base64/URLEncoded data component to raw binary data held in a string 277 | var byteString; 278 | if (dataURI.split(',')[0].indexOf('base64') >= 0) 279 | byteString = atob(dataURI.split(',')[1]); 280 | else 281 | byteString = unescape(dataURI.split(',')[1]); 282 | 283 | // separate out the mime component 284 | var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; 285 | 286 | // write the bytes of the string to a typed array 287 | var ia = new Uint8Array(byteString.length); 288 | for (var i = 0; i < byteString.length; i++) { 289 | ia[i] = byteString.charCodeAt(i); 290 | } 291 | return new Blob([ia], { 292 | name: 'photo', 293 | type: mimeString 294 | }); 295 | } 296 | 297 | })(); 298 | -------------------------------------------------------------------------------- /www/js/controllers/topic.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('app.controller') 6 | .controller('TopicController', TopicController); 7 | 8 | //////////////////////////////////////////////////////////// 9 | 10 | /* @ngInject */ 11 | function TopicController($rootScope, $scope, $stateParams, $timeout, $ionicActionSheet, 12 | $ionicPopup, $location, $ionicPosition, $ionicScrollDelegate, 13 | BaseService, AuthService, TopicService, CameraService) { 14 | 15 | var vm = this; 16 | vm.is_logined = false; 17 | vm.current_user = null; 18 | vm.user_liked_reply_ids = []; 19 | vm.meta = {}; 20 | vm.topic = { 21 | user: { 22 | avatar_url: 'img/default_avatar.png' 23 | }, 24 | likes_count: 0, 25 | body_html: '', 26 | title: '' 27 | }; 28 | vm.replies = []; 29 | vm.reply_content = ""; 30 | vm.current_page = 1; // 当前页码 31 | 32 | // Functions 33 | vm.showReplies = showReplies; 34 | vm.showTopicPopupMenu = showTopicPopupMenu; 35 | vm.showReplyModal = showReplyModal; 36 | vm.closeReplyModal = closeReplyModal; 37 | vm.moreAction = moreAction; 38 | vm.saveReply = saveReply; 39 | vm.loadMore = loadMore; 40 | vm.quoteReply = quoteReply; 41 | vm.editReply = editReply; 42 | vm.destroyReply = destroyReply; 43 | vm.likeReply = likeReply; 44 | vm.isReplyLiked = isReplyLiked; 45 | 46 | activate(); 47 | 48 | function openUrl() { 49 | console.log('open'); 50 | } 51 | 52 | function activate() { 53 | 54 | vm.is_logined = AuthService.isAuthencated(); 55 | vm.current_user = AuthService.getCurrentUser(); 56 | vm.reply_content = ""; 57 | BaseService.registModal('modals/reply.html', 'reply-modal', $scope, { 58 | focusFirstInput: true 59 | }); 60 | 61 | TopicService.getTopic($stateParams.topic_id).then(function(result) { 62 | vm.meta = result.meta; 63 | vm.topic = result.topic; 64 | // BaseService.formatTopicBody(); 65 | }); 66 | 67 | TopicService.getRepliesByTopic($stateParams.topic_id, 0).then(function(result) { 68 | vm.replies = result.replies; 69 | vm.user_liked_reply_ids = result.meta.user_liked_reply_ids || []; 70 | vm.has_more = vm.replies.length === 150; // 默认这里 100 条一页 71 | // BaseService.formatTopicBody(); 72 | }); 73 | } 74 | 75 | function showReplyModal() { 76 | vm.edit_reply_id = null; 77 | vm.reply_content = ""; 78 | vm.is_logined = AuthService.isAuthencated(); 79 | if (!vm.is_logined) { 80 | BaseService.showModal('login-modal'); 81 | } else { 82 | BaseService.showModal('reply-modal'); 83 | } 84 | } 85 | 86 | function quoteReply(reply, floor) { 87 | vm.current_edit_reply = null; 88 | vm.reply_content = "#" + floor + "楼 @" + reply.user.login + " "; 89 | BaseService.showModal('reply-modal'); 90 | } 91 | 92 | function likeReply(reply) { 93 | var liked = isReplyLiked(reply); 94 | TopicService.like('reply', reply.id, liked).then(function(result) { 95 | reply.likes_count = result.count; 96 | if (liked) { 97 | _.remove(vm.user_liked_reply_ids, function(id) { 98 | return id == reply.id 99 | }); 100 | } else { 101 | vm.user_liked_reply_ids.push(reply.id); 102 | } 103 | }); 104 | } 105 | 106 | function isReplyLiked(reply) { 107 | return vm.user_liked_reply_ids.indexOf(reply.id) != -1; 108 | } 109 | 110 | function editReply(reply) { 111 | vm.current_edit_reply = reply; 112 | TopicService.getReply(reply.id).then(function(result) { 113 | vm.reply_content = result.reply.body; 114 | BaseService.showModal('reply-modal'); 115 | }); 116 | } 117 | 118 | function destroyReply(reply) { 119 | BaseService.confirm('删除确认', '', '你确定要删除这个回帖么?').then(function(res) { 120 | TopicService.destroyReply(reply.id).then(function(result) { 121 | reply.deleted = true; 122 | }); 123 | }); 124 | } 125 | 126 | function closeReplyModal() { 127 | BaseService.hideModal('reply-modal'); 128 | } 129 | 130 | function showTopicPopupMenu() { 131 | vm.is_logined = AuthService.isAuthencated(); 132 | if (!vm.is_logined) { 133 | BaseService.showModal('login-modal'); 134 | return true; 135 | }; 136 | 137 | var likeButton = { text: ' 赞' }; 138 | var unlikeButton = { text: ' 取消赞' }; 139 | var favoriteButton = { text: ' 收藏' }; 140 | var unfavoriteButton = { text: ' 取消收藏' }; 141 | var followButton = { text: ' 关注' }; 142 | var unfollowButton = { text: ' 取消关注' }; 143 | var banButton = { text: ' 屏蔽' }; 144 | var deleteButton = { text: ' 删除' }; 145 | 146 | var buttons = []; 147 | if (vm.meta.liked) { 148 | buttons.push(unlikeButton); 149 | } else { 150 | buttons.push(likeButton); 151 | } 152 | 153 | if (vm.meta.favorited) { 154 | buttons.push(unfavoriteButton); 155 | } else { 156 | buttons.push(favoriteButton); 157 | } 158 | 159 | if (vm.meta.followed) { 160 | buttons.push(unfollowButton); 161 | } else { 162 | buttons.push(followButton); 163 | } 164 | 165 | if (vm.is_logined && vm.current_user.level == 'admin') { 166 | buttons.push(banButton); 167 | } 168 | 169 | if (vm.topic.abilities.destroy) { 170 | buttons.push(deleteButton); 171 | } 172 | 173 | var options = { 174 | buttons: buttons, 175 | cancelText: '取消', 176 | buttonClicked: function(index) { 177 | if (index == buttons.indexOf(likeButton)) { 178 | TopicService.likeTopic(vm.topic.id).then(function(result) { 179 | vm.topic.likes_count = result.count; 180 | vm.meta.liked = true; 181 | }); 182 | } 183 | 184 | if (index == buttons.indexOf(unlikeButton)) { 185 | TopicService.unlikeTopic(vm.topic.id).then(function(result) { 186 | vm.topic.likes_count = result.count; 187 | vm.meta.liked = false; 188 | }); 189 | } 190 | 191 | if (index == buttons.indexOf(favoriteButton) || index == buttons.indexOf(unfavoriteButton)) { 192 | TopicService.favorite(vm.topic.id, vm.meta.favorited).then(function(res) { 193 | vm.meta.favorited = !vm.meta.favorited; 194 | }); 195 | } 196 | 197 | if (index == buttons.indexOf(followButton) || index == buttons.indexOf(unfollowButton)) { 198 | TopicService.follow(vm.topic.id, vm.meta.followed).then(function(res) { 199 | vm.meta.followed = !vm.meta.followed; 200 | }); 201 | } 202 | 203 | if (index == buttons.indexOf(banButton)) { 204 | TopicService.ban(vm.topic.id).then(function(res) { 205 | BaseService.alert('屏蔽话题', '', '已经成功将话题移到了 NoPoint 节点。'); 206 | vm.topic.node_name = "NoPoint"; 207 | }); 208 | } 209 | 210 | if (index == buttons.indexOf(deleteButton)) { 211 | BaseService.confirm('删除确认', '', '你确定要删除这个话题么?').then(function(res) { 212 | TopicService.destroy(vm.topic.id).then(function(result) { 213 | $location.path('/app/topics/last_actived'); 214 | }); 215 | }); 216 | } 217 | 218 | return true; 219 | } 220 | }; 221 | return $ionicActionSheet.show(options); 222 | } 223 | 224 | function moreAction() { 225 | var options = { 226 | buttons: [{ 227 | text: ' 从相册添加图片' 228 | }, { 229 | text: ' 从相机添加图片' 230 | }], 231 | titleText: '更多', 232 | cancelText: '取消', 233 | buttonClicked: function(index) { 234 | document.addEventListener("deviceready", function() { 235 | var size = { 236 | width: 800, 237 | height: 600 238 | }; 239 | return CameraService.getPicture(index, size, 0) 240 | .then(function(result) { 241 | BaseService.uploadPicture(result) 242 | .then(function(img) { 243 | var img_url = ''; 244 | var prev = vm.reply_content.length === 0 ? '' : vm.reply_content + "\r\n"; 245 | vm.reply_content = prev + img_url; 246 | }); 247 | }); 248 | }, false); 249 | 250 | return true; 251 | } 252 | } 253 | return $ionicActionSheet.show(options); 254 | } 255 | 256 | 257 | // 提交回帖 258 | function saveReply() { 259 | if (vm.current_edit_reply) { 260 | TopicService.updateReply(vm.current_edit_reply.id, vm.reply_content) 261 | .then(function(result) { 262 | closeReplyModal(); 263 | var idx = vm.replies.indexOf(vm.current_edit_reply); 264 | vm.replies[idx].body_html = result.reply.body_html; 265 | vm.current_edit_reply = null; 266 | vm.reply_content = ''; 267 | }); 268 | } else { 269 | TopicService.createReply($stateParams.topic_id, vm.reply_content) 270 | .then(function(result) { 271 | closeReplyModal(); 272 | vm.replies.push(result.reply); 273 | vm.reply_content = ""; 274 | }).catch(function(err) { 275 | BaseService.alert('提交回复', '', '提交失败!'); 276 | }) 277 | } 278 | } 279 | 280 | function loadMore() { 281 | vm.current_page++; 282 | var offset = ((vm.current_page || 0) - 1) * 20; 283 | return TopicService.getRepliesByTopic($stateParams.topic_id, offset) 284 | .then(function(result) { 285 | vm.has_more = result.replies && result.replies.length > 0; 286 | if (!vm.has_more) { 287 | vm.current_page--; 288 | } else { 289 | vm.replies = _.union(vm.replies, result.replies); 290 | vm.user_liked_reply_ids = _.union(vm.user_liked_reply_ids, result.meta.user_liked_reply_ids); 291 | $scope.$broadcast('scroll.infiniteScrollComplete'); 292 | } 293 | }); 294 | } 295 | 296 | function showReplies() { 297 | var pos = $ionicPosition.position(angular.element(document.getElementById('topic-stats'))); 298 | $ionicScrollDelegate.scrollTo(0, pos.top, true); 299 | } 300 | 301 | $scope.$on('$ionicView.beforeEnter', function(viewInfo, state) { 302 | BaseService.statusBar(0); 303 | }); 304 | 305 | $scope.$on('$ionicView.leave', function(viewInfo, state) { 306 | if (state.direction === "back") { 307 | BaseService.recycleModalById('reply-modal'); 308 | } 309 | }) 310 | } 311 | 312 | })(); 313 | -------------------------------------------------------------------------------- /www/js/controllers/main.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('app.controller') 6 | .controller('MainController', MainController); 7 | 8 | //////////////////////////////////////////////////////////// 9 | 10 | /* @ngInject */ 11 | function MainController($rootScope, $scope, $state, $ionicScrollDelegate, $ionicPopup, $ionicHistory, 12 | $timeout, BaseService, UserService, AuthService, $location, $cordovaAppVersion, $cordovaPushV5, 13 | CameraService, TopicService, $window) { 14 | 15 | initPushNotification(); 16 | 17 | var vm = this; 18 | vm.current_user = {}; 19 | vm.is_logined = false; 20 | vm.account = {}; 21 | vm.errorMsg = ""; 22 | vm.nodes = []; 23 | vm.new_topic = {}; 24 | 25 | $ionicHistory.nextViewOptions({ 26 | historyRoot: true 27 | }); 28 | 29 | // Functions 30 | vm.showLoginModal = showLoginModal; 31 | vm.showRegisterModal = showRegisterModal; 32 | vm.closeLoginModal = closeLoginModal; 33 | vm.login = login; 34 | vm.logout = logout; 35 | vm.showNewTopicModal = showNewTopicModal; 36 | vm.closeNewTopicModal = closeNewTopicModal; 37 | // vm.moreAction = moreAction; 38 | vm.createTopic = createTopic; 39 | 40 | vm.imageByCamera = imageByCamera; 41 | vm.imageByGallery = imageByGallery; 42 | vm.insertCode = insertCode; 43 | vm.atSomebody = atSomebody; 44 | vm.insertEmoji = insertEmoji; 45 | vm.unread_notifications_count = 0; 46 | 47 | activate(); 48 | loadAppVerion(); 49 | 50 | function activate() { 51 | loadData(""); 52 | 53 | UserService.getUnreadNotificationsCount().then(function(res) { 54 | vm.unread_notifications_count = res.count; 55 | }); 56 | 57 | BaseService.registModal('modals/login.html', 'login-modal', $scope, { 58 | focusFirstInput: true 59 | }); 60 | BaseService.registModal('modals/new_topic.html', 'new-topic-modal', $scope, { 61 | focusFirstInput: true 62 | }); 63 | } 64 | 65 | function loadData(err) { 66 | vm.errorMsg = err; 67 | vm.current_user = AuthService.getCurrentUser() || {}; 68 | vm.is_logined = AuthService.isAuthencated(); 69 | vm.account = {}; 70 | } 71 | 72 | function loadAppVerion() { 73 | document.addEventListener("deviceready", function () { 74 | // only working on Device, not browser 75 | $cordovaAppVersion.getVersionNumber().then(function (version) { 76 | console.log(version); 77 | vm.appVersion = version; 78 | }); 79 | }, false); 80 | } 81 | 82 | function showLoginModal() { 83 | BaseService.showModal('login-modal'); 84 | } 85 | 86 | function showRegisterModal() { 87 | BaseService.openUrl('https://ruby-china.org/account/sign_up'); 88 | } 89 | 90 | function closeLoginModal() { 91 | BaseService.hideModal('login-modal'); 92 | } 93 | 94 | function login() { 95 | return AuthService.login(vm.account) 96 | .then(function(result) { 97 | loadData(""); 98 | 99 | BaseService.hideModal('login-modal'); 100 | }, function(err) { 101 | vm.errorMsg = err; 102 | }) 103 | } 104 | 105 | function logout() { 106 | AuthService.logout(); 107 | loadData(""); 108 | } 109 | 110 | function showNewTopicModal() { 111 | BaseService.showModal('new-topic-modal') 112 | .then(function() { 113 | TopicService.getAllNodes() 114 | .then(function(result) { 115 | vm.nodes = result.nodes; 116 | // 减40是减掉操作条的高度;减12是减掉padding 117 | vm.textarea_origin_height = 118 | document.documentElement.clientHeight - $('.bar-header').height() - 40 - 12; 119 | 120 | setTextareaHeight($rootScope.keyboardHeight); 121 | 122 | // 光标进入内容区,操作条上来 123 | $("#new-topic").on('focus', function(event) { 124 | $location.hash('new-topic'); 125 | $ionicScrollDelegate.$getByHandle('new-topic').anchorScroll(true); 126 | moreActionPutup($rootScope.keyboardHeight); 127 | }); 128 | 129 | // 光标离开内容区,操作条回去 130 | $("#new-topic").on('blur', function() { 131 | moreActionDown(); 132 | $ionicScrollDelegate.$getByHandle('new-topic').scrollTop(true); 133 | }); 134 | 135 | $("#new-topic-title").on('focus', function() { 136 | setTextareaHeight($rootScope.keyboardHeight); 137 | $ionicScrollDelegate.$getByHandle('new-topic').scrollTop(true); 138 | }) 139 | 140 | return vm.nodes; 141 | }); 142 | }); 143 | } 144 | 145 | function closeNewTopicModal() { 146 | BaseService.hideModal('new-topic-modal') 147 | .then(function() { 148 | vm.new_topic = {}; 149 | $('#new-topic').css("max-height", "31px"); 150 | }); 151 | } 152 | 153 | // 处理操作条的方法不太完美,后期改进 154 | // 操作条提上来 155 | function moreActionPutup(height) { 156 | $('#more-actions') 157 | .css("transform", "translate(0px, -" + height + "px)"); 158 | } 159 | 160 | // 操作条回到底部 161 | function moreActionDown() { 162 | $('#more-actions') 163 | .css("transform", "translate(0px, 0px)"); 164 | } 165 | 166 | // 设置文本区高度,传入的是需要减少的高度,而非设定值 167 | function setTextareaHeight(height) { 168 | $('#new-topic') 169 | .css("max-height", vm.textarea_origin_height - height) 170 | .height(vm.textarea_origin_height - height); 171 | } 172 | 173 | // 发表新话题 174 | function createTopic() { 175 | TopicService.createTopic(vm.new_topic.title, vm.new_topic.body, vm.new_topic.node_id) 176 | .then(function(result) { 177 | closeNewTopicModal(); 178 | $scope.$broadcast('new_topic_success'); 179 | BaseService.alert('发表新话题', '', '话题发布成功。'); 180 | vm.new_topic = {}; 181 | }, function(err) { 182 | BaseService.alert('发表新话题', '提交失败', err.error); 183 | }) 184 | } 185 | 186 | // 来自相机的照片 187 | function imageByCamera() { 188 | moreActionDown(); 189 | document.addEventListener("deviceready", function() { 190 | var size = { 191 | width: 600, 192 | height: 600 193 | }; 194 | return CameraService.getPicture(1, size, 0) 195 | .then(function(result) { 196 | BaseService.uploadPicture(result) 197 | .then(function(img) { 198 | var img_url = ''; 199 | var prev = vm.new_topic.body.length === 0 ? '' : vm.new_topic.body + "\r\n"; 200 | vm.new_topic.body = prev + img_url; 201 | }); 202 | }); 203 | }, false); 204 | } 205 | 206 | // 来自相册的照片 207 | function imageByGallery() { 208 | moreActionDown(); 209 | document.addEventListener("deviceready", function() { 210 | var size = { 211 | width: 600, 212 | height: 600 213 | }; 214 | return CameraService.getPicture(0, size, 0) 215 | .then(function(result) { 216 | BaseService.uploadPicture(result) 217 | .then(function(img) { 218 | var img_url = ''; 219 | var prev = vm.new_topic.body.length === 0 ? '' : vm.new_topic.body + "\r\n"; 220 | vm.new_topic.body = prev + img_url; 221 | }); 222 | }); 223 | }, false); 224 | } 225 | 226 | // 插入代码 227 | function insertCode() { 228 | // moreActionDown(); 229 | var popup = $ionicPopup.show({ 230 | templateUrl: 'modals/code_selector.html', 231 | title: '请选择代码语言', 232 | cssClass: 'code_selector', 233 | scope: $scope, 234 | buttons: [{ 235 | text: '确认', 236 | type: 'button-positive', 237 | onTap: function(e) { 238 | if (vm.code_id) { 239 | var code = "```" + vm.code_id + "\r\n" + "\r\n" + "```"; 240 | var prev = (!vm.new_topic.body || vm.new_topic.body.length === 0) ? '' : vm.new_topic.body + "\r\n"; 241 | vm.new_topic.body = prev + code; 242 | }; 243 | } 244 | }, { 245 | text: '取消' 246 | }] 247 | }); 248 | popup.then(function() { 249 | vm.code_id = undefined; 250 | }) 251 | } 252 | 253 | // @某人 254 | function atSomebody() { 255 | moreActionDown(); 256 | } 257 | 258 | // 插入表情 259 | function insertEmoji() { 260 | moreActionDown(); 261 | } 262 | 263 | function initPushNotification() { 264 | var config = { 265 | ios: { 266 | "badge": true, 267 | "sound": true, 268 | "alert": true 269 | } 270 | }; 271 | 272 | document.addEventListener("deviceready", function(){ 273 | $cordovaPushV5.initialize(config).then(function(result) { 274 | $cordovaPushV5.onNotification(); 275 | $cordovaPushV5.onError(); 276 | $cordovaPushV5.register().then(function (deviceToken) { 277 | console.log("deviceToken: " + deviceToken) 278 | AuthService.submitDeviceToken(deviceToken).then(function(res) { }); 279 | }, function (err) { 280 | // handle error 281 | console.log("Registration error: " + err) 282 | }); 283 | }); 284 | 285 | AuthService.submitDeviceToken(deviceToken).then(function(res) { }); 286 | }, false); 287 | 288 | document.addEventListener('resume', function() { 289 | var goafterpush = $window.localStorage['goafterpush']; 290 | if (goafterpush == 1) { 291 | $window.localStorage['goafterpush'] = null; 292 | $state.go('app.notification'); 293 | } 294 | }); 295 | } 296 | 297 | $rootScope.$on('relogin', function() { 298 | // 自动重新登录 299 | AuthService.submitDeviceToken().then(function(res) { }); 300 | AuthService.refreshAccessToken().then(function(res) { 301 | console.log('refreshAccessToken result', res); 302 | }).catch(function(err) { 303 | console.log('Will logout'); 304 | AuthService.logout(); 305 | showLoginModal(); 306 | }); 307 | }); 308 | 309 | $rootScope.$on('unread_notifications_count', function(event, count) { 310 | vm.unread_notifications_count = count; 311 | }); 312 | 313 | $rootScope.$on('$cordovaPushV5:notificationReceived', function(event, notification) { 314 | // if (notification.alert) { 315 | // navigator.notification.alert(notification.alert); 316 | // } 317 | 318 | if (notification.sound) { 319 | var snd = new Media(event.sound); 320 | snd.play(); 321 | } 322 | 323 | // store state for open /notifications page when rescume app. 324 | $window.localStorage['goafterpush'] = 1; 325 | 326 | if (notification.badge) { 327 | vm.unread_notifications_count = notification.badge; 328 | 329 | $cordovaPushV5.setBadgeNumber(notification.badge).then(function(result) { 330 | // Success! 331 | }, function(err) { 332 | // An error occurred. Show a message to the user 333 | }); 334 | } 335 | }); 336 | } 337 | 338 | })(); 339 | --------------------------------------------------------------------------------