gina 0.1.1-alpha.16 → 0.1.1-alpha.161

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 (324) hide show
  1. package/AUTHORS +2 -1
  2. package/LICENSE +1 -1
  3. package/README-4Contributors.md +30 -0
  4. package/README.md +202 -32
  5. package/bin/cli +165 -68
  6. package/bin/cli-debug +49 -18
  7. package/bin/cmd +40 -18
  8. package/bin/gina +48 -37
  9. package/{framework/v0.1.1-alpha.16/core/template/command/gina.bat.tpl → bin/gina.bat} +0 -0
  10. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/AUTHORS +0 -0
  11. package/framework/{v0.1.1-alpha.16/lib/inherits → v0.1.1-alpha.161}/LICENSE +1 -1
  12. package/framework/v0.1.1-alpha.161/VERSION +1 -0
  13. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/html/nolayout.html +0 -0
  14. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/html/static.html +0 -0
  15. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/android-chrome-192x192.png +0 -0
  16. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/android-chrome-512x512.png +0 -0
  17. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/apple-touch-icon.png +0 -0
  18. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/favicon-16x16.png +0 -0
  19. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/favicon-32x32.png +0 -0
  20. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/asset/img/favicon.ico +0 -0
  21. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.js +887 -874
  22. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.js.map +3 -3
  23. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.min.css +0 -0
  24. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.min.css.map +0 -0
  25. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/gina.min.js +739 -0
  26. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/gina.min.js.map +8 -0
  27. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.onload.min.js +0 -0
  28. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/dist/gina.onload.min.js.map +0 -0
  29. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/css/toolbar-min.css +1 -0
  30. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/css/toolbar.css +3 -0
  31. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/css/toolbar.css.map +1 -0
  32. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/js/jquery-3.1.0.min.js +4 -0
  33. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/main.js +1542 -0
  34. package/framework/v0.1.1-alpha.161/core/asset/plugin/dist/toolbar/toolbar.html +251 -0
  35. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/readme.md +6 -6
  36. package/framework/{v0.1.1-alpha.16/core/asset/js → v0.1.1-alpha.161/core/asset}/plugin/uuid.json +0 -0
  37. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/config.js +29 -14
  38. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/index.js +331 -222
  39. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/connector.js +6 -4
  40. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/connector.v2.js +47 -47
  41. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/connector.v3.js +0 -0
  42. package/framework/v0.1.1-alpha.161/core/connectors/couchbase/lib/connector.v4.js +384 -0
  43. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/n1ql.js +3 -2
  44. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/session-store.js +6 -5
  45. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/session-store.v2.js +0 -0
  46. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/connectors/couchbase/lib/session-store.v3.js +0 -0
  47. package/framework/v0.1.1-alpha.161/core/connectors/couchbase/lib/session-store.v4.js +362 -0
  48. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/controller/controller.framework.js +0 -0
  49. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/controller/controller.js +691 -677
  50. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/controller/index.js +0 -0
  51. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/.travis.yml +0 -0
  52. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/LICENSE +0 -0
  53. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/README.md +0 -0
  54. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/deps/encoding/encoding-indexes.js +0 -0
  55. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/deps/encoding/encoding.js +0 -0
  56. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/lib/main.js +0 -0
  57. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/lib/types/multipart.js +0 -0
  58. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/lib/types/urlencoded.js +0 -0
  59. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/lib/utils.js +0 -0
  60. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/busboy/package.json +0 -0
  61. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/deps/swig-client/swig-2.0.0.min.js +0 -0
  62. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/dev/index.js +1 -1
  63. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/dev/lib/class.js +0 -0
  64. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/dev/lib/factory.js +1 -1
  65. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/dev/lib/tools.js +0 -0
  66. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/gna.js +3 -4
  67. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/README.md +0 -0
  68. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/currency.json +0 -0
  69. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/dist/language/en.json +0 -0
  70. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/dist/language/fr.json +0 -0
  71. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/dist/region/en.json +0 -0
  72. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/dist/region/fr.json +0 -0
  73. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/index.js +2 -2
  74. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/src/make.js +0 -0
  75. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/src/resources/currency.csv +0 -0
  76. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/src/resources/region.csv +0 -0
  77. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/locales/src/resources/region.mapping.json +0 -0
  78. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/mime.types +0 -0
  79. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/model/entity.js +81 -61
  80. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/model/index.js +8 -7
  81. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/model/template/entityFactory.js +1 -1
  82. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/model/template/index.js +1 -1
  83. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/README.md +0 -0
  84. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/index.js +1 -1
  85. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/file/README.md +0 -0
  86. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/file/build.json +0 -0
  87. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/file/package.json +1 -1
  88. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/intl/README.md +0 -0
  89. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/intl/build.json +0 -0
  90. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/intl/package.json +1 -1
  91. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/intl/src/main.js +0 -0
  92. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/storage/README.md +0 -0
  93. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/storage/build.json +0 -0
  94. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/storage/package.json +1 -1
  95. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/storage/src/main.js +0 -0
  96. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/validator/README.md +0 -0
  97. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/validator/build.json +0 -0
  98. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/validator/package.json +1 -1
  99. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/validator/src/form-validator.js +0 -0
  100. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/plugins/lib/validator/src/main.js +0 -0
  101. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/router.js +92 -79
  102. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/server.express.js +0 -0
  103. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/server.isaac.js +117 -108
  104. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/server.js +44 -1
  105. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/status.codes +0 -0
  106. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/config/app.json +0 -0
  107. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/config/routing.json +0 -0
  108. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/config/settings.json +0 -0
  109. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/config/settings.server.json +0 -0
  110. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/config/templates.json +4 -4
  111. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/controllers/controller.content.js +0 -0
  112. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/controllers/controller.js +0 -0
  113. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/controllers/setup.js +0 -0
  114. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle/index.js +0 -0
  115. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_namespace/controllers/controller.js +0 -0
  116. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_public/css/default.css +0 -0
  117. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_public/css/vendor/readme.md +0 -0
  118. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_public/favicon.ico +0 -0
  119. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_public/js/vendor/readme.md +0 -0
  120. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_public/readme.md +0 -0
  121. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/boilerplate/bundle_templates/handlers/main.js +0 -0
  122. package/framework/v0.1.1-alpha.161/core/template/boilerplate/bundle_templates/html/content/homepage.html +8 -0
  123. package/framework/v0.1.1-alpha.161/core/template/boilerplate/bundle_templates/html/includes/error-msg-noscript.html +11 -0
  124. package/framework/v0.1.1-alpha.161/core/template/boilerplate/bundle_templates/html/includes/error-msg-outdated-browser.html +8 -0
  125. package/framework/{v0.1.1-alpha.16/core/template/boilerplate/bundle_templates/html/layout → v0.1.1-alpha.161/core/template/boilerplate/bundle_templates/html/layouts}/main.html +10 -3
  126. package/framework/v0.1.1-alpha.161/core/template/command/gina.bat.tpl +8 -0
  127. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/command/gina.tpl +1 -1
  128. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/env.json +0 -0
  129. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/manifest.json +0 -0
  130. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/package.json +1 -1
  131. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/settings.json +0 -0
  132. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/statics.json +3 -3
  133. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/conf/templates.json +2 -2
  134. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/client/json/401.json +0 -0
  135. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/client/json/403.json +0 -0
  136. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/client/json/404.json +0 -0
  137. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/server/html/50x.html +0 -0
  138. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/server/json/500.json +0 -0
  139. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/error/server/json/503.json +0 -0
  140. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/core/template/extensions/logger/config.json +0 -0
  141. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/console.js +1 -1
  142. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/context.js +145 -5
  143. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/dateFormat.js +4 -2
  144. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/index.js +10 -5
  145. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/json/README.md +0 -0
  146. package/framework/{v0.1.1-alpha.16/helpers/plugins → v0.1.1-alpha.161/helpers/json}/package.json +1 -1
  147. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/json/src/main.js +22 -22
  148. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/path.js +143 -89
  149. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/plugins/README.md +0 -0
  150. package/framework/{v0.1.1-alpha.16/helpers/json → v0.1.1-alpha.161/helpers/plugins}/package.json +1 -1
  151. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/plugins/src/api-error.js +23 -23
  152. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/plugins/src/main.js +2 -2
  153. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/prototypes.js +35 -36
  154. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/task.js +21 -14
  155. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/helpers/text.js +1 -1
  156. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/archiver/README.md +0 -0
  157. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/archiver/build.json +0 -0
  158. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/archiver/package.json +1 -1
  159. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/archiver/src/dep/jszip.min.js +0 -0
  160. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/archiver/src/main.js +167 -167
  161. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/aliases.json +4 -1
  162. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/add.js +43 -17
  163. package/framework/v0.1.1-alpha.161/lib/cmd/bundle/arguments.json +6 -0
  164. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/copy.js +0 -0
  165. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/cp.js +0 -0
  166. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/help.js +0 -0
  167. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/help.txt +2 -2
  168. package/framework/v0.1.1-alpha.161/lib/cmd/bundle/list.js +176 -0
  169. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/remove.js +22 -22
  170. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/rename.js +0 -0
  171. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/restart.js +0 -0
  172. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/rm.js +0 -0
  173. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/start.js +257 -46
  174. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/status.js +0 -0
  175. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/bundle/stop.js +93 -74
  176. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/add.js +0 -0
  177. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/get.js +0 -0
  178. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/help.js +0 -0
  179. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/help.txt +0 -0
  180. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/link-dev.js +0 -0
  181. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/list.js +0 -0
  182. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/remove.js +0 -0
  183. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/rm.js +0 -0
  184. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/set.js +0 -0
  185. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/env/unset.js +0 -0
  186. package/framework/{v0.1.1-alpha.16/lib/cmd/scope → v0.1.1-alpha.161/lib/cmd/env}/use.js +21 -1
  187. package/framework/v0.1.1-alpha.161/lib/cmd/framework/build.js +85 -0
  188. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/dot.js +0 -0
  189. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/get.js +0 -0
  190. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/help.js +0 -0
  191. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/help.txt +0 -0
  192. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/init.js +212 -21
  193. package/framework/v0.1.1-alpha.161/lib/cmd/framework/link-node-modules.js +86 -0
  194. package/framework/v0.1.1-alpha.161/lib/cmd/framework/link.js +94 -0
  195. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/msg.json +0 -0
  196. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/open.js +15 -0
  197. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/restart.js +58 -26
  198. package/framework/v0.1.1-alpha.161/lib/cmd/framework/set.js +264 -0
  199. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/start.js +35 -12
  200. package/framework/v0.1.1-alpha.161/lib/cmd/framework/status.js +138 -0
  201. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/stop.js +44 -28
  202. package/framework/v0.1.1-alpha.161/lib/cmd/framework/tail.js +271 -0
  203. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/update.js +0 -0
  204. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/framework/version.js +12 -3
  205. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/gina-dev.1.md +0 -0
  206. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/gina-framework.1.md +0 -0
  207. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/gina.1.md +0 -0
  208. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/helper.js +74 -5
  209. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/index.js +22 -22
  210. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/msg.json +0 -0
  211. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/port/help.js +0 -0
  212. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/port/help.txt +0 -0
  213. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/port/inc/scan.js +32 -17
  214. package/framework/v0.1.1-alpha.161/lib/cmd/port/list.js +446 -0
  215. package/framework/v0.1.1-alpha.161/lib/cmd/port/reset.js +426 -0
  216. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/port/set.js +0 -0
  217. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/add.js +146 -122
  218. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/arguments.json +0 -0
  219. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/build.js +0 -0
  220. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/help.js +0 -0
  221. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/help.txt +0 -0
  222. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/import.js +0 -0
  223. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/list.js +16 -2
  224. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/move.js +0 -0
  225. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/remove.js +17 -17
  226. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/rename.js +0 -0
  227. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/restart.js +0 -0
  228. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/rm.js +0 -0
  229. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/start.js +0 -0
  230. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/status.js +0 -0
  231. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/project/stop.js +0 -0
  232. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/protocol/help.js +0 -0
  233. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/protocol/help.txt +0 -0
  234. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/protocol/list.js +0 -0
  235. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/protocol/set.js +239 -201
  236. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/help.js +0 -0
  237. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/help.txt +0 -0
  238. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/link-local.js +0 -0
  239. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/list.js +0 -0
  240. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/remove.js +0 -0
  241. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/rm.js +0 -0
  242. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/set.js +0 -0
  243. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/scope/unset.js +0 -0
  244. package/framework/{v0.1.1-alpha.16/lib/cmd/env → v0.1.1-alpha.161/lib/cmd/scope}/use.js +0 -0
  245. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cmd/view/add.js +34 -9
  246. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/collection/README.md +0 -0
  247. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/collection/build.json +0 -0
  248. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/collection/package.json +1 -1
  249. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/collection/src/main.js +0 -0
  250. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/config.js +2 -1
  251. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cron/README.md +0 -0
  252. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cron/package.json +1 -1
  253. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/cron/src/main.js +0 -0
  254. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/generator/index.js +1 -1
  255. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/index.js +1 -1
  256. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161/lib/inherits}/LICENSE +1 -1
  257. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/README.md +0 -0
  258. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/example/inheriting_eventemitter.js +0 -0
  259. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/example/protected_inheritance.js +0 -0
  260. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/example/simple_inheritance.js +0 -0
  261. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/example/super_attribute_overridden_by_child_on_init.js +0 -0
  262. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/package.json +1 -1
  263. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/inherits/src/main.js +1 -1
  264. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/README.md +0 -0
  265. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/package.json +1 -1
  266. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/default/index.js +13 -2
  267. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/file/index.js +105 -14
  268. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/file/lib/logrotator/README.md +0 -0
  269. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/file/lib/logrotator/index.js +0 -0
  270. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/mq/index.js +2 -1
  271. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/mq/listener.js +16 -14
  272. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/containers/mq/speaker.js +32 -3
  273. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/helper.js +20 -1
  274. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/logger/src/main.js +5 -2
  275. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/math/index.js +7 -7
  276. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/README.md +0 -0
  277. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/example/merge.js +0 -0
  278. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/example/merge_2_literal objects.js +0 -0
  279. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/example/merge_and_preserve_first.js +0 -0
  280. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/package.json +1 -1
  281. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/merge/src/main.js +0 -0
  282. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/model.js +9 -9
  283. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/proc.js +75 -47
  284. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/routing/README.md +0 -0
  285. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/routing/build.json +0 -0
  286. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/routing/package.json +1 -1
  287. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/routing/src/main.js +258 -258
  288. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/session-store.js +6 -6
  289. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/shell.js +3 -3
  290. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/swig-filters/README.md +0 -0
  291. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/swig-filters/package.json +1 -1
  292. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/swig-filters/src/main.js +55 -52
  293. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/url/README.md +0 -0
  294. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/url/index.js +0 -0
  295. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/url/mocks.json +0 -0
  296. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/url/routing.json +0 -0
  297. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/url/test.js +0 -0
  298. package/framework/{v0.1.1-alpha.16 → v0.1.1-alpha.161}/lib/validator.js +0 -0
  299. package/framework/v0.1.1-alpha.161/package.json +14 -0
  300. package/package.json +33 -24
  301. package/resources/home/main.json +44 -1
  302. package/resources/home/settings.json +7 -0
  303. package/resources/home/user/extensions/logger/default/config.json +1 -1
  304. package/resources/package.json.template +29 -18
  305. package/script/post_install.js +410 -120
  306. package/script/post_publish.js +185 -0
  307. package/script/pre_install.js +424 -76
  308. package/script/prepare_version.js +152 -22
  309. package/utils/helper.js +230 -185
  310. package/utils/prototypes.js +9 -9
  311. package/utils/prototypes.json_clone.js +31 -31
  312. package/doc/framework/cli/doc.json +0 -9
  313. package/doc/framework/index.md +0 -60
  314. package/framework/v0.1.1-alpha.16/VERSION +0 -1
  315. package/framework/v0.1.1-alpha.16/core/asset/js/plugin/dist/gina.min.js +0 -736
  316. package/framework/v0.1.1-alpha.16/core/asset/js/plugin/dist/gina.min.js.map +0 -56
  317. package/framework/v0.1.1-alpha.16/core/template/boilerplate/bundle_templates/html/homepage.html +0 -4
  318. package/framework/v0.1.1-alpha.16/lib/cmd/bundle/arguments.json +0 -4
  319. package/framework/v0.1.1-alpha.16/lib/cmd/bundle/list.js +0 -129
  320. package/framework/v0.1.1-alpha.16/lib/cmd/framework/set.js +0 -161
  321. package/framework/v0.1.1-alpha.16/lib/cmd/framework/status.js +0 -72
  322. package/framework/v0.1.1-alpha.16/lib/cmd/framework/tail.js +0 -183
  323. package/framework/v0.1.1-alpha.16/lib/cmd/port/list.js +0 -176
  324. package/framework/v0.1.1-alpha.16/package.json +0 -14
