rails_design 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +18 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/images/image-square.png +0 -0
  6. data/app/assets/images/logo.png +0 -0
  7. data/app/assets/javascripts/default_form/datetime.js +31 -0
  8. data/app/assets/javascripts/default_form/default_valid.js +101 -0
  9. data/app/assets/javascripts/default_form/field.js +33 -0
  10. data/app/assets/javascripts/default_form/index.js +9 -0
  11. data/app/assets/javascripts/default_form/valid_weui.js +17 -0
  12. data/app/assets/javascripts/rails_design/attachment.js +295 -0
  13. data/app/assets/javascripts/rails_design/cable.js +3 -0
  14. data/app/assets/javascripts/rails_design/dataset.js +39 -0
  15. data/app/assets/javascripts/rails_design/index.js +4 -0
  16. data/app/assets/javascripts/rails_design/stimulus.js +19 -0
  17. data/app/assets/javascripts/rails_design/turbo.js +35 -0
  18. data/app/assets/javascripts/stimulus_com/checkbox.js +77 -0
  19. data/app/assets/javascripts/stimulus_com/choice.js +18 -0
  20. data/app/assets/javascripts/stimulus_com/common.js +52 -0
  21. data/app/assets/javascripts/stimulus_com/count_down.js +27 -0
  22. data/app/assets/javascripts/stimulus_com/former.js +26 -0
  23. data/app/assets/javascripts/stimulus_com/hover.js +40 -0
  24. data/app/assets/javascripts/stimulus_com/index.js +58 -0
  25. data/app/assets/javascripts/stimulus_com/input.js +36 -0
  26. data/app/assets/javascripts/stimulus_com/menu.js +34 -0
  27. data/app/assets/javascripts/stimulus_com/modal.js +85 -0
  28. data/app/assets/javascripts/stimulus_com/modal_show.js +16 -0
  29. data/app/assets/javascripts/stimulus_com/navbar.js +11 -0
  30. data/app/assets/javascripts/stimulus_com/notice.js +10 -0
  31. data/app/assets/javascripts/stimulus_com/picture.js +85 -0
  32. data/app/assets/javascripts/stimulus_com/show.js +26 -0
  33. data/app/assets/javascripts/stimulus_com/showcase.js +34 -0
  34. data/app/assets/javascripts/stimulus_com/slide.js +188 -0
  35. data/app/assets/javascripts/stimulus_com/slide_y.js +189 -0
  36. data/app/assets/javascripts/stimulus_com/sortable.js +41 -0
  37. data/app/assets/javascripts/stimulus_com/sticky.js +11 -0
  38. data/app/assets/javascripts/stimulus_com/swipe.js +78 -0
  39. data/app/assets/javascripts/stimulus_com/taxon.js +45 -0
  40. data/app/assets/javascripts/stimulus_com/time.js +19 -0
  41. data/app/assets/javascripts/stimulus_com/touch.js +83 -0
  42. data/app/assets/javascripts/stimulus_com/tree.js +34 -0
  43. data/app/assets/javascripts/stimulus_com/tree_remote.js +64 -0
  44. data/app/assets/javascripts/stimulus_com/typer.js +41 -0
  45. data/app/assets/javascripts/stimulus_com/visit.js +61 -0
  46. data/app/assets/javascripts/stimulus_phone/index.js +19 -0
  47. data/app/assets/javascripts/stimulus_phone/qq_map.js +29 -0
  48. data/app/assets/javascripts/stimulus_phone/search.js +37 -0
  49. data/app/assets/javascripts/stimulus_phone/wechat.js +80 -0
  50. data/app/assets/javascripts/stimulus_phone/weui-actionsheet.js +43 -0
  51. data/app/assets/javascripts/stimulus_phone/weui-datepicker.js +38 -0
  52. data/app/assets/javascripts/stimulus_phone/weui-dialog.js +24 -0
  53. data/app/assets/javascripts/stimulus_phone/weui-picker.js +54 -0
  54. data/app/assets/javascripts/stimulus_phone/wxpay.js +29 -0
  55. data/app/assets/stylesheets/app.scss +3 -0
  56. data/app/assets/stylesheets/ext_bulma/base/_all.scss +5 -0
  57. data/app/assets/stylesheets/ext_bulma/base/_choices.scss +3 -0
  58. data/app/assets/stylesheets/ext_bulma/base/_global.scss +19 -0
  59. data/app/assets/stylesheets/ext_bulma/base/_main.scss +15 -0
  60. data/app/assets/stylesheets/ext_bulma/components/_all.scss +10 -0
  61. data/app/assets/stylesheets/ext_bulma/components/_box.scss +15 -0
  62. data/app/assets/stylesheets/ext_bulma/components/_breadcrumb.scss +17 -0
  63. data/app/assets/stylesheets/ext_bulma/components/_card.scss +12 -0
  64. data/app/assets/stylesheets/ext_bulma/components/_level.scss +8 -0
  65. data/app/assets/stylesheets/ext_bulma/components/_media.scss +14 -0
  66. data/app/assets/stylesheets/ext_bulma/components/_menu.scss +76 -0
  67. data/app/assets/stylesheets/ext_bulma/components/_pagination.scss +9 -0
  68. data/app/assets/stylesheets/ext_bulma/components/_panel.scss +5 -0
  69. data/app/assets/stylesheets/ext_bulma/elements/_all.scss +7 -0
  70. data/app/assets/stylesheets/ext_bulma/elements/_button.scss +14 -0
  71. data/app/assets/stylesheets/ext_bulma/elements/_fa.scss +4 -0
  72. data/app/assets/stylesheets/ext_bulma/elements/_image.scss +38 -0
  73. data/app/assets/stylesheets/ext_bulma/elements/_table.scss +52 -0
  74. data/app/assets/stylesheets/ext_bulma/elements/_title.scss +9 -0
  75. data/app/assets/stylesheets/ext_bulma/expand/_all.scss +2 -0
  76. data/app/assets/stylesheets/ext_bulma/expand/_slide.scss +26 -0
  77. data/app/assets/stylesheets/ext_bulma/expand/_sortable.scss +4 -0
  78. data/app/assets/stylesheets/ext_bulma/form/_all.scss +34 -0
  79. data/app/assets/stylesheets/ext_bulma/form/_checkbox.scss +267 -0
  80. data/app/assets/stylesheets/ext_bulma/form/_file.scss +23 -0
  81. data/app/assets/stylesheets/ext_bulma/form/_select.scss +5 -0
  82. data/app/assets/stylesheets/ext_bulma/form/_tools.scss +30 -0
  83. data/app/assets/stylesheets/ext_bulma/grid/_all.scss +3 -0
  84. data/app/assets/stylesheets/ext_bulma/grid/_columns.scss +13 -0
  85. data/app/assets/stylesheets/ext_bulma/helpers/_all.scss +5 -0
  86. data/app/assets/stylesheets/ext_bulma/helpers/_dot.scss +11 -0
  87. data/app/assets/stylesheets/ext_bulma/helpers/_drawable.scss +3 -0
  88. data/app/assets/stylesheets/ext_bulma/helpers/_grid.scss +10 -0
  89. data/app/assets/stylesheets/ext_bulma/index.scss +22 -0
  90. data/app/assets/stylesheets/ext_bulma/layout/_all.scss +4 -0
  91. data/app/assets/stylesheets/ext_bulma/layout/_footer.scss +4 -0
  92. data/app/assets/stylesheets/ext_bulma/layout/_level.scss +1 -0
  93. data/app/assets/stylesheets/ext_choices/index.scss +16 -0
  94. data/app/assets/stylesheets/ext_font/index.scss +4 -0
  95. data/app/assets/stylesheets/ext_weui/index.scss +24 -0
  96. data/app/assets/stylesheets/ext_weui/widget/_actionsheet.scss +3 -0
  97. data/app/assets/stylesheets/ext_weui/widget/_article.scss +7 -0
  98. data/app/assets/stylesheets/ext_weui/widget/_button.scss +7 -0
  99. data/app/assets/stylesheets/ext_weui/widget/_cell.scss +17 -0
  100. data/app/assets/stylesheets/ext_weui/widget/_form.scss +3 -0
  101. data/app/assets/stylesheets/ext_weui/widget/_half_screen_dialog.scss +10 -0
  102. data/app/assets/stylesheets/ext_weui/widget/_icon.scss +9 -0
  103. data/app/assets/stylesheets/ext_weui/widget/_media.scss +43 -0
  104. data/app/assets/stylesheets/ext_weui/widget/_panel.scss +4 -0
  105. data/app/assets/stylesheets/ext_weui/widget/_preview.scss +5 -0
  106. data/app/assets/stylesheets/ext_weui/widget/_search.scss +5 -0
  107. data/app/assets/stylesheets/ext_weui/widget/_tab.scss +10 -0
  108. data/app/assets/stylesheets/ext_weui/widget/_tabbar.scss +12 -0
  109. data/app/assets/stylesheets/ext_weui/widget/_uploader.scss +14 -0
  110. data/app/assets/stylesheets/phone.scss +6 -0
  111. data/app/assets/stylesheets/slide/index.scss +208 -0
  112. data/app/assets/stylesheets/ui_tooltip/_mixins.scss +46 -0
  113. data/app/assets/stylesheets/ui_tooltip/_variables.scss +5 -0
  114. data/app/assets/stylesheets/ui_tooltip/index.scss +278 -0
  115. data/app/controllers/design/base_controller.rb +4 -0
  116. data/app/controllers/design/home_controller.rb +13 -0
  117. data/app/views/design/home/swipe.html.erb +7 -0
  118. data/app/views/layouts/ui/base.html.erb +5 -0
  119. data/config/routes.rb +11 -0
  120. data/lib/rails_design/config.rb +8 -0
  121. data/lib/rails_design/engine.rb +5 -0
  122. data/lib/rails_design.rb +2 -0
  123. metadata +181 -0
