chr 0.2.8 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/Gruntfile.coffee +33 -27
  3. data/README.md +6 -1
  4. data/app/assets/javascripts/chr.coffee +18 -16
  5. data/app/assets/javascripts/chr/core/chr.coffee +41 -76
  6. data/app/assets/javascripts/chr/core/chr_router.coffee +141 -0
  7. data/app/assets/javascripts/chr/core/item.coffee +36 -49
  8. data/app/assets/javascripts/chr/core/list.coffee +26 -71
  9. data/app/assets/javascripts/chr/core/list_config.coffee +28 -13
  10. data/app/assets/javascripts/chr/core/list_pagination.coffee +56 -13
  11. data/app/assets/javascripts/chr/core/list_reorder.coffee +2 -2
  12. data/app/assets/javascripts/chr/core/list_search.coffee +2 -2
  13. data/app/assets/javascripts/chr/core/module.coffee +24 -93
  14. data/app/assets/javascripts/chr/core/utils.coffee +4 -0
  15. data/app/assets/javascripts/chr/core/view.coffee +123 -43
  16. data/app/assets/javascripts/chr/core/view_local-storage.coffee +58 -0
  17. data/app/assets/javascripts/chr/store/{_array-store.coffee → array-store.coffee} +3 -1
  18. data/app/assets/javascripts/chr/store/{_object-store.coffee → object-store.coffee} +0 -0
  19. data/app/assets/javascripts/chr/store/rails-array-store.coffee +39 -0
  20. data/app/assets/javascripts/chr/store/{mongosteen-object-store.coffee → rails-form-object-parser.coffee} +11 -20
  21. data/app/assets/javascripts/chr/store/rails-object-store.coffee +35 -0
  22. data/app/assets/javascripts/chr/store/rest-array-store.coffee +3 -5
  23. data/app/assets/javascripts/chr/store/rest-object-store.coffee +1 -1
  24. data/app/assets/javascripts/form/expandable-group.coffee +30 -0
  25. data/app/assets/javascripts/{chr/form → form}/form.coffee +3 -1
  26. data/app/assets/javascripts/{chr/form → form}/input-checkbox.coffee +1 -1
  27. data/app/assets/javascripts/{chr/form → form}/input-color.coffee +2 -0
  28. data/app/assets/javascripts/{chr/form → form}/input-date.coffee +0 -0
  29. data/app/assets/javascripts/{chr/form → form}/input-file.coffee +28 -1
  30. data/app/assets/javascripts/{chr/form → form}/input-form.coffee +14 -5
  31. data/app/assets/javascripts/{chr/form → form}/input-form_reorder.coffee +0 -0
  32. data/app/assets/javascripts/{chr/form → form}/input-hidden.coffee +9 -9
  33. data/app/assets/javascripts/{chr/form → form}/input-list.coffee +61 -53
  34. data/app/assets/javascripts/{chr/form → form}/input-list_reorder.coffee +2 -0
  35. data/app/assets/javascripts/form/input-list_typeahead.coffee +55 -0
  36. data/app/assets/javascripts/{chr/form → form}/input-password.coffee +1 -0
  37. data/app/assets/javascripts/{chr/form → form}/input-select.coffee +10 -11
  38. data/app/assets/javascripts/form/input-select2.coffee +33 -0
  39. data/app/assets/javascripts/{chr/form → form}/input-string.coffee +45 -2
  40. data/app/assets/javascripts/{chr/form → form}/input-text.coffee +6 -3
  41. data/app/assets/javascripts/input-html.coffee +8 -5
  42. data/app/assets/javascripts/input-markdown.coffee +10 -5
  43. data/app/assets/javascripts/input-redactor.coffee +1 -61
  44. data/app/assets/javascripts/redactor/input-redactor.coffee +53 -0
  45. data/app/assets/javascripts/redactor/input-redactor_character.coffee +83 -0
  46. data/app/assets/javascripts/redactor/input-redactor_images.coffee +166 -0
  47. data/app/assets/javascripts/{chr/vendor → vendor}/ace.js +0 -0
  48. data/app/assets/javascripts/{chr/vendor → vendor}/jquery.scrollparent.js +0 -0
  49. data/app/assets/javascripts/{chr/vendor → vendor}/jquery.textarea_autosize.js +0 -0
  50. data/app/assets/javascripts/{chr/vendor → vendor}/jquery.typeahead.js +0 -0
  51. data/app/assets/javascripts/{chr/vendor → vendor}/marked.js +0 -0
  52. data/app/assets/javascripts/{chr/vendor → vendor}/mode-html.js +0 -0
  53. data/app/assets/javascripts/{chr/vendor → vendor}/mode-markdown.js +0 -0
  54. data/app/assets/javascripts/{chr/vendor → vendor}/redactor.fixedtoolbar.js +1 -1
  55. data/app/assets/javascripts/vendor/select2.js +5274 -0
  56. data/app/assets/javascripts/{chr/vendor → vendor}/slip.js +0 -0
  57. data/app/assets/stylesheets/_chr.scss +11 -13
  58. data/app/assets/stylesheets/_input-redactor.scss +17 -16
  59. data/app/assets/stylesheets/{core → chr}/_icons.scss +1 -1
  60. data/app/assets/stylesheets/chr/_main.scss +110 -0
  61. data/app/assets/stylesheets/{core → chr}/_mixins.scss +58 -34
  62. data/app/assets/stylesheets/{core → chr}/_settings.scss +7 -1
  63. data/app/assets/stylesheets/form/_expandable-group.scss +16 -0
  64. data/app/assets/stylesheets/form/_input-select2.scss +94 -0
  65. data/app/assets/stylesheets/form/_main.scss +180 -0
  66. data/app/assets/stylesheets/vendor/select2.css +258 -0
  67. data/bower.json +2 -2
  68. data/dist/chr.js +2292 -2030
  69. data/dist/input-ace.js +18 -8
  70. data/dist/input-redactor.js +0 -156
  71. data/docs/bootstrap.md +1 -1
  72. data/docs/rails.md +10 -10
  73. data/lib/chr.rb +1 -8
  74. data/lib/chr/version.rb +1 -1
  75. data/lib/mongoid/character.rb +30 -0
  76. data/package.json +1 -1
  77. metadata +49 -43
  78. data/app/assets/javascripts/chr/store/mongosteen-array-store.coffee +0 -55
  79. data/app/assets/stylesheets/core/_list.scss +0 -39
  80. data/app/assets/stylesheets/core/_main.scss +0 -49
  81. data/app/assets/stylesheets/core/_responsive.scss +0 -62
  82. data/app/assets/stylesheets/form/_form.scss +0 -41
  83. data/app/assets/stylesheets/form/_input-checkbox.scss +0 -18
  84. data/app/assets/stylesheets/form/_input-color.scss +0 -10
  85. data/app/assets/stylesheets/form/_input-file.scss +0 -29
  86. data/app/assets/stylesheets/form/_input-form.scss +0 -26
  87. data/app/assets/stylesheets/form/_input-list.scss +0 -36
  88. data/app/assets/stylesheets/form/_input-string.scss +0 -8