@@ -0,0 +1,1542 @@
1
+ define('gina/toolbar', ['require', 'jquery', 'vendor/uuid'/**, 'utils/merge'*/, 'utils/collection', 'utils/routing', 'gina/storage', 'gina/validator' ], function (require) {
2
+
3
+ var $ = require('jquery');
4
+ $.noConflict();
5
+ //var merge = require('utils/merge');
6
+ var routing = require('utils/routing');
7
+ var Collection = require('utils/collection');
8
+ var Storage = require('gina/storage');
9
+ //var Validator = require('gina/validator');
10
+
11
+ /**
12
+ * Toolbar plugin
13
+ *
14
+ * TODO - search using `datatables` plugin (https://stackoverflow.com/questions/10400033/is-there-a-jquery-plugin-like-datatables-for-a-ul)
15
+ */
16
+ function Toolbar() {
17
+
18
+ //console.debug('Toolbar jquery is ', $.fn.jquery);
19
+
20
+ var self = {
21
+ version : '1.0.3',
22
+ foldingPaths : {},
23
+ foldingClass : null,
24
+ isUnfolded : null,
25
+ isXHR : false,
26
+ isValidator : false,
27
+ hasParsedUrls : false
28
+ };
29
+
30
+ var bucket = new Storage({bucket: 'gina'}) // <Bucket>
31
+ , plugins = bucket.Collection('plugin') // <Collection>
32
+ //, validator = new Validator() // <Validator>
33
+ ;
34
+
35
+ var $toolbar = null
36
+ , settings = null
37
+ , isCollapsed = false
38
+ , $tabs = null
39
+ , $logo = null
40
+ , $panelsContainer = null
41
+ , $panels = null
42
+ , $currentPanel = null
43
+ , panelId = ''
44
+ , $verticalPos = null
45
+ , $horizontalPos = null
46
+ , $toolbarPos = null
47
+ , position = ''
48
+ , $toolbarWidth = null
49
+ , width = 0
50
+ , $toolbarHeight = null
51
+ , toolbarHeight = 0
52
+ , contentHeight = 0
53
+ , keynum = ''
54
+ , lastPressedKey = {}
55
+ , coockie = null
56
+ , $json = null
57
+ , $ginaJson = null
58
+ , $jsonRAW = null
59
+ , originalData = null
60
+ , jsonObject = null
61
+ , lastJsonObjectState = null
62
+ , ginaJsonObject = null
63
+ , forms = null
64
+ , formsIgnored = '.gina-toolbar-options, .gina-toolbar-content'
65
+ , $htmlConfigurationEnvironment = null
66
+ , $htmlData = null
67
+ , $htmlView = null
68
+ , $htmlForms = null
69
+ , $codeFoldingToggle = null
70
+ , codeFolding = true
71
+ , timeoutId = null
72
+ , $copyCache = null
73
+ , copyValue = null
74
+ ;
75
+
76
+ var init = function () {
77
+ // Get elements
78
+ $toolbar = $('#gina-toolbar');
79
+ if (!$toolbar.length) return false;
80
+
81
+ $tabs = $toolbar.find('.gina-toolbar-tab > a');
82
+ $logo = $('#gina-toolbar-toggle');
83
+ $panelsContainer = $('#gina-toolbar-panels');
84
+ $panels = $panelsContainer.find('.gina-toolbar-panel');
85
+ $verticalPos = $('#gina-toolbar-vposition');
86
+ $horizontalPos = $('#gina-toolbar-hposition');
87
+ $toolbarPos = $verticalPos.add($horizontalPos);
88
+ $toolbarWidth = $('#gina-toolbar-width');
89
+ $toolbarHeight = $toolbar.find('.gina-toolbar-main');
90
+ $json = $('#gina-toolbar-json');
91
+ $ginaJson = $('#gina-toolbar-gina-json');
92
+ $jsonRAW = $('#gina-toolbar-toggle-code-raw');
93
+ $forms = $('form:not('+ formsIgnored +')');
94
+ $htmlData = $('#gina-toolbar-data-html');
95
+ $htmlView = $('#gina-toolbar-view-html');
96
+ $htmlForms = $('#gina-toolbar-forms-html');
97
+ $htmlConfigurationEnvironment = $('#gina-toolbar-configuration-environment-html')
98
+ $codeFoldingToggle = $('#gina-toolbar-code-toggle');
99
+
100
+ // Append textarea for copy/paste then select it
101
+ $toolbar.prepend('<textarea class="gina-toolbar-copy"></textarea>');
102
+ $copyCache = $toolbar.find('.gina-toolbar-copy');
103
+
104
+ // Get toolbar settings
105
+ settings = plugins.findOne({_name: 'toolbar'});
106
+
107
+ if ( !settings ) {
108
+ // default settings
109
+ settings = {
110
+ _name : 'toolbar',
111
+ _version : self.version,
112
+ _description : 'Toolbar settings',
113
+ _licence : 'MIT',
114
+ _author : [
115
+ {name: 'Fabrice Delaneau', company: 'Freelancer'},
116
+ {name: 'Martin-Luther Etouman', company: 'Rhinostone'}
117
+ ],
118
+ position : 'top-right',
119
+ width : '30',
120
+ panelId : '#gina-toolbar-data',
121
+ isCollapsed : true,
122
+ isUnfolded : [],
123
+ debug : {
124
+ forms : {
125
+ active: false,
126
+ strategy: 'frontend' // by default
127
+ }
128
+ }
129
+ };
130
+ // saving default settings
131
+ plugins.insert(settings);
132
+ settings = plugins.findOne({_name: 'toolbar'});
133
+
134
+ }
135
+
136
+ // in case of local storage schema update;
137
+ if (settings._version != self.version) {
138
+ checkSchemaUpdate();
139
+ }
140
+
141
+ position = settings.position;
142
+ width = settings.width;
143
+ panelId = settings.panelId;
144
+ isCollapsed = settings.isCollapsed;
145
+
146
+ $toolbar.removeClass('gina-toolbar-hidden');
147
+ handle() // Bind behaviors
148
+ };
149
+
150
+
151
+ var checkSchemaUpdate = function () {
152
+ // Run every update from your current version up to the head
153
+
154
+ if (settings._version < '1.0.1') {
155
+ if (!settings.isUnfolded ) {
156
+ settings.isUnfolded = [];
157
+ }
158
+ if (settings.codeFolding != undefined) {
159
+ delete settings.codeFolding;
160
+ }
161
+ }
162
+
163
+ if ( typeof(settings.isUnfolded) != 'undefined' && !Array.isArray(settings.isUnfolded) ) {
164
+ settings.isUnfolded = [];
165
+ }
166
+
167
+ // update version number
168
+ settings._version = self.version;
169
+
170
+ // save all changes
171
+ settings.save(true);
172
+ }
173
+
174
+ /**
175
+ * loadData
176
+ *
177
+ * @param {object} [section]
178
+ * @param {object} [data]
179
+ * @param {object} [ginaData]
180
+ *
181
+ * */
182
+ var loadData = function (section, data, ginaData) {
183
+
184
+ var $currentForms = null;
185
+ try {
186
+ var txt = ($json) ? $json.text() : '';
187
+ if (txt == '' || txt == 'null' ) {
188
+ $json.text('Empty')
189
+ } else {
190
+ jsonObject = JSON.parse( txt );
191
+ ginaJsonObject = JSON.parse($ginaJson.text());
192
+
193
+ $json.text('');
194
+
195
+ // backing up document data for restore action
196
+ if (!originalData) {
197
+
198
+ originalData = {
199
+ jsonObject : JSON.clone(jsonObject),
200
+ ginaJsonObject : JSON.clone( ginaJsonObject)
201
+ };
202
+ lastJsonObjectState = {}; // jsonObject.data
203
+
204
+ }
205
+ }
206
+
207
+ } catch (err) {
208
+
209
+ var sectionStr = ( section ) ? ' [ '+ section + ' ] ' : ' ';
210
+ var _err = 'Could not load'+ sectionStr +'json\n' + (err.stack||err.message||err);
211
+ if ($json) {
212
+ $json.text(_err);
213
+ } else {
214
+ throw _err;
215
+ }
216
+
217
+ }
218
+
219
+ if (jsonObject) {
220
+
221
+ if (data && !ginaData) {
222
+ if ( !jsonObject[section] )
223
+ jsonObject[section] = {};
224
+
225
+ jsonObject[section] = ginaJsonObject[section] = data;
226
+
227
+ } else if ( section == 'data-xhr' && !data && jsonObject['data-xhr'] ) {
228
+ // reset xhr
229
+ delete jsonObject['data-xhr'];
230
+ } else if (ginaData) {
231
+ jsonObject = data;
232
+ ginaJsonObject = ginaData;
233
+ }
234
+
235
+
236
+ // Make folding paths
237
+ makeFoldingPaths(jsonObject, '');
238
+
239
+ // Create DOM from JSON
240
+ // -> Configuration::environment
241
+ // filtering before
242
+ delete jsonObject.environment.routing;
243
+ delete ginaJsonObject.environment.routing;
244
+ delete jsonObject.environment.reverseRouting;
245
+ delete ginaJsonObject.environment.reverseRouting;
246
+ delete jsonObject.environment.forms;
247
+ delete ginaJsonObject.environment.forms;
248
+ $htmlConfigurationEnvironment.html(parseObject(jsonObject.environment, ginaJsonObject.environment));
249
+
250
+
251
+ var userObject = { data: jsonObject.data, view: jsonObject.view, forms: jsonObject.forms }
252
+ , ginaObject = { data: ginaJsonObject.data, view: ginaJsonObject.view, forms: ginaJsonObject.forms } ;
253
+
254
+
255
+ // xhr mode
256
+ self.initiatedXhrFoldingState = false;
257
+ // validator mode
258
+ self.isValidator = false;
259
+
260
+ var isXHR = null, isXHRViewData = false;
261
+
262
+ if ( /^(view-xhr)$/.test(section) ) {
263
+
264
+ isXHR = true;
265
+
266
+ userObject.view = jsonObject[section];
267
+ ginaObject.view = ginaJsonObject[section];
268
+
269
+ userObject.data = jsonObject['data-xhr'];
270
+ ginaObject.data = ginaJsonObject['data-xhr'];
271
+ }
272
+
273
+ if ( !section || /^(data)$/.test(section) ) {
274
+
275
+
276
+ // -> Data
277
+ $htmlData.html('<ul class="gina-toolbar-code">' + parseObject(userObject.data, ginaObject.data, null, isXHR) +'</ul>');
278
+
279
+ // -> View
280
+ // init view
281
+ var htmlProp = '<div id="gina-toolbar-view-html-properties" class="gina-toolbar-section">\n' +
282
+ ' <h2 class="gina-toolbar-section-title">properties</h2>\n' +
283
+ ' <ul class="gina-toolbar-properties"></ul>\n' +
284
+ '</div>';
285
+
286
+ $htmlView.html(htmlProp);
287
+
288
+ $htmlView.html( parseView(userObject.view, ginaObject.view, null, isXHR, $htmlView) );
289
+
290
+ // -> Forms
291
+ $currentForms = $forms;
292
+ $htmlForms.html('');
293
+ $htmlForms.html( parseForms(userObject.forms, ginaObject.forms, $htmlForms, 0, $currentForms, $currentForms.length, isXHR) );
294
+ // Form binding
295
+ $htmlForms.find('div.gina-toolbar-section > h2').off('click').on('click', function(event) {
296
+ event.preventDefault();
297
+
298
+ $(this)
299
+ .parent()
300
+ .find('ul').first()
301
+ .slideToggle();
302
+ });
303
+
304
+ //$htmlForms.html( parseView(jsonObject.forms, ginaJsonObject.forms, null, $htmlForms) );
305
+ } //else
306
+ if ( /^(data-xhr|view-xhr)$/.test(section) ) {
307
+
308
+ // reset case
309
+ if ( typeof(jsonObject[section]) == 'undefined' || !jsonObject[section] || jsonObject[section] == 'null' ) {
310
+ return false;
311
+ }
312
+
313
+ // -> XHR Data
314
+ isXHR = true;
315
+ isXHRViewData = (typeof (jsonObject[section].isXHRViewData) != 'undefined') ? true : isXHRViewData;
316
+
317
+
318
+ // update data section without erasing old data
319
+ if (!isXHRViewData && !/^(view-xhr)$/.test(section)) {
320
+
321
+ // also update original data to handle restore action
322
+ if ( typeof (jsonObject['el-xhr']) != 'undefined' ) {
323
+ lastJsonObjectState.data = JSON.clone(jsonObject[section]);
324
+ }
325
+ }
326
+
327
+ // -> isXHRViewData (from popin) : cleanup
328
+ if (isXHRViewData) {
329
+ delete jsonObject[section].isXHRViewData;
330
+ }
331
+
332
+ if ( /^(data-xhr)$/.test(section) ) {
333
+ $htmlData.html('<ul class="gina-toolbar-code">' + parseObject(jsonObject[section], ginaJsonObject[section], null, isXHR) +'</ul>');
334
+ } else if ( /^(view-xhr)$/.test(section) ) {
335
+ //$htmlView.html( parseView(userObject.view, ginaObject.view, null, isXHR, $htmlView) );
336
+ // -> View
337
+ // init view
338
+ var htmlProp = '<div id="gina-toolbar-view-html-properties" class="gina-toolbar-section">\n' +
339
+ ' <h2 class="gina-toolbar-section-title">properties</h2>\n' +
340
+ ' <ul class="gina-toolbar-properties"></ul>\n' +
341
+ '</div>';
342
+
343
+ $htmlView.html(htmlProp);
344
+ $htmlView.html( parseView(jsonObject[section], ginaJsonObject[section], null, isXHR, $htmlView) );
345
+ }
346
+
347
+ } //else
348
+ if ( /^(el-xhr)$/.test(section) ) {
349
+ // -> XHR Forms
350
+ isXHR = true;
351
+ $currentForms = $('#' + data).find('form:not(' + formsIgnored + ')');
352
+ $htmlForms.html('');
353
+ $htmlForms.html( parseForms(userObject.forms, ginaObject.forms, $htmlForms, 0, $currentForms, $currentForms.length, isXHR ) );
354
+ // Form binding
355
+ $htmlForms.find('div.gina-toolbar-section > h2').off('click').on('click', function(event) {
356
+ event.preventDefault();
357
+
358
+ $(this)
359
+ .parent()
360
+ .find('ul').first()
361
+ .slideToggle();
362
+ });
363
+ } //else
364
+ if ( /^(forms)$/.test(section) ) {
365
+ isXHR = true;
366
+ self.isValidator = true;
367
+
368
+ var $form = $('#gina-toolbar-form-' + data.id);
369
+ // for live changes (eg.: on `Validator::getFormById()` call)
370
+ if ( !$form.length ) {
371
+ // crearte toolbar entry for the new form
372
+ $currentForms = $forms;
373
+ $htmlForms.html('');
374
+ $htmlForms.html( parseForms(userObject.forms, ginaObject.forms, $htmlForms, 0, $currentForms, $currentForms.length, isXHR) );
375
+ // Form binding
376
+ $htmlForms.find('div.gina-toolbar-section > h2').off('click').on('click', function(event) {
377
+ event.preventDefault();
378
+
379
+ $(this)
380
+ .parent()
381
+ .find('ul').first()
382
+ .slideToggle();
383
+ });
384
+ }
385
+
386
+ // form data sent
387
+ if ( typeof(data.rules) != 'undefined' ) {
388
+ updateForm(data.id, 'rules', data.rules, isXHR)
389
+ }
390
+
391
+ // form errors
392
+ if ( typeof(data.errors) != 'undefined' && data.errors.count() > 0 ) {
393
+ updateForm(data.id, 'errors', data.errors, isXHR)
394
+ }
395
+
396
+ // form data sent
397
+ if ( typeof(data.sent) != 'undefined' ) {
398
+ updateForm(data.id, 'sent', data.sent, isXHR)
399
+ }
400
+ }
401
+
402
+
403
+ // Manage folding state
404
+ settings.currentFile = jsonObject.file;
405
+ if (!settings.currentFile) {
406
+ // Init currentFile if none exists
407
+ settings.currentFile = jsonObject.file;
408
+ }
409
+
410
+ if (jsonObject.file == settings.currentFile) {
411
+ // If current page is the same as the previous page, unfold code as neede
412
+ $(document).ready(function () {
413
+
414
+ if (self.isValidator ) {
415
+ self.isXHR = true;
416
+ if (settings.isUnfolded.length > 0 && !self.initiatedXhrFoldingState) {
417
+ self.initiatedXhrFoldingState = true;
418
+ setTimeout(function () {
419
+ if (settings.isUnfolded.length > 0)
420
+ initFoldingState(settings.isUnfolded, settings.isUnfolded.length, 0);
421
+ }, 200)
422
+ }
423
+ } else {
424
+ if (!isXHR) {
425
+ self.isXHR = false;
426
+ setTimeout(function () {
427
+ if (settings.isUnfolded.length > 0)
428
+ initFoldingState(settings.isUnfolded, settings.isUnfolded.length, 0);
429
+ }, 200)
430
+ } else {
431
+ self.isXHR = true;
432
+ if (settings.isUnfolded.length > 0 && !self.initiatedXhrFoldingState) {
433
+ self.initiatedXhrFoldingState = true;
434
+ initFoldingState(settings.isUnfolded, settings.isUnfolded.length, 0);
435
+ }
436
+ }
437
+ }
438
+ })
439
+ }
440
+ }
441
+
442
+ if ( !section || section == 'el-xhr' && !self.hasParsedUrls) {
443
+ self.hasParsedUrls = (section && section == 'el-xhr' ) ? true : false;
444
+ parseUrls(section);
445
+ }
446
+ }
447
+
448
+
449
+ var initFoldingState = function (unfolded, len, i) {
450
+
451
+ if (i == len) return false;
452
+
453
+ var key = unfolded[i];
454
+ var $kel = null;
455
+
456
+ if ( self.isXHR && /^xhr-/.test(key) ) {
457
+ key = key.replace(/^xhr-/, '');
458
+ $kel = $('.gina-toolbar-xhr-folding-state-'+ key);
459
+ } else {
460
+ $kel = $('.gina-toolbar-folding-state-' + key);
461
+ }
462
+
463
+ toggleCodeFolding( $kel, function onCodeToggled() {
464
+ i = i + 1;
465
+ initFoldingState(unfolded, len, i)
466
+ });
467
+ }
468
+
469
+ var handle = function () {
470
+
471
+
472
+ // Add folding behavior
473
+ $htmlData
474
+ .add($htmlView).off('click', 'a').on('click', 'a', function(event) {
475
+ event.preventDefault();
476
+
477
+ toggleCodeFolding( $(this), null, true )
478
+ })
479
+ .add($htmlForms).off('click', 'a').on('click', 'a', function(event) {
480
+ event.preventDefault();
481
+
482
+ toggleCodeFolding( $(this), null, true )
483
+ });
484
+
485
+ // Expand/collapse all code
486
+ $codeFoldingToggle.off('click').on('click', function(event) {
487
+ event.preventDefault();
488
+
489
+ toggleCodeFolding('all', null, true)
490
+ });
491
+
492
+ // Add value to the clipboard
493
+ $htmlData.add($htmlView, $htmlForms).off('click', '.gina-toolbar-value').on('click', '.gina-toolbar-value', function(event) {
494
+ event.preventDefault();
495
+ try {
496
+ copyValue = $(this).text();
497
+ $copyCache.text(copyValue);
498
+ $copyCache.select();
499
+ document.execCommand('copy', false, null);
500
+ $copyCache.blur();
501
+ } catch(err) {
502
+ alert('Please press Ctrl/Cmd+C to copy the value');
503
+ // throw err;
504
+ }
505
+
506
+ });
507
+
508
+ // display RAW
509
+ $jsonRAW.off('click').on('click', function(event){
510
+ if (jsonObject) {
511
+ var jsonOut = window.open("", "JSON RAW", "width=400,height=100");
512
+ //jsonOut.document.write( '<pre>' + JSON.stringify(jsonObject, null, 2) + '</pre>' );
513
+ jsonOut.document.write( JSON.stringify(jsonObject.data) );
514
+ }
515
+ });
516
+
517
+ // Tabs
518
+ $tabs.off('click').on('click', function(event) {
519
+ event.preventDefault();
520
+
521
+ // Hide all panels
522
+ $tabs.removeClass('gina-toolbar-active');
523
+ $panels.removeClass('gina-toolbar-active');
524
+
525
+ // Show selected tab
526
+ $(this).addClass('gina-toolbar-active');
527
+
528
+ // Show selected panel
529
+ panelId = $(this).attr('href');
530
+ $currentPanel = $(panelId).addClass('gina-toolbar-active');
531
+
532
+ // Save current active tab to coockie
533
+ settings.panelId = panelId;
534
+ settings.save()
535
+ });
536
+
537
+ // Show/hide Toolbar
538
+ $logo.off('click').on('click', function(event) {
539
+ event.preventDefault();
540
+
541
+ $toolbar.toggleClass('gina-toolbar-collapsed');
542
+
543
+ // Save current visibility state to coockie
544
+ isCollapsed = $toolbar.hasClass('gina-toolbar-collapsed')
545
+ settings.isCollapsed = isCollapsed;
546
+ settings.save()
547
+ });
548
+
549
+ // Toolbar position
550
+ $toolbarPos.off('change').on('change', function(event) {
551
+ event.preventDefault();
552
+
553
+ // Get selected option value
554
+ var vposition = $verticalPos.val();
555
+ var hposition = $horizontalPos.val();
556
+ position = vposition + '-' + hposition
557
+ changeToolbarPosition(position);
558
+
559
+ // Save new position to coockie
560
+ settings.position = position;
561
+ settings.save()
562
+ });
563
+
564
+ // Toolbar width
565
+ $toolbarWidth.off('change').on('change', function(event) {
566
+ event.preventDefault();
567
+
568
+ // Get selected option value
569
+ width = $toolbarWidth.val();
570
+ changeToolbarWidth(width);
571
+
572
+ // Save new width to coockie
573
+ settings.width = width;
574
+ settings.save()
575
+ });
576
+
577
+ // Toolbar height
578
+ $(window).off('resize').on('resize', function() {
579
+ changeToolbarHeight();
580
+ });
581
+
582
+ // Show/hide toolbar using gg shorcut
583
+ $('body').off('keypress').on('keypress', function onKeypressed(event){
584
+
585
+ if (!/INPUT|TEXTAREA/.test(event.target.tagName )) {
586
+ if (event.keyCode) {
587
+ // IE
588
+ keynum = event.keyCode;
589
+ } else if (event.which) {
590
+ // Netscape/Firefox/Opera
591
+ keynum = event.which;
592
+ } else {
593
+ // Chrome/Safari
594
+ keynum = event.charCode;
595
+ }
596
+ var now = new Date();
597
+ if (
598
+ typeof lastPressedKey.keynum != "undefined"
599
+ && lastPressedKey.keynum == keynum
600
+ && typeof lastPressedKey.pressTime != "undefined"
601
+ && now.getTime() - lastPressedKey.pressTime < 500
602
+ ) {
603
+ switch (keynum) {
604
+ case 103: //This is the "g" key
605
+ $toolbar.toggle();
606
+ // variousTools.setCookie("gina-toolbar[hub]", params.display.hub, 365);
607
+ break;
608
+ }
609
+ }
610
+ lastPressedKey.pressTime = now.getTime();
611
+ lastPressedKey.keynum = keynum;
612
+ }
613
+
614
+ });
615
+
616
+
617
+ // Updates Toolbar with current values
618
+
619
+ // Select the current tab
620
+ $tabs.filter('[href="' + panelId +'"]').trigger('click');
621
+
622
+ // Open toolbar if needed
623
+ if (!isCollapsed) {
624
+ $('#gina-toolbar-toggle').trigger('click');
625
+ }
626
+
627
+ // Change Toolbar Position and init selects
628
+ changeToolbarPosition(position);
629
+
630
+ var positions = position.split('-');
631
+ $verticalPos.val(positions[0]);
632
+ $horizontalPos.val(positions[1]);
633
+
634
+ // Change Toolbar Width and init select
635
+ changeToolbarWidth(width);
636
+
637
+ $toolbarWidth.val(width);
638
+
639
+ // Change Toolbar max-Height;
640
+ changeToolbarHeight();
641
+
642
+ // Parse JSON
643
+ var txt = ($json) ? $json.text() : '';
644
+ // dev only - allows HTML 5 mock
645
+ if ( /^\{\{ (.*) \}\}/.test(txt) ) {
646
+ // loading mock
647
+ //var url = document.location.protocol + '//' + document.location.pathname.replace('index.html', '');
648
+ //url + 'mock.json';
649
+ loadJSON(txt, loadData); //parse
650
+
651
+ } else {
652
+ loadData()
653
+ }
654
+ }
655
+
656
+
657
+ var changeToolbarPosition = function (position) {
658
+ $toolbar
659
+ .removeClass('gina-toolbar-top-left gina-toolbar-top-right gina-toolbar-bottom-left gina-toolbar-bottom-right')
660
+ .addClass('gina-toolbar-'+ position);
661
+ }
662
+
663
+ var changeToolbarWidth = function (width) {
664
+ $toolbar
665
+ .removeClass('gina-toolbar-auto gina-toolbar-100 gina-toolbar-80 gina-toolbar-60 gina-toolbar-50 gina-toolbar-40 gina-toolbar-30')
666
+ .addClass('gina-toolbar-'+ width);
667
+ }
668
+
669
+ var changeToolbarHeight = function () {
670
+ // Use window height - 32px for the header
671
+ toolbarHeight = window.innerHeight - 32;
672
+ $toolbar
673
+ .find('.gina-toolbar-main')
674
+ .css('max-height', toolbarHeight +'px');
675
+
676
+ checkContentHeight()
677
+ }
678
+
679
+ var checkContentHeight = function () {
680
+ // check toolbar content against window height
681
+ var $currentMain = $currentPanel.find('.gina-toolbar-main');
682
+ var $currentContent = $currentMain.find('.gina-toolbar-content');
683
+ contentHeight = $currentMain.height();
684
+ if (contentHeight == toolbarHeight) {
685
+ $currentContent.addClass('gina-toolbar-content-end')
686
+ } else {
687
+ $currentContent.removeClass('gina-toolbar-content-end')
688
+ }
689
+ }
690
+
691
+ var toggleCodeFolding = function ($el, cb, toggledByClick) {
692
+
693
+ if ( typeof(toggledByClick) == 'undefined' ) {
694
+ var toggledByClick = false
695
+ }
696
+
697
+ if ($el != undefined && $el.length && $el != 'all') {
698
+
699
+ // Save element folding state
700
+ self.foldingClass = $el.attr('class');
701
+ var hasXhrFlag = false;
702
+
703
+ if ( /(gina-toolbar-folding-state-[a-z 0-9_-]+|gina-toolbar-xhr-folding-state-[a-z 0-9_-]+)/i.test(self.foldingClass) ) {
704
+
705
+ if ( /gina-toolbar-folding-state-[a-z0-9_-]+/i.test(self.foldingClass) ) {
706
+ self.foldingClass = self.foldingClass.match(/gina-toolbar-folding-state-[a-z0-9_-]+/i)[0].replace(/gina-toolbar-folding-state-/, '');
707
+ } else {
708
+ hasXhrFlag = true;
709
+ if ( typeof(self.foldingClass) != 'undefined' )
710
+ self.foldingClass = self.foldingClass.match(/gina-toolbar-xhr-folding-state-[a-z0-9_-]+/i)[0].replace(/gina-toolbar-xhr-folding-state-/, 'xhr-');
711
+ }
712
+
713
+ if ( settings.isUnfolded.indexOf(self.foldingClass) < 0 ) {
714
+
715
+ settings.isUnfolded.push(self.foldingClass);
716
+ settings.save();
717
+
718
+ if (!$el.hasClass('gina-toolbar-unfolded')) {
719
+ $el.addClass('gina-toolbar-unfolded');
720
+ $el.next('ul').slideToggle('fast');
721
+ }
722
+
723
+ } else {
724
+
725
+ if ( settings.isUnfolded.indexOf(self.foldingClass) > -1 && $el.hasClass('gina-toolbar-unfolded') ) {
726
+
727
+ // remove reference & sub-references
728
+ var re = new RegExp('^('+ self.foldingClass +')');
729
+ for (var i = 0, len = settings.isUnfolded.length; i < len; ++i) {
730
+ if ( re.test(settings.isUnfolded[i]) ) {
731
+ if (!self.isValidator && toggledByClick || self.isValidator && hasXhrFlag || toggledByClick ) {
732
+ settings.isUnfolded.splice(i, 1);
733
+ --i
734
+ }
735
+ }
736
+ }
737
+
738
+ settings.save(true);
739
+
740
+ if ( settings.isUnfolded.indexOf(self.foldingClass) < 0 ) {
741
+ $el.removeClass('gina-toolbar-unfolded');
742
+ $el.next('ul').slideToggle('fast');
743
+ }
744
+
745
+
746
+ } else {
747
+ $el.addClass('gina-toolbar-unfolded');
748
+ $el.next('ul').slideToggle('fast');
749
+ }
750
+ }
751
+ }
752
+
753
+ }
754
+
755
+ if (typeof (cb) != 'undefined' && cb != null )
756
+ cb()
757
+ }
758
+
759
+ var orderKeys = function(obj) {
760
+
761
+ var newObj = {}
762
+ , k = null
763
+ , keys = []
764
+ , i = 0
765
+ , len = null
766
+ ;
767
+
768
+ for (k in obj) {
769
+ if ( obj.hasOwnProperty(k) ){
770
+ keys[i] = k;
771
+ ++i
772
+ }
773
+ }
774
+
775
+ len = keys.length;
776
+ keys.sort();
777
+
778
+ for (i = 0; i < len; ++i) {
779
+ k = keys[i];
780
+ newObj[k] = obj[k];
781
+ }
782
+
783
+ return newObj
784
+ }
785
+
786
+ var normalizeFoldingStateName = function(stateSection, stateName) {
787
+
788
+ var foldingStateName = '', section = null, name = null;
789
+
790
+ if ( typeof(stateSection) != 'undefined' && stateSection != '' ) {
791
+
792
+ section = stateSection;
793
+ if ( typeof(stateSection) == 'string' ) {
794
+ section = stateSection
795
+ .replace(/(\]\[|\[)/g, '-')
796
+ .replace(/\]/, '')
797
+ .replace(/[^A-Za-z0-9_-]/g, '_')
798
+ }
799
+
800
+ foldingStateName += section + '-'
801
+ }
802
+
803
+ if ( typeof(stateName) != 'undefined' && stateName != '' ) {
804
+
805
+ name = stateName;
806
+ if ( typeof(stateName) == 'string' ) {
807
+ name = stateName
808
+ .replace(/(\]\[|\[)/g, '-')
809
+ .replace(/\]/, '')
810
+ }
811
+
812
+ foldingStateName += name
813
+ } else {
814
+ foldingStateName = foldingStateName.substr(0, foldingStateName.length-1)
815
+ }
816
+
817
+ return foldingStateName.trim()
818
+ }
819
+
820
+ var parseObject = function(obj, ginaObj, elId, elIsXHR, elSection) {
821
+
822
+ var html = '';
823
+ var id = ( typeof(elId) != 'undefined' && elId != null ) ? elId.replace(/[^A-Za-z0-9_-]/g, '_') : '';
824
+ var section = ( typeof(elSection) != 'undefined' && elSection != null ) ? elSection : '';
825
+ var isXHR = ( typeof(elIsXHR) != 'undefined' && elIsXHR != null ) ? '-xhr' : '';
826
+ var count = '';
827
+ var objType = '';
828
+ var isEmptyClass = null;
829
+
830
+ obj = orderKeys(obj);
831
+ ginaObj = orderKeys(ginaObj);
832
+
833
+ for (var i in obj) {
834
+ //console.log('i', i);
835
+ //if ( /^(_uuid)$/.test(i) ) continue;
836
+
837
+ if ( typeof(obj[i]) == 'object' && !Array.isArray(obj[i]) && obj[i] !== null ) { // parse
838
+ //id += i + '-';
839
+ id += '-' + i.replace(/[^A-Za-z0-9_-]/g, '_');
840
+ isEmptyClass = (obj[i].count() > 0 || typeof(ginaObj[i]) != 'undefined' && ginaObj[i].count() > 0) ? '' : ' is-empty';
841
+
842
+ html += '<li class="gina-toolbar-object">';
843
+ html += '<a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( section, i.replace(/[^A-Za-z0-9_-]/g, '_') ) + isEmptyClass +'">'+ i +' <span>{ }</span></a>';
844
+ html += '<ul class="gina-toolbar-object">' + parseObject(obj[i], ginaObj[i], id, elIsXHR, elSection) +'</ul>';
845
+ html += '</li>';
846
+ // clear one level
847
+ //id = id.substr(0, id.length - i.length - 1);
848
+ id = id.substr(0, id.length - i.length);
849
+ } else if ( Array.isArray(obj[i]) ) {
850
+ //id += i + '-';
851
+ id += '-' + i.replace(/[^A-Za-z0-9_-]/g, '_');
852
+ isEmptyClass = (obj[i].length > 0 || typeof(ginaObj[i]) != 'undefined' && ginaObj[i].length > 0) ? '' : ' is-empty';
853
+
854
+ html += '<li class="gina-toolbar-collection">';
855
+ html += '<a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( section, i.replace(/[^A-Za-z0-9_-]/g, '_') ) + isEmptyClass +'">'+ i +' <span>['+ obj[i].length +']</span></a>';
856
+ html += '<ul class="gina-toolbar-collection">' + parseCollection(obj[i], ginaObj[i], id, elIsXHR, elSection) +'</ul>';
857
+ html += '</li>';
858
+ // clear one level
859
+ //id = id.substr(0, id.length - i.length - 1);
860
+ id = id.substr(0, id.length - i.length);
861
+ } else {
862
+ objType = (ginaObj[i] === null) ? 'null' : typeof(ginaObj[i]);
863
+ if ( objType == 'undefined' ) { // new key declaration added by user
864
+ html += '<li class="gina-toolbar-key-value">';
865
+ html += '<span class="gina-toolbar-key gina-toolbar-key-added">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span>';
866
+ html += '</li>';
867
+ } else {
868
+
869
+ //if (/^_comment/.test(i) ) continue;
870
+
871
+ if (obj[i] !== ginaObj[i] ) {
872
+ html += '<li class="gina-toolbar-key-value gina-toolbar-is-overridden">';
873
+ html += '<span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value">'+ ginaObj[i] +'</span>';
874
+ html += '</li>';
875
+
876
+ html += '<li class="gina-toolbar-key-value">';
877
+ html += '<span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span>';
878
+ html += '</li>';
879
+ } else {
880
+ html += '<li class="gina-toolbar-key-value">';
881
+ html += '<span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span>';
882
+ html += '</li>';
883
+ }
884
+ }
885
+ }
886
+ }
887
+ return html
888
+ }
889
+
890
+ var parseCollection = function (arr, ginaArr, elId, elIsXHR, elSection) {
891
+ var html = '';
892
+ var id = ( typeof(elId) != 'undefined' && elId != null ) ? elId : '';
893
+ var section = ( typeof(elSection) != 'undefined' && elSection != null ) ? elSection : '';
894
+ var isXHR = ( typeof(elIsXHR) != 'undefined' && elIsXHR != null ) ? '-xhr' : '';
895
+
896
+ // patch
897
+ if (!ginaArr) {
898
+ ginaArr = [];
899
+ }
900
+ for (var i = 0, len = arr.length; i<len; ++i) {
901
+ if ( typeof(arr[i]) == 'object' && !Array.isArray(arr[i]) ) {
902
+ //id += i + '-';
903
+ // patch
904
+ if (!ginaArr[i]) {
905
+ ginaArr[i] = arr[i]
906
+ }
907
+
908
+ id += '-'+ i;
909
+ if (section == '') {
910
+ section = id;
911
+ }
912
+ html += '<li class="gina-toolbar-object">';
913
+ html += '<a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( section, i ) +'">'+ i +' <span>{ }</span></a>';
914
+ html += '<ul class="gina-toolbar-object">' + parseObject(arr[i], ginaArr[i], id, elIsXHR, elSection) +'</ul>';
915
+ html += '</li>';
916
+ // clear one level
917
+ id = id.substr(0, id.length - i.toString().length - 1);
918
+
919
+ } else if ( Array.isArray(arr[i]) ) {
920
+ //id += i + '-';
921
+ id += '-'+ i;
922
+ if (section == '') {
923
+ section = id;
924
+ }
925
+ html += '<li class="gina-toolbar-collection">';
926
+ html += '<a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( section, i ) +'">'+ i +'<span>[ ]</span></a>';
927
+ html += '<ul class="gina-toolbar-collection">' + parseCollection(arr[i], ginaArr[i], id, elIsXHR, elSection) +'</ul>';
928
+ html += '</li>';
929
+ // clear one level
930
+ //id = id.substr(0, id.length - i.toString().length - 1);
931
+ id = id.substr(0, id.length - i.toString().length);
932
+ } else {
933
+ html += '<li class="gina-toolbar-key-value"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value">'+ arr[i] +'</span></li>';
934
+ }
935
+ }
936
+ return html
937
+ }
938
+
939
+ var parseView = function (obj, ginaObj, elId, elIsXHR, $html, $root) {
940
+
941
+ var id = (elId != null) ? elId.replace(/[^A-Za-z0-9_-]/g, '_') : '';
942
+ var section = null;
943
+ var isXHR = ( typeof(elIsXHR) != 'undefined' && elIsXHR != null ) ? '-xhr' : '';
944
+ var count = '';
945
+ var objType = '';
946
+ var hasParent = false;
947
+ var $parent = null;
948
+ var parentId = null;
949
+
950
+ obj = orderKeys(obj);
951
+ ginaObj = orderKeys(ginaObj);
952
+
953
+ if (!$root)
954
+ $root = $html;
955
+
956
+ for (var i in obj) {
957
+ section = i;
958
+ if ( typeof(obj[i]) == 'object' && !Array.isArray(obj[i]) && obj[i] !== null ) { // parse
959
+
960
+ $parent = $('#gina-toolbar-view-' + id.substr(0, id.length - 1));
961
+ hasParent = ( $parent.length ) ? true : false;
962
+
963
+ if (!hasParent ) {
964
+ id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
965
+
966
+ if (i == 'params') { // force to top
967
+ var htmlParams = '<div id="gina-toolbar-view-'+ id.substr(0, id.length - 1) +'" class="gina-toolbar-section">' +
968
+ '<h2 class="gina-toolbar-section-title">'+ id.substr(0, id.length - 1) +'</h2>' +
969
+ '<ul class="'+ id.substr(0, id.length - 1) +'"></ul>' +
970
+ '</div>';
971
+
972
+ $('#gina-toolbar-view-html-properties')
973
+ .before(htmlParams);
974
+ } else {
975
+
976
+ if ( !/^html/.test(id) ) {
977
+
978
+ var htmlOther = '<div id="gina-toolbar-view-'+ id.substr(0, id.length - 1) +'" class="gina-toolbar-section">' +
979
+ '<h2 class="gina-toolbar-section-title">'+ id.substr(0, id.length - 1) +'</h2>' +
980
+ '<ul class="'+ id.substr(0, id.length - 1) +'"></ul>' +
981
+ '</div>';
982
+
983
+ $html
984
+ .append(htmlOther);
985
+ }/** else { // add to properties section
986
+ $root
987
+ .find('.gina-toolbar-properties')
988
+ .append('ul.' + id.substr(0, id.length - 1))
989
+ }*/
990
+
991
+ }
992
+
993
+ parseView(obj[i], ginaObj[i], id, elIsXHR, $html.find('ul.'+ id.substr(0, id.length - 1)), $root );
994
+
995
+ } else {
996
+
997
+ parentId = id + i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
998
+
999
+ $parent
1000
+ .find('ul.'+ id.substr(0, id.length - 1))
1001
+ .append('<li class="gina-toolbar-object"><a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( i.replace(/[^A-Za-z0-9_-]/g, '_'), parentId.substr(0, parentId.length - 1) ) +'">'+ i +' <span>{ }</span></a><ul class="gina-toolbar-object '+ parentId.substr(0, parentId.length - 1) +'"></ul></li>');
1002
+
1003
+ parseView(obj[i], ginaObj[i], parentId, elIsXHR, $parent.find('ul.'+ id.substr(0, id.length - 1)), $root );
1004
+
1005
+ id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1006
+ }
1007
+
1008
+
1009
+ // clear one level
1010
+ id = id.substr(0, id.length - i.length - 1);
1011
+
1012
+
1013
+ } else if ( Array.isArray(obj[i]) ) { // parse collection
1014
+
1015
+
1016
+
1017
+ $parent = $('#gina-toolbar-view-' + id.substr(0, id.length - 1));
1018
+
1019
+ hasParent = ( $parent.length ) ? true : false;
1020
+
1021
+ if ( !hasParent || /^html/.test(id) ) {
1022
+
1023
+ $parent = $('.' + id);
1024
+ parentId = id + i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1025
+
1026
+ $parent
1027
+ //.find('ul.'+ id.substr(0, id.length - 1))
1028
+ .append('<li class="gina-toolbar-collection"><a href="#" class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( i.replace(/[^A-Za-z0-9_-]/g, '_'), parentId.substr(0, parentId.length - 1) ) +'">'+ i +' <span>['+ obj[i].length +']</span></a><ul> '+ parseCollection(obj[i], ginaObj[i], parentId, $parent.find('li ul.'+ id.substr(0, id.length - 1)), section )+'</ul></li>');
1029
+
1030
+
1031
+ //parentId = parentId.substr(0, parentId.length - 1)+ '-';
1032
+ //parentId = id.substr(0, id.length - i.length - 1);
1033
+ //parseView(obj[i], ginaObj[i], parentId, elIsXHR, $parent.find('ul.'+ parentId.substr(0, parentId.length - 1)), $root );
1034
+
1035
+ //id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1036
+ //$parent = $('#gina-toolbar-view-' + id.substr(0, id.length - 1));
1037
+ id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1038
+ } else {
1039
+
1040
+
1041
+ parentId = id + i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1042
+
1043
+ $parent
1044
+ .find('li.'+ id.substr(0, id.length - 1) +' ul')
1045
+ .append('<li class="gina-toolbar-collection"><a class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( i.replace(/[^A-Za-z0-9_-]/g, '_'), parentId.substr(0, parentId.length - 1) ) +'">'+ i +' <span>['+ obj[i].length +']</span></a><ul>'+ parseCollection(obj[i], ginaObj[i], parentId, $parent.find('li ul.'+ id.substr(0, id.length - 1)), section ) +'</ul></li>');
1046
+
1047
+ id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1048
+
1049
+ }
1050
+
1051
+
1052
+ // if ( !hasParent || /^html/.test(id) ) {
1053
+ // id = id + i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1054
+ // $root
1055
+ // .find('.gina-toolbar-properties')
1056
+ // .append('<li class="gina-toolbar-collection"><a class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( i.replace(/[^A-Za-z0-9_-]/g, '_'), id.substr(0, id.length - 1) ) +'">'+ i +' <span>['+ obj[i].length +']</span></a><ul>'+ parseCollection(obj[i], ginaObj[i], parentId, $root.find('.gina-toolbar-properties'), section) +'</ul></li>');
1057
+
1058
+
1059
+ // } else {
1060
+
1061
+
1062
+ // parentId = id + i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1063
+
1064
+ // $parent
1065
+ // .find('li.'+ id.substr(0, id.length - 1) +' ul')
1066
+ // .append('<li class="gina-toolbar-collection"><a class="gina-toolbar-key gina-toolbar'+ isXHR +'-folding-state-'+ normalizeFoldingStateName( i.replace(/[^A-Za-z0-9_-]/g, '_'), parentId.substr(0, parentId.length - 1) ) +'">'+ i +' <span>['+ obj[i].length +']</span></a><ul>'+ parseCollection(obj[i], ginaObj[i], parentId, $parent.find('li ul.'+ id.substr(0, id.length - 1)), section ) +'</ul></li>');
1067
+
1068
+ // id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1069
+ // }
1070
+
1071
+ // clear one level
1072
+ id = id.substr(0, id.length - i.length - 1);
1073
+ } else {
1074
+
1075
+
1076
+
1077
+ objType = (ginaObj[i] === null) ? 'null' : typeof(ginaObj[i]);
1078
+ if ( objType == 'undefined' ) { // new key declaration added by user
1079
+ if (/\-$/.test(id)) {
1080
+ id = id.substr(0, id.length - 1);
1081
+ }
1082
+
1083
+ if (!id) continue;
1084
+
1085
+ $html
1086
+ .find('ul.' + id)
1087
+ .append('<li class="gina-toolbar-key-value"><span class="gina-toolbar-key gina-toolbar-key-added">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i]+'</span></li>');
1088
+
1089
+ } else {
1090
+
1091
+ //if (/^_comment/.test(i) ) continue;
1092
+
1093
+ if (obj[i] !== ginaObj[i] ) {
1094
+ if (!id) {
1095
+ id += i.replace(/[^A-Za-z0-9_-]/g, '_') + '-';
1096
+ }
1097
+
1098
+ try {
1099
+ $html
1100
+ .find('ul.' + id)
1101
+ .append('<li class="gina-toolbar-key-value gina-toolbar-is-overridden"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value">'+ ginaObj[i] +'</span></li>');
1102
+
1103
+ $html
1104
+ .find('ul.' + id)
1105
+ .append('<li class="gina-toolbar-key-value"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span></li>')
1106
+
1107
+ } catch (err) {
1108
+ throw new Error('GinaToolbarError: `ul.'+ id +'` not found');
1109
+ }
1110
+
1111
+ } else {
1112
+
1113
+ if ( !id || /^html\-properties/.test(id) ) { // properties case
1114
+ // if (id) {
1115
+ // $html
1116
+ // .find('ul.' + id)
1117
+ // .append('<li class="gina-toolbar-key-value"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span></li>')
1118
+ // } else {
1119
+ $root
1120
+ .find('.gina-toolbar-properties')
1121
+ .append('<li class="gina-toolbar-key-value"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span></li>')
1122
+ //}
1123
+
1124
+ } else {
1125
+
1126
+ $root
1127
+ .find('ul.' + id.substr(0, id.length - 1))
1128
+ .append('<li class="gina-toolbar-key-value"><span class="gina-toolbar-key">'+ i +':</span> <span class="gina-toolbar-value gina-toolbar-value-type-is-'+ objType +'">'+ obj[i] +'</span></li>')
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+
1135
+ return $root.html()
1136
+ }
1137
+
1138
+ var parseSection = function (rules, id, elIsXHR, section) {
1139
+
1140
+ return parseObject(rules, rules, id, elIsXHR, section)
1141
+ }
1142
+
1143
+ var parseUrls = function(section) {
1144
+
1145
+ var $el = null;
1146
+ var $currentPopin = (gina.hasPopinHandler) ? gina.popin.getActivePopin() : null;
1147
+ var isPopinContext = ( gina.hasPopinHandler ) ? true : false;
1148
+ if ( isPopinContext ) {
1149
+ $el = $('#' + $currentPopin.id );
1150
+ } else {
1151
+ $el = $('body');
1152
+ }
1153
+
1154
+ // look for `404: `
1155
+ var found = {}
1156
+ , foundStr = null
1157
+ , formMethod = null
1158
+ , f = 0
1159
+ , fLen = 0
1160
+ ;
1161
+ var matched = $el.html().match(/404\:\[(.+)\](.+)@(.+)\"/gm);
1162
+ if (matched) {
1163
+ f = 0; fLen = matched.length;
1164
+ for (; f < fLen; ++f) {
1165
+ foundStr = matched[f].replace(/\"(.*)|\"/g, '');
1166
+ formMethod = foundStr.match(/\[(.*)\]/g, '')[0].replace(/\[|\]/g,'');
1167
+
1168
+ routing.getRouteByUrl(foundStr, formMethod)
1169
+ }
1170
+ }
1171
+
1172
+ printLogs();
1173
+
1174
+ //console.debug('popinIsActive: '+ isPopinContext +'isXHR: ', self.isXHR, ' -> ' + section, routing.notFound);
1175
+ }
1176
+
1177
+ var printLogs = function() {
1178
+ fLen = routing.notFound.count();
1179
+ if ( fLen > 0 ) {
1180
+ for (f in routing.notFound) {
1181
+ console.warn( '(x'+ routing.notFound[f].count +') ' + f + ' => ' + routing.notFound[f].message );
1182
+ }
1183
+ }
1184
+ }
1185
+
1186
+ var parseForms = function (obj, ginaObj, $html, i, $forms, len, elIsXHR) {
1187
+
1188
+ if (!len) return false;
1189
+
1190
+ var attributes = $forms[i].attributes;
1191
+ var formMethod = null;
1192
+ var attrClass = 'gina-toolbar-form-attributes';
1193
+ var id = $forms[i].getAttribute('id') || $forms[i].id;
1194
+ var section = attrClass; // by default
1195
+ var isXHR = ( typeof(elIsXHR) != 'undefined' && elIsXHR != null ) ? '-xhr' : '';
1196
+ // form fields set
1197
+ // var fields = validator
1198
+ // .getFormById(id)
1199
+ // .fieldsSet;
1200
+
1201
+ var $form = $(
1202
+ '<div id="gina-toolbar-form-'+ id +'" class="gina-toolbar-section">' +
1203
+ '<h2 class="gina-toolbar-section-title">'+ id +'</h2>' +
1204
+ '<ul class="gina-toolbar-section-content gina-toolbar-code" style="display: none;">' +
1205
+ '<li class="'+ attrClass +'">' +
1206
+ '<h3 class="gina-toolbar-sub-section-title">'+ attrClass.replace(/gina-toolbar-form-/, '') +'</h3>' +
1207
+ '<ul class="gina-toolbar-code"></ul>' +
1208
+ '</li>' +
1209
+ '</ul>' +
1210
+ '</div>');
1211
+
1212
+ var key = null
1213
+ , val = null
1214
+ , content = null
1215
+ , hasEvents = false
1216
+ , routeObj = null
1217
+ ;
1218
+
1219
+ // testing for action attr to add action route
1220
+
1221
+
1222
+ // adding form attributes
1223
+ for ( var a = 0, aLen = attributes.length; a < aLen; ++a ) {
1224
+
1225
+ key = attributes[a].name;
1226
+ val = attributes[a].nodeValue;
1227
+
1228
+ // filters
1229
+ if ( /^method$/.test(key) )
1230
+ val = val.toUpperCase();
1231
+
1232
+ if ( /^class$/.test(key) && /\s+/.test(val) )
1233
+ val = '<ul><li>'+ val.replace(/\s+/g, '</li><li>') +'</li></ul>';
1234
+
1235
+ if ( /^action$/.test(key) ) {
1236
+
1237
+ formMethod = ( typeof(attributes['method']) != 'undefined' ) ? attributes['method'].nodeValue : undefined;
1238
+
1239
+ if (!formMethod) {
1240
+ console.warn('[ ToolbarFormHelper::UndefinedMethod : form `'+ attributes['id'].nodeValue +'` method attribute cannot be left undefined !');
1241
+ }
1242
+
1243
+ routeObj = routing.getRouteByUrl(val, formMethod);
1244
+
1245
+ if ( typeof(routeObj) == 'undefined' || !routeObj ) {
1246
+ routeObj = {
1247
+ name: 'not found',
1248
+ namespace: 'not found',
1249
+ param: {
1250
+ control: 'not found',
1251
+ file: 'not found'
1252
+ }
1253
+ }
1254
+ }
1255
+
1256
+ val = '<ul>' +
1257
+ '<li>' +
1258
+ '<span class="gina-toolbar-key">url</span>' +
1259
+ '<span class="gina-toolbar-value">' + (val || '#') + '</span>' +
1260
+ '</li>' +
1261
+ '<li>' +
1262
+ '<span class="gina-toolbar-key">route</span>' +
1263
+ '<span class="gina-toolbar-value">' + routeObj.name +'</span>' +
1264
+ '</li>' +
1265
+ '<li>' +
1266
+ '<span class="gina-toolbar-key">namespace</span>' +
1267
+ '<span class="gina-toolbar-value">' + (routeObj.namespace || 'root controller') + '</span>' +
1268
+ '</li>' +
1269
+ '<li>' +
1270
+ '<span class="gina-toolbar-key">control</span>' +
1271
+ '<span class="gina-toolbar-value">' + routeObj.param.control + '</span>' +
1272
+ '</li>' +
1273
+ '<li>' +
1274
+ '<span class="gina-toolbar-key">file</span>' +
1275
+ '<span class="gina-toolbar-value">' + routeObj.param.file + '</span>' +
1276
+ '</li>' +
1277
+ '<ul>';
1278
+
1279
+ content = '<li>' +
1280
+ '<span class="gina-toolbar-key">' + key + ':</span>' +
1281
+ '<span class="gina-toolbar-value">' + val + '</span>' +
1282
+ '</li>';
1283
+ }
1284
+
1285
+ //content = val;
1286
+
1287
+
1288
+ // events
1289
+ if ( /^data-gina-form-event/.test(key) ) {
1290
+ section = 'events';
1291
+ hasEvents = ( $form
1292
+ .find('.'+ attrClass)
1293
+ .find('.gina-toolbar-key-events').length ) ? true : false;
1294
+
1295
+ key = key.replace(/^data-gina-form-event-/, '');
1296
+
1297
+ if (!hasEvents) {
1298
+ // adding event sub section
1299
+ $form
1300
+ .find('ul.gina-toolbar-section-content')
1301
+ .append('<li class="gina-toolbar-form-'+ section +'">' +
1302
+ '<h3 class="gina-toolbar-sub-section-title">'+ section +'</h3>' +
1303
+ '<ul class="gina-toolbar-code"></ul>' +
1304
+ '</li>');
1305
+
1306
+ }
1307
+
1308
+
1309
+ content = '<li>' +
1310
+ '<span class="gina-toolbar-key">'+ key +':</span>' +
1311
+ '<span class="gina-toolbar-value">'+ val +'</span>' +
1312
+ '</li>';
1313
+
1314
+
1315
+ $form
1316
+ .find('ul.gina-toolbar-section-content')
1317
+ .find('li.gina-toolbar-form-'+ section +' > ul')
1318
+ .append(content)
1319
+
1320
+
1321
+ } else { // normal case
1322
+
1323
+ if (!/^action$/.test(key)) {
1324
+ content = '<li>' +
1325
+ '<span class="gina-toolbar-key">' + key + ':</span>' +
1326
+ '<span class="gina-toolbar-value">' + val + '</span>' +
1327
+ '</li>';
1328
+ }
1329
+
1330
+ $form
1331
+ .find('ul.gina-toolbar-section-content')
1332
+ .find('li.'+ attrClass +' > ul')
1333
+ .append(content)
1334
+ }
1335
+
1336
+
1337
+ }
1338
+
1339
+ // adding form rules
1340
+ var rules = null;
1341
+
1342
+ try {
1343
+
1344
+ var dataRule = $forms[i].getAttribute('data-gina-form-rule');
1345
+
1346
+ if ( typeof(dataRule) != 'undefined' && dataRule!= null ) {
1347
+ rules = eval('gina.forms.rules.' + dataRule.replace(/-/g, '.'))
1348
+ } else {
1349
+ rules = eval('gina.forms.rules.' + id.replace(/-/g, '.'))
1350
+ }
1351
+
1352
+ } catch (err) {}
1353
+
1354
+ if ( rules ) {
1355
+ section = 'rules';
1356
+ $form
1357
+ .find('ul.gina-toolbar-section-content')
1358
+ .append('<li class="gina-toolbar-form-'+ section +'">' +
1359
+ '<h3 class="gina-toolbar-sub-section-title">'+ section +'</h3>' +
1360
+ '<ul class="gina-toolbar-properties">'+ parseSection( rules, id, elIsXHR, section ) +'</ul>' +
1361
+ '</li>');
1362
+
1363
+ }
1364
+
1365
+
1366
+
1367
+ $html.append($form);
1368
+
1369
+ ++i;
1370
+
1371
+ if (i < len) {
1372
+ parseForms(obj, ginaObj, $html, i, $forms, len, elIsXHR)
1373
+ }
1374
+ }
1375
+
1376
+ var updateForm = function(id, section, obj, elIsXHR) {
1377
+
1378
+ var $form = $('#gina-toolbar-form-' + id);
1379
+
1380
+ // reset
1381
+ $section = $form
1382
+ .find('ul.gina-toolbar-section-content')
1383
+ .find('li.gina-toolbar-form-'+ section + '> ul');
1384
+
1385
+ if ($section.length > 0) { // update
1386
+
1387
+ if ( obj.count() == 0 ) { // no errors remove section
1388
+ $form
1389
+ .find('ul.gina-toolbar-section-content')
1390
+ .find('li.gina-toolbar-form-' + section)
1391
+ .remove();
1392
+ return false
1393
+ }
1394
+
1395
+ $section
1396
+ .html( parseSection( obj, id, elIsXHR, section ) );
1397
+
1398
+ } else { // init
1399
+
1400
+ $form
1401
+ .find('ul.gina-toolbar-section-content')
1402
+ .append('<li class="gina-toolbar-form-'+ section +'">' +
1403
+ '<h3 class="gina-toolbar-sub-section-title">'+ section +'</h3>' +
1404
+ '<ul class="gina-toolbar-properties">'+ parseSection( obj, id, elIsXHR, section ) +'</ul>' +
1405
+ '</li>');
1406
+ }
1407
+
1408
+ // Form binding
1409
+ var $sectionContent = $form.find('ul.gina-toolbar-section-content');
1410
+ if ( !$sectionContent.is(':visible') ) {
1411
+ $sectionContent.slideToggle()
1412
+ }
1413
+
1414
+ }
1415
+
1416
+ var createInputFile = function(id, label) {
1417
+
1418
+ var html = null;
1419
+
1420
+ html = '<label class="gina-toolbar-input-file">';
1421
+ html += '<input type="file" multiple id="' + id +'">';
1422
+ html += label;
1423
+ html += '</label>';
1424
+
1425
+ return html
1426
+ }
1427
+
1428
+ var loadJSON = function(txt, cb) {
1429
+
1430
+ var html = createInputFile('mock', 'Select your JSON file');
1431
+
1432
+ $htmlData.html(html);
1433
+ $json.text('');
1434
+
1435
+ $htmlData.find('input').off('change').on('change', function(e) {
1436
+
1437
+ var files = $(this)[0].files;
1438
+ var file = null;
1439
+ var reader = null;
1440
+
1441
+
1442
+ if (files.length == 1) {
1443
+ file = $(this)[0].files[0]; // jQuery way
1444
+ reader = new FileReader();
1445
+ reader.addEventListener('load', function(){
1446
+ // user
1447
+ $json.text(reader.result);
1448
+ // gina <- being duplicated to prevent bugs
1449
+ $ginaJson.text(reader.result);
1450
+ cb();
1451
+ }, false);
1452
+
1453
+ reader.readAsBinaryString(file)
1454
+ } else {
1455
+ var done = 0;
1456
+ var complete = function (done) {
1457
+
1458
+ if (done == files.length) {
1459
+ cb()
1460
+ }
1461
+ };
1462
+
1463
+ reader = [];
1464
+
1465
+ for (var i = 0, len = files.length; i < len; ++i) {
1466
+ file = files[i];
1467
+ switch (true) {
1468
+ case /user/.test(file.name):
1469
+
1470
+ reader[i] = new FileReader();
1471
+ reader[i].addEventListener('load', function onEventListenerAdded(e){
1472
+
1473
+ // user
1474
+ $json.text(e.currentTarget.result);
1475
+ ++done;
1476
+ complete(done)
1477
+ }, false);
1478
+
1479
+ reader[i].readAsBinaryString(file);
1480
+
1481
+ break;
1482
+
1483
+ case /gina/.test(file.name):
1484
+ //console.log(file);
1485
+ reader[i] = new FileReader();
1486
+ reader[i].addEventListener('load', function onEventListenerAdded(e){
1487
+ // gina
1488
+ $ginaJson.text(e.currentTarget.result);
1489
+ ++done;
1490
+ complete(done)
1491
+ }, false);
1492
+
1493
+ reader[i].readAsBinaryString(file);
1494
+
1495
+ break;
1496
+ }
1497
+ }
1498
+ }
1499
+
1500
+ });
1501
+
1502
+ return false;
1503
+ }
1504
+
1505
+ var makeFoldingPaths = function(obj, tmp) {
1506
+ for (var r in obj) {
1507
+ if ( typeof(obj[r]) == 'object' ) {
1508
+ self.foldingPaths[tmp + r] = tmp + r;
1509
+ makeFoldingPaths(obj[r], tmp + r+'-');
1510
+ }
1511
+ }
1512
+ }
1513
+
1514
+ this.update = function (section, data) {
1515
+ loadData(section, data);
1516
+ }
1517
+
1518
+ this.restore = function () {
1519
+ // get last jsonObject.data state
1520
+ if (lastJsonObjectState && typeof (lastJsonObjectState.data) != 'undefined' ) {
1521
+ originalData.jsonObject.data = lastJsonObjectState.data;
1522
+ }
1523
+
1524
+ loadData('data', originalData.jsonObject, originalData.ginaJsonObject);
1525
+ self.hasParsedUrls = false;
1526
+ routing.notFound = {};
1527
+ }
1528
+
1529
+
1530
+ if ( typeof(gina.validator) != 'undefined' ) {
1531
+ gina.validator.on('initialized', function onValidatorReady(){
1532
+ console.log('toolbar validator ready');
1533
+ init();
1534
+ })
1535
+ } else {
1536
+ init();
1537
+ }
1538
+
1539
+ }
1540
+
1541
+ return Toolbar
1542
+ })