@@ -0,0 +1,34 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['item']
5
+
6
+ collapse(event) {
7
+ const ele = event.currentTarget
8
+ const par = this.itemTarget
9
+
10
+ let el = par.nextElementSibling
11
+ while (el && el.dataset['depth'] !== par.dataset['depth'] && par.dataset['depth'].endsWith(el.dataset['depth'])) {
12
+ el.style.display = 'none'
13
+ el = el.nextElementSibling
14
+ }
15
+
16
+ ele.classList.replace('fa-caret-down', 'fa-caret-right')
17
+ ele.dataset['action'] = 'click->tree#expand'
18
+ }
19
+
20
+ expand(event) {
21
+ const ele = event.currentTarget
22
+ const par = this.itemTarget
23
+
24
+ let el = par.nextElementSibling
25
+ while (el && el.dataset['depth'] !== par.dataset['depth'] && par.dataset['depth'].endsWith(el.dataset['depth'])) {
26
+ el.style.display = 'table-row'
27
+ el = el.nextElementSibling
28
+ }
29
+
30
+ ele.classList.replace('fa-caret-right', 'fa-caret-down')
31
+ ele.dataset['action'] = 'click->tree#collapse'
32
+ }
33
+
34
+ }
@@ -0,0 +1,64 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['item', 'checkbox']
5
+ static values = {
6
+ hide: Boolean
7
+ }
8
+
9
+ connect() {
10
+ if (this.hideValue) {
11
+ this.collapseDirect()
12
+ }
13
+ }
14
+
15
+ collapseDirect() {
16
+ let el = this.element.nextElementSibling
17
+ while (el && el.id.startsWith(this.element.id)) {
18
+ let to_remove = el
19
+ el = el.nextElementSibling
20
+ to_remove.remove()
21
+ }
22
+ }
23
+
24
+ collapseCheckbox() {
25
+ this.checkboxTargets.forEach(el=> {
26
+ if (el.elements['expand']) {
27
+ el.elements['expand'].value = null
28
+ }
29
+ })
30
+ }
31
+
32
+ collapse(event) {
33
+ const ele = event.currentTarget
34
+ const par = this.itemTarget
35
+ ele.parentNode.addEventListener('click', this.disableLink)
36
+
37
+ let el = par.nextElementSibling
38
+ while (el && el.id.startsWith(par.id)) {
39
+ let to_remove = el
40
+ el = el.nextElementSibling
41
+ to_remove.remove()
42
+ }
43
+
44
+ this.collapseCheckbox()
45
+ ele.classList.replace('fa-caret-down', 'fa-caret-right')
46
+ ele.dataset['action'] = 'click->tree-remote#expand'
47
+ }
48
+
49
+ expand(event) {
50
+ const ele = event.currentTarget
51
+ ele.parentNode.removeEventListener('click', this.disableLink)
52
+
53
+ ele.classList.replace('fa-caret-right', 'fa-caret-down')
54
+ ele.dataset['action'] = 'click->tree-remote#collapse'
55
+ }
56
+
57
+ disableLink(event) {
58
+ event.stopPropagation()
59
+ event.preventDefault()
60
+
61
+ return false
62
+ }
63
+
64
+ }
@@ -0,0 +1,41 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // data-controller="typer"
4
+ export default class extends Controller {
5
+ static targets = ['input', 'value']
6
+
7
+ connect() {
8
+ this.initInput()
9
+ }
10
+
11
+ initInput() {
12
+ const ele = this.inputTarget
13
+ ele.addEventListener('input', this.form)
14
+ ele.addEventListener('compositionstart', event => {
15
+ event.target.removeEventListener('input', this.form)
16
+ })
17
+ ele.addEventListener('compositionend', event => {
18
+ event.target.addEventListener('input', this.form)
19
+ this.form(event)
20
+ })
21
+ }
22
+
23
+ form(event) {
24
+ const ele = event.currentTarget
25
+ if (!ele.value) {
26
+ return
27
+ }
28
+
29
+ const evt = document.createEvent('Event')
30
+ evt.initEvent('submit', true, true)
31
+ ele.form.dispatchEvent(evt)
32
+ }
33
+
34
+ // click->typer#choose
35
+ choose(event) {
36
+ const ele = event.currentTarget
37
+ this.valueTarget.value = ele.dataset['id']
38
+ this.inputTarget.value = ele.dataset['name']
39
+ }
40
+
41
+ }
@@ -0,0 +1,61 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // data-controller="visit"
4
+ export default class extends Controller {
5
+ static values = {
6
+ url: String,
7
+ frame: String,
8
+ reload: Boolean,
9
+ headers: Object
10
+ }
11
+
12
+ connect() {
13
+ if (this.hasFrameValue) {
14
+ this.visit()
15
+ } else {
16
+ this.addEvent(this.headersValue)
17
+ this.topVisit()
18
+ }
19
+
20
+ if (this.hasReloadValue && this.reloadValue) {
21
+ this.replaceAction()
22
+ }
23
+
24
+ document.documentElement.classList.remove('is-clipped')
25
+ this.element.remove()
26
+ }
27
+
28
+ addEvent(headers) {
29
+ document.addEventListener('turbo:before-fetch-request', event => {
30
+ let xhr = event.detail.fetchOptions
31
+ Object.assign(xhr.headers, headers)
32
+ }, { once: true })
33
+ }
34
+
35
+ topVisit() {
36
+ if (this.hasUrlValue) {
37
+ Turbo.visit(this.urlValue, { action: 'replace' })
38
+ } else {
39
+ Turbo.visit(location.href, { action: 'replace' })
40
+ }
41
+ }
42
+
43
+ visit() {
44
+ this.modal.visit(this.urlValue)
45
+ }
46
+
47
+ replaceAction() {
48
+ this.modalWrapper.querySelectorAll('[data-action$="modal#close"]').forEach(ele => {
49
+ ele.dataset.replace('action', 'modal#close', 'modal#reloadClose')
50
+ })
51
+ }
52
+
53
+ get modal() {
54
+ return document.getElementById(this.frameValue).delegate
55
+ }
56
+
57
+ get modalWrapper() {
58
+ return document.getElementById('modal_wrapper')
59
+ }
60
+
61
+ }
@@ -0,0 +1,19 @@
1
+ import { application } from '../rails_ui/stimulus'
2
+ // dependent on Weui
3
+ import QqMapController from './qq_map'
4
+ import SearchController from './search'
5
+ import WechatController from './wechat'
6
+ import WeuiActionsheetController from './weui-actionsheet'
7
+ import WeuiDatepickerController from './weui-datepicker'
8
+ import WeuiDialogController from './weui-dialog'
9
+ import WeuiPickerController from './weui-picker'
10
+ import WxpayController from './wxpay'
11
+
12
+ application.register('qq-map', QqMapController)
13
+ application.register('search', SearchController)
14
+ application.register('wechat', WechatController)
15
+ application.register('weui-actionsheet', WeuiActionsheetController)
16
+ application.register('weui-dialog', WeuiDialogController)
17
+ application.register('weui-datepicker', WeuiDatepickerController)
18
+ application.register('weui-picker', WeuiPickerController)
19
+ application.register('wxpay', WxpayController)
@@ -0,0 +1,29 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static values = {
5
+ name: String,
6
+ index: Number
7
+ }
8
+ static targets = ['load']
9
+
10
+ connect() {
11
+ console.debug('connected:', this.identifier)
12
+ }
13
+
14
+ selected(event) {
15
+ let loc = event.data
16
+ if (loc && loc.module === 'locationPicker') {
17
+ document.getElementById(`${this.nameValue}_${this.indexValue}_lat`).value = loc.latlng.lat
18
+ document.getElementById(`${this.nameValue}_${this.indexValue}_lng`).value = loc.latlng.lng
19
+ document.getElementById(`${this.nameValue}_${this.indexValue}_poiname`).value = loc.poiname
20
+ document.getElementById(`${this.nameValue}_${this.indexValue}_poiaddress`).value = loc.poiaddress
21
+ document.getElementById(`${this.nameValue}_${this.indexValue}_cityname`).value = loc.cityname
22
+
23
+ document.getElementById(`${this.indexValue}_name`).innerText = loc.poiname
24
+
25
+ this.element.remove()
26
+ }
27
+ }
28
+
29
+ }
@@ -0,0 +1,37 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['input', 'label']
5
+
6
+ connect() {
7
+ console.debug('connected:', this.identifier)
8
+ if (this.hasInputTarget && this.inputTarget.value.length > 0) {
9
+ this.focus()
10
+ }
11
+ }
12
+
13
+ focus() {
14
+ this.element.classList.add('weui-search-bar_focusing')
15
+ this.inputTarget.focus()
16
+ }
17
+
18
+ doSearch(element) {
19
+ let ele = element.currentTarget
20
+ if (ele.value.length) {
21
+
22
+ }
23
+ }
24
+
25
+ clear() {
26
+ Turbo.visit(location.pathname, { action: 'replace' })
27
+ this.inputTarget.value = ''
28
+ this.inputTarget.focus()
29
+ }
30
+
31
+ cancel() {
32
+ Turbo.visit(location.pathname, { action: 'replace' })
33
+ this.element.classList.remove('weui-search-bar_focusing')
34
+ this.inputTarget.blur()
35
+ }
36
+
37
+ }
@@ -0,0 +1,80 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['preview', 'media']
5
+
6
+ connect() {
7
+ console.debug('connected:', this.identifier)
8
+ }
9
+
10
+ close() {
11
+ wx.closeWindow()
12
+ }
13
+
14
+ openAddress() {
15
+ wx.ready(() => {
16
+ wx.openAddress({
17
+ success: (res) => {
18
+ document.getElementById('address_contact').value = res.userName
19
+ document.getElementById('address_tel').value = res.telNumber
20
+ document.getElementById('address_detail').value = res.detailInfo
21
+ document.getElementById('address_post_code').value = res.postalCode
22
+ document.getElementById('province_name').value = res.provinceName
23
+ document.getElementById('city_name').value = res.cityName
24
+ document.getElementById('country_name').value = res.countryName
25
+
26
+ let dialog = document.getElementById('dialog')
27
+ application.getControllerForElementAndIdentifier(dialog, 'weui-dialog').show()
28
+ }
29
+ })
30
+ })
31
+ }
32
+
33
+ location() {
34
+ wx.ready(() => {
35
+ wx.getLocation({
36
+ type: 'gcj02',
37
+ success: (res) => {
38
+ wx.openLocation({
39
+ latitude: res.latitude,
40
+ longitude: res.longitude,
41
+ name: '点击右侧打开导航软件',
42
+ address: '点击测试',
43
+ scale: 15
44
+ })
45
+ },
46
+ fail: function(res) {
47
+ alert(res)
48
+ }
49
+ })
50
+ })
51
+ }
52
+
53
+ chooseImage() {
54
+ wx.ready(() => {
55
+ wx.chooseImage({
56
+ count: 1,
57
+ success: (res) => {
58
+ let localId = res.localIds[0]
59
+ this.previewTarget.src = localId
60
+ wx.uploadImage({
61
+ localId: localId,
62
+ success: (res) => {
63
+ this.mediaTarget.value = res.serverId
64
+ this.submit(this.mediaTarget.form)
65
+ }
66
+ })
67
+ }
68
+ })
69
+ })
70
+ }
71
+
72
+ scan() {
73
+ wx.scanQRCode({
74
+ success: function (res) {
75
+ var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
76
+ }
77
+ })
78
+ }
79
+
80
+ }
@@ -0,0 +1,43 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ['mask', 'sheet']
5
+ static values = {
6
+ id: String
7
+ }
8
+
9
+ connect() {
10
+ console.debug('connected:', this.identifier)
11
+ }
12
+
13
+ close() {
14
+ let ele = this.maskTarget
15
+ ele.style.display = 'none'
16
+ ele.style.opacity = 0
17
+ ele.style.transition = 'opacity 2s'
18
+ this.sheetTarget.classList.remove('weui-actionsheet_toggle')
19
+ }
20
+
21
+ show() {
22
+ let ele = this.maskTarget
23
+ ele.style.display = 'block'
24
+ ele.style.opacity = 1
25
+ ele.style.transition = 'opacity 2s'
26
+ this.sheetTarget.classList.add('weui-actionsheet_toggle')
27
+ }
28
+
29
+ toggle() {
30
+ let x = this.target
31
+ if (x.sheetTarget.classList.contains('weui-actionsheet_toggle')) {
32
+ x.close()
33
+ } else {
34
+ x.show()
35
+ }
36
+ }
37
+
38
+ get target() {
39
+ let ele = document.getElementById(this.idValue)
40
+ return application.getControllerForElementAndIdentifier(ele, 'weui-actionsheet')
41
+ }
42
+
43
+ }
@@ -0,0 +1,38 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+ import weui from 'weui.js'
3
+
4
+ export default class extends Controller {
5
+
6
+ connect() {
7
+ console.debug('connected:', this.identifier)
8
+ }
9
+
10
+ // focus->weui#getFocus
11
+ getFocus() {
12
+ document.activeElement.blur()
13
+ }
14
+
15
+ // click->weui#select
16
+ select(e) {
17
+ let d = new Date()
18
+ let da = [d.getFullYear(), d.getMonth() + 1, d.getDate()]
19
+ weui.datePicker({
20
+ start: da.join('-'),
21
+ end: '2020-02-31',
22
+ cron: '* * *',
23
+ defaultValue: da,
24
+ onChange: function onChange(result) {
25
+ console.log(da)
26
+ console.log(result)
27
+ console.log(e.currentTarget)
28
+ console.log(e.target)
29
+ },
30
+ onConfirm: function onConfirm(result) {
31
+ e.target.value = result.join('-')
32
+ },
33
+ id: 'datePicker',
34
+ title: '日期选择器'
35
+ })
36
+ }
37
+
38
+ }