@@ -1,55 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # RAILS ARRAY STORE
11
- # -----------------------------------------------------------------------------
12
- class @MongosteenArrayStore extends RestArrayStore
13
-
14
- # PRIVATE ===============================================
15
-
16
- _configure_store: ->
17
- @ajaxConfig =
18
- processData: false
19
- contentType: false
20
-
21
-
22
- # generate resource api url
23
- _resource_url: (type, id) ->
24
- objectPath = if id then "/#{ id }" else ''
25
- "#{ @config.path }#{ objectPath }.json"
26
-
27
-
28
- # get form data object from serialized form object,
29
- # it uses special format for object names for support of:
30
- # files, lists, nested objects
31
- _parse_form_object: (serializedFormObject) ->
32
- formDataObject = new FormData()
33
-
34
- for attr_name, attr_value of serializedFormObject
35
-
36
- # special case for LIST inputs, values separated with comma
37
- if attr_name.indexOf('[__LIST__') > -1
38
- attr_name = attr_name.replace('__LIST__', '')
39
- values = attr_value.split(',')
40
-
41
- for value in values
42
- formDataObject.append("#{ @config.resource }#{ attr_name }[]", value)
43
-
44
- else
45
- # special case for FILE inputs
46
- if attr_name.startsWith('__FILE__')
47
- attr_name = attr_name.replace('__FILE__', '')
48
-
49
- formDataObject.append("#{ @config.resource }#{ attr_name }", attr_value)
50
-
51
- return formDataObject
52
-
53
-
54
-
55
-
@@ -1,39 +0,0 @@
1
- .list {
2
- header {
3
- .search {
4
- @include absolutePosition(0 0 inherit inherit);
5
- width: 40px; height: 40px; overflow: hidden;
6
-
7
- .icon { @extend .icon-search; @include absolutePosition(0 inherit inherit 0); }
8
- input { height: 40px; width: 100%; padding: 0 5em 0 2.5em; outline: none; border: none; }
9
- input { display: none; }
10
- .cancel { @include headerButton; @include absolutePosition(0 1em initial initial); }
11
- .cancel { display: none; }
12
- }
13
- .new + .search { @include absolutePosition(0 40px inherit inherit); }
14
-
15
- .spinner { @include spinner; position: absolute; margin: .5em 0 0 -2.25em; }
16
- .spinner { display: none; }
17
- }
18
-
19
- &.list-search {
20
- header {
21
- .search {
22
- @include absolutePosition(0 0 inherit 0);
23
- width: 100%; background-color: $white;
24
-
25
- input { display: block; }
26
- .cancel { display: inline; }
27
- .icon:hover { opacity: 1; }
28
- .icon:before { border-color: $stableColor; }
29
- .icon:after { background-color: $stableColor; }
30
- }
31
- .new + .search { @include absolutePosition(0 0 inherit 0); }
32
- }
33
- .item-folder { display: none; }
34
- }
35
-
36
- &.show-spinner {
37
- header .spinner { display: inline-block; }
38
- }
39
- }
@@ -1,49 +0,0 @@
1
- /* Generic ----------------------------------------------------------------- */
2
- *, *:before, *:after { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
3
- html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
4
- font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
5
- a { text-decoration: none; }
6
- }
7
- html, body, .view { overflow: hidden; }
8
-
9
- /* Menu -------------------------------------------------------------------- */
10
- .menu:before { content: 'CHR'; font-weight: 800; color: $contrastColor; line-height: 2.7;
11
- position: absolute; display: block; margin-top: -2.7em; padding-left: 1em;
12
- background-color: #fff; width: 100%; }
13
- .menu { margin-top: 2.7em; font-size: .8em; letter-spacing: 1px; text-transform: uppercase; }
14
-
15
- /* Headers ----------------------------------------------------------------- */
16
- .view header,
17
- .list header { text-align: center; position: relative; z-index: 1; line-height: 2.6; max-height: 42px; background-color: $white;
18
- .title { font-weight: 500; color: $black; display: inline-block; max-width: 70%; @include truncate; }
19
- .back, .close { @include absolutePosition(0 inherit inherit 0); @extend .icon-back; overflow: hidden; height: 41px; }
20
- .new { @include absolutePosition(0 0 inherit inherit); @extend .icon-plus; }
21
- .save { @include absolutePosition(0 1em inherit inherit); @include headerButton; }
22
- }
23
-
24
- /* Items ------------------------------------------------------------------- */
25
- .items { @include absolutePosition(42px 0 0 0); @include scrollable(); padding-bottom: 5em; }
26
- .menu a, .items .item {
27
- display: block; position: relative;
28
- padding: 1em; color: $black; @include border($neutralColor); margin-top: -1px;
29
- &.active { background-color: $neutralColor; z-index: 1; }
30
- &:first-child { @include noBorder(); }
31
- }
32
- .items .item {
33
- &.has-subtitle { padding: .6em 1em; }
34
- &.has-thumbnail { padding-left: 4.1em; }
35
- &.has-thumbnail .item-title { line-height: 2.15; }
36
- &.has-thumbnail.has-subtitle { padding-top: 1em; padding-bottom: .75em; }
37
- &.has-thumbnail.has-subtitle .item-title { line-height: 1.2; }
38
- &.reorderable { padding-right: 2.5em; }
39
- .icon-reorder { top: 50%; margin-top: -20px; right: 0; }
40
- }
41
- .item-title { @include truncate; }
42
- .item-subtitle { @include truncate; color: $stableColor; font-size: .8em; line-height: 1.5; }
43
- .item-thumbnail { @include absolutePosition(.5em 0 0 .5em); width: 3.1em; height: 3.1em; }
44
- .item-thumbnail img { width: 100%; border-radius: 25px; }
45
-
46
-
47
-
48
-
49
-
@@ -1,62 +0,0 @@
1
- /* Layouts */
2
- $tablet: "screen and (min-width:768px)";
3
- $desktop: "screen and (min-width:1150px)";
4
-
5
-
6
- /* Mobile Layout */
7
- .sidebar { @include absolutePosition(0 0 0 0); z-index: 1; }
8
- .module { @include absolutePosition(0 0 0 0); z-index: 2; }
9
- .view { @include absolutePosition(0 0 0 0); z-index: 3; background-color: #fff; }
10
- .list { @include absolutePosition(0 0 0 0); z-index: 0; overflow: hidden; background-color: #fff; }
11
-
12
-
13
- /* Tablet Layout */
14
- @media #{$tablet} {
15
- .sidebar { right: inherit; width: 9em; }
16
- .module { right: inherit; left: 9em; width: 20em; }
17
- .view { left: 29em; &.fullsize { left: 9em; } }
18
- .list header,
19
- .list .items { font-size: .9em; }
20
- .list header { line-height: 2.9em; }
21
- .module .list:first-child .back { display: none; }
22
- .view header .close { @include absolutePosition(0 inherit inherit 1em); @include headerButton; width: auto; &:before { display: none; } }
23
- .module, .view { @include shadow; }
24
- .module {
25
- &:after {
26
- display: block; content: ''; width: 4px; @include position(absolute, 0px -3px 0px null);
27
- background-color: $white; border-left: 1px solid $neutralColor;
28
- }
29
- }
30
-
31
- // scrollbars
32
- .view .input-stacked textarea, .view > form, .list .items { @include customScrollbar(); }
33
-
34
- // layout when first list always shown
35
- .module.first-list-aside { width: auto; right: 0;
36
- .list {
37
- &:first-child { width: 20em; }
38
- &:not(:first-child) { left: 20em; }
39
- &:first-child .items { overflow-y: hidden; }
40
- &:first-child .icon-folder { display: none; }
41
- &:not(:first-child) { @include shadow; }
42
- &:not(:first-child) header .back { display: none; }
43
- }
44
- }
45
- }
46
-
47
-
48
- /* Desktop Layout */
49
- @media #{$desktop} {
50
- .sidebar { width: 10em; }
51
- .module { left: 10em; width: 22em; }
52
- .view { left: 32em; &.fullsize { left: 10em; } }
53
-
54
- .module.first-list-aside {
55
- .list:first-child { width: 22em; }
56
- .list:not(:first-child) { left: 22em; }
57
- }
58
- }
59
-
60
-
61
-
62
-
@@ -1,41 +0,0 @@
1
- /* Form -------------------------------------------------------------------- */
2
- .view {
3
- form { @include absolutePosition(42px 0 0 0); @include scrollable(); z-index: 0; padding-bottom: 5em; }
4
- form { color: $black; }
5
- label { display: block; }
6
-
7
- .input-stacked {
8
- @include position(relative); @include border($neutralColor); &:first-child { @include noBorder(); }
9
- padding: .5em 1em .9em;
10
-
11
- &.input-text { min-height: 82px; } // workaround for empty or oneline textareas
12
- &.input-select select { margin-top: 0.15em; }
13
-
14
- textarea { resize: none; overflow: auto; }
15
- textarea { box-sizing: border-box; min-height: 20px; /* max-height: 400px; /* optional */ }
16
- textarea,
17
- input { outline-style: none; border: 0; width: 100%; @include placeholder { color: $lightColor; } }
18
- .label { display: block; line-height: 1.8; color: $stableColor; }
19
- }
20
-
21
- .delete { display: block; text-align: center; margin: 5em 0; line-height: 2.5em;
22
- color: $assertiveColor; border: 1px solid $assertiveColor; border-left: none; border-right: none;
23
- &:hover, &:active { background-color: $assertiveColor; color: #fff; } }
24
-
25
- .error-message { color: $assertiveColor; font-size: .8em; margin-left: .5em; }
26
-
27
- &.view-saving {
28
- header .save { display: none; }
29
- header:after {
30
- font-size: .8em;
31
- content: 'Saving...';
32
- opacity: .4;
33
- @include absolutePosition(.4em .8em inherit inherit);
34
- }
35
- }
36
- }
37
-
38
-
39
-
40
-
41
-
@@ -1,18 +0,0 @@
1
-
2
- // Checkbox -----------------------------------------------
3
-
4
- .view .input-checkbox { padding: .8em 1em 1em;
5
- input { display: inline; width: auto; margin-right: .5em; }
6
- .label { display: inline; cursor: pointer; }
7
- }
8
-
9
-
10
- // Switch -------------------------------------------------
11
-
12
- .view .input-switch { padding-top: .75em;
13
- .label { cursor: pointer; }
14
- .switch { @include switchControl(); float: right; }
15
- }
16
-
17
-
18
-
@@ -1,10 +0,0 @@
1
- /* Color ------------------------------------------------------------------- */
2
- .view .input-color {
3
- position: relative;
4
- padding-left: 4.75em;
5
-
6
- .preview {
7
- @include position(absolute, .65em null null 1em);
8
- width: 50px; height: 50px; border-radius: 4px; background-color: #eee;
9
- }
10
- }
@@ -1,29 +0,0 @@
1
- /* File & Image ------------------------------------------------------------ */
2
- .view .input-file,
3
- .view .input-image {
4
- min-height: 102px; // NOTE: calculated based on image thumbnail size
5
-
6
- a { color: $positiveColor; @include truncate; }
7
- a:hover { text-decoration: underline; }
8
-
9
- input[type=file] { margin-top: .5em; }
10
- input[type=checkbox] { display: inline; width: auto; margin-right: .5em; margin-left: 1em; }
11
- label { display: inline; font-size: .8em; }
12
-
13
- &.empty {
14
- img, a, label, input[type=checkbox] { display: none; }
15
- input[type=file] { margin-top: .2em; }
16
- }
17
- }
18
-
19
- .view .input-image:not(.empty) {
20
- padding-left: 6.5em;
21
- position: relative;
22
- img {
23
- position: absolute;
24
- border-radius: 4px;
25
- left: 1em;
26
- top: .8em;
27
- width: 4.7em;
28
- }
29
- }
@@ -1,26 +0,0 @@
1
- /* Nested Form ------------------------------------------------------------- */
2
- .view .nested-forms {
3
- & > .label { margin-bottom: .25em; }
4
- & > ul { margin: 0; padding: 0; }
5
- & > ul > li { list-style-type: none; margin-top: 1em; @include position(relative); border: 1px solid $neutralColor; }
6
- & > ul > li:first-child { margin-top: 0; }
7
- & > ul > li > .icon-reorder { left: 0; top: 1em; }
8
- & > ul li.reorderable { background-color: $white; }
9
- & > ul li.reorderable > .input-stacked:first-child { padding-left: 2.4em; }
10
- }
11
-
12
- .view .nested-form-new {
13
- color: $positiveColor; margin-top: .75em; display: inline-block; font-size: .9em;
14
- &:hover { opacity: .5; }
15
- }
16
-
17
- .view .nested-form-delete {
18
- @include position(absolute, .35em .3em null null); border-radius: 1em;
19
- @include hide-text; width: 1.5em; height: 1.5em; background-color: rgba(0,0,0,.05);
20
- &:before { content: '\00d7'; color: $stableColor; line-height: 1.35em; width: 1.5em; text-align: center; }
21
- &:hover { background-color: $positiveColor; &:before { color: $white; } }
22
- }
23
-
24
-
25
-
26
-
@@ -1,36 +0,0 @@
1
- /* List -------------------------------------------------------------------- */
2
- .view .input-list {
3
- input { padding-left: 2em; margin-top: .1em; }
4
- ul { line-height: 1.5; margin: 0 0 0 2em; list-style: none; padding: 0; }
5
- ul li { @include user-select-none; position: relative; }
6
- ul li a { color: $assertiveColor; font-size: .75em; }
7
-
8
- .slip-reordering { color: $positiveColor; }
9
-
10
- .icon-reorder {
11
- width: 25px;
12
- height: 25px;
13
- left: -1.75em;
14
- &:before { left: 0; top: 9px; }
15
- &:after { left: 0; top: 14px; }
16
- }
17
- }
18
-
19
- .view .input-list {
20
- .twitter-typeahead { width: 100%; }
21
- .twitter-typeahead:after {
22
- content: '+';
23
- display: block;
24
- width: 40px;
25
- height: 24px;
26
- position: absolute; left: 12px; top: -3px;
27
- font-size: 22px;
28
- color: $contrastColor;
29
- }
30
-
31
- .tt-suggestions { padding: .1em .5em; margin: 0 0 0 1.55em; background: rgba(255,255,255, .95); }
32
- .tt-suggestion { cursor: pointer; opacity: .5;
33
- p { line-height: 1.5; margin: 0; }
34
- &.tt-cursor { opacity: 1; }
35
- }
36
- }
@@ -1,8 +0,0 @@
1
- .view .input-string {
2
- .twitter-typeahead { width: 100%; }
3
- .tt-suggestions { padding: .1em .5em; margin: 0 0 0 -.5em; background: rgba(255,255,255, .95); }
4
- .tt-suggestion { cursor: pointer; opacity: .5;
5
- p { line-height: 1.5; margin: 0; }
6
- &.tt-cursor { opacity: 1; }
7
- }
8
- }