adapt-authoring-ui 0.0.1

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 (414) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +14 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.yml +55 -0
  4. package/.github/ISSUE_TEMPLATE/config.yml +1 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +22 -0
  6. package/.github/dependabot.yml +11 -0
  7. package/.github/pull_request_template.md +25 -0
  8. package/.github/workflows/labelled_prs.yml +16 -0
  9. package/.github/workflows/new.yml +19 -0
  10. package/adapt-authoring.json +11 -0
  11. package/app/core/app.js +43 -0
  12. package/app/core/assets/adapt-learning-logo-outline.png +0 -0
  13. package/app/core/assets/adapt-learning-logo-white.png +0 -0
  14. package/app/core/assets/ajax-loader.gif +0 -0
  15. package/app/core/assets/favicon.png +0 -0
  16. package/app/core/assets/transparency-light.png +0 -0
  17. package/app/core/browserStorage.js +45 -0
  18. package/app/core/collections/apiCollection.js +74 -0
  19. package/app/core/collections/contentCollection.js +33 -0
  20. package/app/core/collections/contentPluginCollection.js +24 -0
  21. package/app/core/collections/tagsCollection.js +4 -0
  22. package/app/core/constants.js +10 -0
  23. package/app/core/helpers.js +375 -0
  24. package/app/core/index.hbs +192 -0
  25. package/app/core/l10n.js +33 -0
  26. package/app/core/less/_reset.less +43 -0
  27. package/app/core/less/app.less +100 -0
  28. package/app/core/less/buttons.less +268 -0
  29. package/app/core/less/colourLabels.less +14 -0
  30. package/app/core/less/colours.less +132 -0
  31. package/app/core/less/columns.less +190 -0
  32. package/app/core/less/fonts.less +30 -0
  33. package/app/core/less/forms.less +77 -0
  34. package/app/core/less/sharedStyles.less +73 -0
  35. package/app/core/less/tables.less +29 -0
  36. package/app/core/less/tags.less +194 -0
  37. package/app/core/loading.hbs +27 -0
  38. package/app/core/models/articleModel.js +19 -0
  39. package/app/core/models/blockModel.js +25 -0
  40. package/app/core/models/clipboardModel.js +10 -0
  41. package/app/core/models/componentModel.js +18 -0
  42. package/app/core/models/configModel.js +22 -0
  43. package/app/core/models/contentModel.js +26 -0
  44. package/app/core/models/contentObjectModel.js +19 -0
  45. package/app/core/models/contentPluginModel.js +10 -0
  46. package/app/core/models/courseModel.js +24 -0
  47. package/app/core/models/sessionModel.js +86 -0
  48. package/app/core/origin.js +189 -0
  49. package/app/core/router.js +135 -0
  50. package/app/core/views/originView.js +92 -0
  51. package/app/libraries/babel-polyfill.min.js +1 -0
  52. package/app/libraries/backbone-forms-lists.js +669 -0
  53. package/app/libraries/backbone-forms.js +2604 -0
  54. package/app/libraries/backbone.js +1581 -0
  55. package/app/libraries/ckeditor.js +6 -0
  56. package/app/libraries/handlebars.js +4902 -0
  57. package/app/libraries/imageReady.js +2 -0
  58. package/app/libraries/inview.js +140 -0
  59. package/app/libraries/jquery-ui.min.js +6 -0
  60. package/app/libraries/jquery.form.js +1277 -0
  61. package/app/libraries/jquery.js +10346 -0
  62. package/app/libraries/jquery.tagsinput.min.js +1 -0
  63. package/app/libraries/moment.min.js +7 -0
  64. package/app/libraries/polyglot.min.js +2922 -0
  65. package/app/libraries/require.js +36 -0
  66. package/app/libraries/scrollTo.js +11 -0
  67. package/app/libraries/selectize/css/selectize.less +403 -0
  68. package/app/libraries/selectize/js/selectize.js +4500 -0
  69. package/app/libraries/spectrum/spectrum.js +2323 -0
  70. package/app/libraries/spectrum/spectrum.less +507 -0
  71. package/app/libraries/underscore.js +1692 -0
  72. package/app/libraries/velocity.js +4773 -0
  73. package/app/modules/appHeader/assets/top-bar-1080.jpg +0 -0
  74. package/app/modules/appHeader/assets/top-bar-2560.jpg +0 -0
  75. package/app/modules/appHeader/index.js +5 -0
  76. package/app/modules/appHeader/less/appHeader.less +72 -0
  77. package/app/modules/appHeader/templates/appHeader.hbs +17 -0
  78. package/app/modules/appHeader/views/appHeaderView.js +63 -0
  79. package/app/modules/assetManagement/collections/assetCollection.js +16 -0
  80. package/app/modules/assetManagement/index.js +65 -0
  81. package/app/modules/assetManagement/less/asset.less +229 -0
  82. package/app/modules/assetManagement/less/assetManagementModalTags.less +34 -0
  83. package/app/modules/assetManagement/less/assetManagementNew.less +60 -0
  84. package/app/modules/assetManagement/models/assetModel.js +11 -0
  85. package/app/modules/assetManagement/templates/assetManagement.hbs +12 -0
  86. package/app/modules/assetManagement/templates/assetManagementCollection.hbs +2 -0
  87. package/app/modules/assetManagement/templates/assetManagementEditAsset.hbs +9 -0
  88. package/app/modules/assetManagement/templates/assetManagementEditAssetSidebar.hbs +10 -0
  89. package/app/modules/assetManagement/templates/assetManagementListItem.hbs +35 -0
  90. package/app/modules/assetManagement/templates/assetManagementModalAutofill.hbs +1 -0
  91. package/app/modules/assetManagement/templates/assetManagementModalEditAsset.hbs +11 -0
  92. package/app/modules/assetManagement/templates/assetManagementModalFilters.hbs +16 -0
  93. package/app/modules/assetManagement/templates/assetManagementModalTags.hbs +26 -0
  94. package/app/modules/assetManagement/templates/assetManagementPreview.hbs +53 -0
  95. package/app/modules/assetManagement/templates/assetManagementSidebar.hbs +93 -0
  96. package/app/modules/assetManagement/templates/assetPicker.hbs +45 -0
  97. package/app/modules/assetManagement/views/assetManagementCollectionView.js +216 -0
  98. package/app/modules/assetManagement/views/assetManagementEditAssetSidebarView.js +25 -0
  99. package/app/modules/assetManagement/views/assetManagementEditAssetView.js +123 -0
  100. package/app/modules/assetManagement/views/assetManagementItemView.js +68 -0
  101. package/app/modules/assetManagement/views/assetManagementModalAutofillView.js +51 -0
  102. package/app/modules/assetManagement/views/assetManagementModalEditAssetView.js +38 -0
  103. package/app/modules/assetManagement/views/assetManagementModalFiltersView.js +132 -0
  104. package/app/modules/assetManagement/views/assetManagementModalTagsView.js +169 -0
  105. package/app/modules/assetManagement/views/assetManagementModalView.js +62 -0
  106. package/app/modules/assetManagement/views/assetManagementPreviewView.js +69 -0
  107. package/app/modules/assetManagement/views/assetManagementSidebarView.js +126 -0
  108. package/app/modules/assetManagement/views/assetManagementView.js +43 -0
  109. package/app/modules/colorLabel/index.js +48 -0
  110. package/app/modules/colorLabel/less/colorLabels.less +102 -0
  111. package/app/modules/colorLabel/models/colors.js +31 -0
  112. package/app/modules/colorLabel/templates/colorLabelPopUpView.hbs +21 -0
  113. package/app/modules/colorLabel/views/colorLabelPopupView.js +75 -0
  114. package/app/modules/contentHeader/index.js +6 -0
  115. package/app/modules/contentHeader/less/contentHeader.less +152 -0
  116. package/app/modules/contentHeader/less/options.less +51 -0
  117. package/app/modules/contentHeader/templates/actionsButton.hbs +3 -0
  118. package/app/modules/contentHeader/templates/contentHeader.hbs +38 -0
  119. package/app/modules/contentHeader/templates/contentHeaderToggleButton.hbs +11 -0
  120. package/app/modules/contentHeader/templates/filterItem.hbs +23 -0
  121. package/app/modules/contentHeader/templates/options.hbs +14 -0
  122. package/app/modules/contentHeader/templates/partials/part_headerButtonContent.hbs +2 -0
  123. package/app/modules/contentHeader/templates/sortItem.hbs +9 -0
  124. package/app/modules/contentHeader/views/actionsButtonView.js +14 -0
  125. package/app/modules/contentHeader/views/contentHeaderButtonView.js +42 -0
  126. package/app/modules/contentHeader/views/contentHeaderToggleButtonView.js +52 -0
  127. package/app/modules/contentHeader/views/contentHeaderView.js +96 -0
  128. package/app/modules/contentHeader/views/filtersButtonView.js +31 -0
  129. package/app/modules/contentHeader/views/optionsView.js +88 -0
  130. package/app/modules/contentHeader/views/sortsButtonView.js +45 -0
  131. package/app/modules/contentPane/index.js +20 -0
  132. package/app/modules/contentPane/less/contentPane.less +8 -0
  133. package/app/modules/contentPane/templates/contentPane.hbs +2 -0
  134. package/app/modules/contentPane/views/contentPaneView.js +77 -0
  135. package/app/modules/contextMenu/index.js +85 -0
  136. package/app/modules/contextMenu/less/contextMenu.less +54 -0
  137. package/app/modules/contextMenu/templates/contextMenu.hbs +6 -0
  138. package/app/modules/contextMenu/templates/contextMenuItem.hbs +8 -0
  139. package/app/modules/contextMenu/views/contextMenuItemView.js +37 -0
  140. package/app/modules/contextMenu/views/contextMenuView.js +76 -0
  141. package/app/modules/editor/article/index.js +18 -0
  142. package/app/modules/editor/article/templates/editorArticleEdit.hbs +2 -0
  143. package/app/modules/editor/article/templates/editorArticleEditSidebar.hbs +19 -0
  144. package/app/modules/editor/article/views/editorArticleEditSidebarView.js +32 -0
  145. package/app/modules/editor/article/views/editorArticleEditView.js +19 -0
  146. package/app/modules/editor/block/index.js +18 -0
  147. package/app/modules/editor/block/templates/editorBlockEdit.hbs +2 -0
  148. package/app/modules/editor/block/templates/editorBlockEditSidebar.hbs +19 -0
  149. package/app/modules/editor/block/views/editorBlockEditSidebarView.js +28 -0
  150. package/app/modules/editor/block/views/editorBlockEditView.js +19 -0
  151. package/app/modules/editor/component/index.js +22 -0
  152. package/app/modules/editor/component/templates/editorComponentEdit.hbs +2 -0
  153. package/app/modules/editor/component/templates/editorComponentEditSidebar.hbs +19 -0
  154. package/app/modules/editor/component/views/editorComponentEditSidebarView.js +32 -0
  155. package/app/modules/editor/component/views/editorComponentEditView.js +23 -0
  156. package/app/modules/editor/config/index.js +15 -0
  157. package/app/modules/editor/config/templates/editorConfigEdit.hbs +1 -0
  158. package/app/modules/editor/config/templates/editorConfigEditSidebar.hbs +10 -0
  159. package/app/modules/editor/config/views/editorConfigEditSidebarView.js +28 -0
  160. package/app/modules/editor/config/views/editorConfigEditView.js +28 -0
  161. package/app/modules/editor/contentObject/assets/component-icons/icon-accordion.png +0 -0
  162. package/app/modules/editor/contentObject/assets/component-icons/icon-assessment.png +0 -0
  163. package/app/modules/editor/contentObject/assets/component-icons/icon-blank.png +0 -0
  164. package/app/modules/editor/contentObject/assets/component-icons/icon-default.png +0 -0
  165. package/app/modules/editor/contentObject/assets/component-icons/icon-gmcq.png +0 -0
  166. package/app/modules/editor/contentObject/assets/component-icons/icon-graphic.png +0 -0
  167. package/app/modules/editor/contentObject/assets/component-icons/icon-hot-graphic.png +0 -0
  168. package/app/modules/editor/contentObject/assets/component-icons/icon-matching.png +0 -0
  169. package/app/modules/editor/contentObject/assets/component-icons/icon-mcq.png +0 -0
  170. package/app/modules/editor/contentObject/assets/component-icons/icon-media.png +0 -0
  171. package/app/modules/editor/contentObject/assets/component-icons/icon-narrative.png +0 -0
  172. package/app/modules/editor/contentObject/assets/component-icons/icon-slider.png +0 -0
  173. package/app/modules/editor/contentObject/assets/component-icons/icon-text.png +0 -0
  174. package/app/modules/editor/contentObject/index.js +68 -0
  175. package/app/modules/editor/contentObject/less/editing-overlay-component-list.less +60 -0
  176. package/app/modules/editor/contentObject/less/editing-overlay-panel.less +25 -0
  177. package/app/modules/editor/contentObject/less/editorMenu.less +84 -0
  178. package/app/modules/editor/contentObject/less/editorMenuItem.less +114 -0
  179. package/app/modules/editor/contentObject/less/editorMenuLayer.less +70 -0
  180. package/app/modules/editor/contentObject/less/editorPage.less +162 -0
  181. package/app/modules/editor/contentObject/less/editorPageArticle.less +40 -0
  182. package/app/modules/editor/contentObject/less/editorPageBlock.less +33 -0
  183. package/app/modules/editor/contentObject/less/editorPageComponent.less +47 -0
  184. package/app/modules/editor/contentObject/less/editorPageComponentList.less +234 -0
  185. package/app/modules/editor/contentObject/templates/editorMenu.hbs +1 -0
  186. package/app/modules/editor/contentObject/templates/editorMenuItem.hbs +23 -0
  187. package/app/modules/editor/contentObject/templates/editorMenuLayer.hbs +12 -0
  188. package/app/modules/editor/contentObject/templates/editorMenuSidebar.hbs +1 -0
  189. package/app/modules/editor/contentObject/templates/editorPage.hbs +15 -0
  190. package/app/modules/editor/contentObject/templates/editorPageArticle.hbs +15 -0
  191. package/app/modules/editor/contentObject/templates/editorPageBlock.hbs +14 -0
  192. package/app/modules/editor/contentObject/templates/editorPageComponent.hbs +9 -0
  193. package/app/modules/editor/contentObject/templates/editorPageComponentList.hbs +33 -0
  194. package/app/modules/editor/contentObject/templates/editorPageComponentListItem.hbs +24 -0
  195. package/app/modules/editor/contentObject/templates/editorPageComponentPasteZone.hbs +4 -0
  196. package/app/modules/editor/contentObject/templates/editorPageEdit.hbs +1 -0
  197. package/app/modules/editor/contentObject/templates/editorPageEditSidebar.hbs +10 -0
  198. package/app/modules/editor/contentObject/templates/editorPageSidebar.hbs +1 -0
  199. package/app/modules/editor/contentObject/views/editorMenuItemView.js +174 -0
  200. package/app/modules/editor/contentObject/views/editorMenuLayerView.js +212 -0
  201. package/app/modules/editor/contentObject/views/editorMenuSidebarView.js +13 -0
  202. package/app/modules/editor/contentObject/views/editorMenuView.js +211 -0
  203. package/app/modules/editor/contentObject/views/editorPageArticleView.js +278 -0
  204. package/app/modules/editor/contentObject/views/editorPageBlockView.js +280 -0
  205. package/app/modules/editor/contentObject/views/editorPageComponentListItemView.js +80 -0
  206. package/app/modules/editor/contentObject/views/editorPageComponentListView.js +131 -0
  207. package/app/modules/editor/contentObject/views/editorPageComponentPasteZoneView.js +47 -0
  208. package/app/modules/editor/contentObject/views/editorPageComponentView.js +202 -0
  209. package/app/modules/editor/contentObject/views/editorPageEditSidebarView.js +28 -0
  210. package/app/modules/editor/contentObject/views/editorPageEditView.js +19 -0
  211. package/app/modules/editor/contentObject/views/editorPageSidebarView.js +13 -0
  212. package/app/modules/editor/contentObject/views/editorPageView.js +183 -0
  213. package/app/modules/editor/course/index.js +26 -0
  214. package/app/modules/editor/course/templates/editorCourseEdit.hbs +2 -0
  215. package/app/modules/editor/course/templates/editorCourseEditSidebar.hbs +19 -0
  216. package/app/modules/editor/course/views/editorCourseEditSidebarView.js +28 -0
  217. package/app/modules/editor/course/views/editorCourseEditView.js +56 -0
  218. package/app/modules/editor/extensions/index.js +26 -0
  219. package/app/modules/editor/extensions/less/extensions.less +22 -0
  220. package/app/modules/editor/extensions/templates/editorExtensionsEdit.hbs +85 -0
  221. package/app/modules/editor/extensions/templates/editorExtensionsEditSidebar.hbs +1 -0
  222. package/app/modules/editor/extensions/views/editorExtensionsEditSidebarView.js +10 -0
  223. package/app/modules/editor/extensions/views/editorExtensionsEditView.js +85 -0
  224. package/app/modules/editor/global/collections/editorCollection.js +24 -0
  225. package/app/modules/editor/global/editorDataLoader.js +91 -0
  226. package/app/modules/editor/global/helpers.js +99 -0
  227. package/app/modules/editor/global/less/colorLabels.less +55 -0
  228. package/app/modules/editor/global/less/editor.less +204 -0
  229. package/app/modules/editor/global/templates/editor.hbs +1 -0
  230. package/app/modules/editor/global/templates/editorPasteZone.hbs +4 -0
  231. package/app/modules/editor/global/templates/partials/part_editorCommon.hbs +70 -0
  232. package/app/modules/editor/global/templates/partials/part_editorItemSidebar.hbs +40 -0
  233. package/app/modules/editor/global/templates/partials/part_editorMenu.hbs +4 -0
  234. package/app/modules/editor/global/templates/partials/part_settingsGeneral.hbs +27 -0
  235. package/app/modules/editor/global/views/editorOriginView.js +255 -0
  236. package/app/modules/editor/global/views/editorPasteZoneView.js +69 -0
  237. package/app/modules/editor/global/views/editorView.js +288 -0
  238. package/app/modules/editor/index.js +52 -0
  239. package/app/modules/editor/menuSettings/index.js +27 -0
  240. package/app/modules/editor/menuSettings/less/menusettings.less +55 -0
  241. package/app/modules/editor/menuSettings/templates/editorMenuSettingsEdit.hbs +1 -0
  242. package/app/modules/editor/menuSettings/templates/editorMenuSettingsEditSidebar.hbs +5 -0
  243. package/app/modules/editor/menuSettings/templates/editorMenuSettingsItem.hbs +4 -0
  244. package/app/modules/editor/menuSettings/views/editorMenuSettingsEditSidebarView.js +21 -0
  245. package/app/modules/editor/menuSettings/views/editorMenuSettingsEditView.js +71 -0
  246. package/app/modules/editor/menuSettings/views/editorMenuSettingsView.js +44 -0
  247. package/app/modules/editor/themeEditor/collections/editorPresetCollection.js +13 -0
  248. package/app/modules/editor/themeEditor/index.js +15 -0
  249. package/app/modules/editor/themeEditor/less/editorPresetEdit.less +78 -0
  250. package/app/modules/editor/themeEditor/less/editorTheming.less +73 -0
  251. package/app/modules/editor/themeEditor/models/editorModel.js +62 -0
  252. package/app/modules/editor/themeEditor/models/editorPresetModel.js +6 -0
  253. package/app/modules/editor/themeEditor/templates/editorPresetEdit.hbs +31 -0
  254. package/app/modules/editor/themeEditor/templates/editorTheming.hbs +35 -0
  255. package/app/modules/editor/themeEditor/templates/editorThemingSidebar.hbs +23 -0
  256. package/app/modules/editor/themeEditor/views/editorPresetEditView.js +98 -0
  257. package/app/modules/editor/themeEditor/views/editorThemingSidebarView.js +62 -0
  258. package/app/modules/editor/themeEditor/views/editorThemingView.js +304 -0
  259. package/app/modules/frameworkImport/index.js +32 -0
  260. package/app/modules/frameworkImport/less/frameworkImport.less +101 -0
  261. package/app/modules/frameworkImport/templates/frameworkImport.hbs +58 -0
  262. package/app/modules/frameworkImport/templates/frameworkImportSidebar.hbs +12 -0
  263. package/app/modules/frameworkImport/templates/frameworkImportSummary.hbs +40 -0
  264. package/app/modules/frameworkImport/templates/partials/part_frameworkImportButton.hbs +3 -0
  265. package/app/modules/frameworkImport/templates/partials/part_frameworkImportStatusMessages.hbs +22 -0
  266. package/app/modules/frameworkImport/views/frameworkImportSidebarView.js +31 -0
  267. package/app/modules/frameworkImport/views/frameworkImportView.js +109 -0
  268. package/app/modules/globalMenu/index.js +86 -0
  269. package/app/modules/globalMenu/less/globalMenu.less +117 -0
  270. package/app/modules/globalMenu/templates/globalMenu.hbs +6 -0
  271. package/app/modules/globalMenu/templates/globalMenuItem.hbs +10 -0
  272. package/app/modules/globalMenu/templates/partials/part_globalMenuButton.hbs +7 -0
  273. package/app/modules/globalMenu/views/globalMenuItemView.js +108 -0
  274. package/app/modules/globalMenu/views/globalMenuView.js +45 -0
  275. package/app/modules/limiteduser/index.js +17 -0
  276. package/app/modules/limiteduser/less/limitedUser.less +29 -0
  277. package/app/modules/limiteduser/templates/limitedUser.hbs +8 -0
  278. package/app/modules/limiteduser/views/limitedUserView.js +12 -0
  279. package/app/modules/modal/index.js +13 -0
  280. package/app/modules/modal/less/modal.less +61 -0
  281. package/app/modules/modal/models/modalModel.js +14 -0
  282. package/app/modules/modal/templates/modal.hbs +34 -0
  283. package/app/modules/modal/views/modalView.js +102 -0
  284. package/app/modules/notify/index.js +32 -0
  285. package/app/modules/notify/plugins/alert/assets/sweetalert.css +932 -0
  286. package/app/modules/notify/plugins/alert/index.js +117 -0
  287. package/app/modules/notify/plugins/alert/less/alert.less +74 -0
  288. package/app/modules/notify/plugins/alert/sweetalert2-11.1.7.all.min.js +2 -0
  289. package/app/modules/notify/plugins/console/index.js +18 -0
  290. package/app/modules/notify/plugins/snackbar/index.js +69 -0
  291. package/app/modules/notify/plugins/snackbar/less/snackbar.less +40 -0
  292. package/app/modules/notify/plugins/toast/index.js +70 -0
  293. package/app/modules/notify/plugins/toast/less/toast.less +62 -0
  294. package/app/modules/pluginManagement/index.js +36 -0
  295. package/app/modules/pluginManagement/less/pluginManagement.less +23 -0
  296. package/app/modules/pluginManagement/less/pluginType.less +25 -0
  297. package/app/modules/pluginManagement/templates/pluginManagement.hbs +43 -0
  298. package/app/modules/pluginManagement/templates/pluginManagementSidebar.hbs +40 -0
  299. package/app/modules/pluginManagement/templates/pluginManagementUpload.hbs +12 -0
  300. package/app/modules/pluginManagement/templates/pluginManagementUploadSidebar.hbs +13 -0
  301. package/app/modules/pluginManagement/templates/pluginType.hbs +43 -0
  302. package/app/modules/pluginManagement/views/pluginManagementSidebarView.js +48 -0
  303. package/app/modules/pluginManagement/views/pluginManagementUploadSidebarView.js +25 -0
  304. package/app/modules/pluginManagement/views/pluginManagementUploadView.js +52 -0
  305. package/app/modules/pluginManagement/views/pluginManagementView.js +104 -0
  306. package/app/modules/pluginManagement/views/pluginTypeView.js +105 -0
  307. package/app/modules/projects/assets/origami-project.jpg +0 -0
  308. package/app/modules/projects/index.js +82 -0
  309. package/app/modules/projects/less/projects.less +152 -0
  310. package/app/modules/projects/less/qproject.less +143 -0
  311. package/app/modules/projects/templates/project.hbs +63 -0
  312. package/app/modules/projects/templates/projects.hbs +6 -0
  313. package/app/modules/projects/templates/projectsSidebar.hbs +42 -0
  314. package/app/modules/projects/views/projectView.js +167 -0
  315. package/app/modules/projects/views/projectsSidebarView.js +172 -0
  316. package/app/modules/projects/views/projectsView.js +271 -0
  317. package/app/modules/scaffold/backboneFormsOverrides.js +284 -0
  318. package/app/modules/scaffold/index.js +342 -0
  319. package/app/modules/scaffold/lang/en.json +9 -0
  320. package/app/modules/scaffold/less/codeEditor.less +6 -0
  321. package/app/modules/scaffold/less/colourPicker.less +141 -0
  322. package/app/modules/scaffold/less/displayTitle.less +17 -0
  323. package/app/modules/scaffold/less/forms.less +174 -0
  324. package/app/modules/scaffold/less/list.less +35 -0
  325. package/app/modules/scaffold/less/modal.less +45 -0
  326. package/app/modules/scaffold/less/scaffoldAsset.less +23 -0
  327. package/app/modules/scaffold/less/scaffoldAssetItem.less +50 -0
  328. package/app/modules/scaffold/less/selectize.less +29 -0
  329. package/app/modules/scaffold/less/textArea.less +9 -0
  330. package/app/modules/scaffold/less/users.less +6 -0
  331. package/app/modules/scaffold/templates/field.hbs +25 -0
  332. package/app/modules/scaffold/templates/fieldset.hbs +10 -0
  333. package/app/modules/scaffold/templates/form.hbs +6 -0
  334. package/app/modules/scaffold/templates/list.hbs +4 -0
  335. package/app/modules/scaffold/templates/listItem.hbs +5 -0
  336. package/app/modules/scaffold/templates/scaffoldAsset.hbs +65 -0
  337. package/app/modules/scaffold/templates/scaffoldAssetItem.hbs +35 -0
  338. package/app/modules/scaffold/templates/scaffoldDisplayTitle.hbs +8 -0
  339. package/app/modules/scaffold/templates/scaffoldEditHtml.hbs +1 -0
  340. package/app/modules/scaffold/templates/scaffoldFile.hbs +1 -0
  341. package/app/modules/scaffold/templates/scaffoldItemsModal.hbs +14 -0
  342. package/app/modules/scaffold/templates/scaffoldModalOverlay.hbs +1 -0
  343. package/app/modules/scaffold/templates/scaffoldUsersOption.hbs +8 -0
  344. package/app/modules/scaffold/views/scaffoldAssetItemView.js +203 -0
  345. package/app/modules/scaffold/views/scaffoldAssetView.js +157 -0
  346. package/app/modules/scaffold/views/scaffoldCodeEditorView.js +64 -0
  347. package/app/modules/scaffold/views/scaffoldColourPickerView.js +70 -0
  348. package/app/modules/scaffold/views/scaffoldDisplayTitleView.js +112 -0
  349. package/app/modules/scaffold/views/scaffoldFileView.js +18 -0
  350. package/app/modules/scaffold/views/scaffoldItemsModalView.js +100 -0
  351. package/app/modules/scaffold/views/scaffoldListView.js +158 -0
  352. package/app/modules/scaffold/views/scaffoldTagsView.js +71 -0
  353. package/app/modules/scaffold/views/scaffoldUsersView.js +89 -0
  354. package/app/modules/sidebar/index.js +22 -0
  355. package/app/modules/sidebar/less/sidebar.less +298 -0
  356. package/app/modules/sidebar/less/sidebarFilter.less +91 -0
  357. package/app/modules/sidebar/templates/sidebar.hbs +7 -0
  358. package/app/modules/sidebar/templates/sidebarBreadcrumb.hbs +3 -0
  359. package/app/modules/sidebar/templates/sidebarDivide.hbs +5 -0
  360. package/app/modules/sidebar/templates/sidebarFieldsetFilter.hbs +6 -0
  361. package/app/modules/sidebar/templates/sidebarFilter.hbs +30 -0
  362. package/app/modules/sidebar/templates/sidebarRowFilter.hbs +4 -0
  363. package/app/modules/sidebar/templates/sidebarUpdateButton.hbs +3 -0
  364. package/app/modules/sidebar/views/sidebarFieldsetFilterView.js +43 -0
  365. package/app/modules/sidebar/views/sidebarFilterView.js +132 -0
  366. package/app/modules/sidebar/views/sidebarItemView.js +172 -0
  367. package/app/modules/sidebar/views/sidebarView.js +71 -0
  368. package/app/modules/user/assets/adapt-learning-logo.png +0 -0
  369. package/app/modules/user/assets/adapt-logo.png +0 -0
  370. package/app/modules/user/assets/login_bg.jpg +0 -0
  371. package/app/modules/user/index.js +75 -0
  372. package/app/modules/user/less/forgotPassword.less +14 -0
  373. package/app/modules/user/less/login.less +138 -0
  374. package/app/modules/user/less/logout.less +3 -0
  375. package/app/modules/user/less/resetPassword.less +7 -0
  376. package/app/modules/user/less/userProfile.less +49 -0
  377. package/app/modules/user/models/userProfileModel.js +32 -0
  378. package/app/modules/user/templates/forgotPassword.hbs +36 -0
  379. package/app/modules/user/templates/login.hbs +29 -0
  380. package/app/modules/user/templates/resetPassword.hbs +29 -0
  381. package/app/modules/user/templates/userProfile.hbs +71 -0
  382. package/app/modules/user/templates/userProfileSidebar.hbs +16 -0
  383. package/app/modules/user/views/forgotPasswordView.js +63 -0
  384. package/app/modules/user/views/loginView.js +93 -0
  385. package/app/modules/user/views/resetPasswordView.js +78 -0
  386. package/app/modules/user/views/userProfileSidebarView.js +32 -0
  387. package/app/modules/user/views/userProfileView.js +107 -0
  388. package/app/modules/userManagement/collections/userCollection.js +65 -0
  389. package/app/modules/userManagement/helpers.js +46 -0
  390. package/app/modules/userManagement/index.js +67 -0
  391. package/app/modules/userManagement/less/userManagement.less +268 -0
  392. package/app/modules/userManagement/models/userModel.js +34 -0
  393. package/app/modules/userManagement/templates/addUser.hbs +35 -0
  394. package/app/modules/userManagement/templates/addUserSidebar.hbs +9 -0
  395. package/app/modules/userManagement/templates/user.hbs +126 -0
  396. package/app/modules/userManagement/templates/userManagement.hbs +49 -0
  397. package/app/modules/userManagement/templates/userManagementFilter.hbs +19 -0
  398. package/app/modules/userManagement/templates/userManagementSidebar.hbs +13 -0
  399. package/app/modules/userManagement/views/addUserSidebarView.js +25 -0
  400. package/app/modules/userManagement/views/addUserView.js +85 -0
  401. package/app/modules/userManagement/views/filterView.js +49 -0
  402. package/app/modules/userManagement/views/userManagementSidebarView.js +33 -0
  403. package/app/modules/userManagement/views/userManagementView.js +104 -0
  404. package/app/modules/userManagement/views/userView.js +324 -0
  405. package/conf/config.schema.json +18 -0
  406. package/docs/migrating-from-legacy.md +19 -0
  407. package/docs/plugins/index-ui.md +17 -0
  408. package/docs/plugins/uidocs.js +54 -0
  409. package/docs/ui-extensions.md +15 -0
  410. package/index.js +1 -0
  411. package/lib/UiBuild.js +391 -0
  412. package/lib/UiModule.js +158 -0
  413. package/npm_hooks/postinstall.js +4 -0
  414. package/package.json +27 -0
@@ -0,0 +1,669 @@
1
+ define(['jquery', 'underscore', 'backbone', 'backboneForms'], function($, _, Backbone) {
2
+
3
+ ;(function(Form) {
4
+
5
+ /**
6
+ * List editor
7
+ *
8
+ * An array editor. Creates a list of other editor items.
9
+ *
10
+ * Special options:
11
+ * @param {String} [options.schema.itemType] The editor type for each item in the list. Default: 'Text'
12
+ * @param {String} [options.schema.confirmDelete] Text to display in a delete confirmation dialog. If falsey, will not ask for confirmation.
13
+ */
14
+ Form.editors.List = Form.editors.Base.extend({
15
+
16
+ events: {
17
+ 'click [data-action="add"]': function(event) {
18
+ event.preventDefault();
19
+ this.addItem(undefined, true);
20
+ }
21
+ },
22
+
23
+ initialize: function(options) {
24
+ options = options || {};
25
+
26
+ var editors = Form.editors;
27
+
28
+ editors.Base.prototype.initialize.call(this, options);
29
+
30
+ var schema = this.schema;
31
+ if (!schema) throw new Error("Missing required option 'schema'");
32
+
33
+ this.schema = _.extend({
34
+ addLabel: 'Add'
35
+ }, schema);
36
+
37
+ this.template = options.template || schema.listTemplate || this.constructor.template;
38
+
39
+ //Determine the editor to use
40
+ this.Editor = (function() {
41
+ var type = schema.itemType;
42
+
43
+ //Default to Text
44
+ if (!type) return editors.Text;
45
+
46
+ //Use List-specific version if available
47
+ if (editors.List[type]) return editors.List[type];
48
+
49
+ //Or whichever was passed
50
+ return (_.isString(type)) ? editors[type] : type;
51
+ })();
52
+
53
+ this.ListItem = schema.itemClass || editors.List.Item;
54
+
55
+ this.items = [];
56
+ },
57
+
58
+ render: function() {
59
+ var self = this,
60
+ value = this.value || [],
61
+ $ = Backbone.$;
62
+
63
+ //Create main element
64
+ var $el = $($.trim(this.template({
65
+ addLabel: this.schema.addLabel
66
+ })));
67
+
68
+ //Store a reference to the list (item container)
69
+ this.$list = $el.is('[data-items]') ? $el : $el.find('[data-items]');
70
+
71
+ //Add existing items
72
+ if (value.length) {
73
+ _.each(value, function(itemValue) {
74
+ self.addItem(itemValue);
75
+ });
76
+ }
77
+
78
+ //If no existing items create an empty one, unless the editor specifies otherwise
79
+ else {
80
+ if (!this.Editor.isAsync) this.addItem();
81
+ }
82
+
83
+ this.setElement($el);
84
+ this.$el.attr('id', this.id);
85
+ this.$el.attr('name', this.key);
86
+
87
+ if (this.hasFocus) this.trigger('blur', this);
88
+
89
+ return this;
90
+ },
91
+
92
+ /**
93
+ * Add a new item to the list
94
+ * @param {Mixed} [value] Value for the new item editor
95
+ * @param {Boolean} [userInitiated] If the item was added by the user clicking 'add'
96
+ */
97
+ addItem: function(value, userInitiated) {
98
+ var self = this,
99
+ editors = Form.editors;
100
+
101
+ //Create the item
102
+ var item = new this.ListItem({
103
+ list: this,
104
+ form: this.form,
105
+ schema: this.schema,
106
+ value: value,
107
+ Editor: this.Editor,
108
+ key: this.key
109
+ }).render();
110
+
111
+ var _addItem = function() {
112
+ self.items.push(item);
113
+ self.$list.append(item.el);
114
+
115
+ item.editor.on('all', function(event) {
116
+ if (event === 'change') return;
117
+
118
+ // args = ["key:change", itemEditor, fieldEditor]
119
+ var args = _.toArray(arguments);
120
+ args[0] = 'item:' + event;
121
+ args.splice(1, 0, self);
122
+ // args = ["item:key:change", this=listEditor, itemEditor, fieldEditor]
123
+
124
+ editors.List.prototype.trigger.apply(this, args);
125
+ }, self);
126
+
127
+ item.editor.on('change', function() {
128
+ if (!item.addEventTriggered) {
129
+ item.addEventTriggered = true;
130
+ this.trigger('add', this, item.editor);
131
+ }
132
+ this.trigger('item:change', this, item.editor);
133
+ this.trigger('change', this);
134
+ }, self);
135
+
136
+ item.editor.on('focus', function() {
137
+ if (this.hasFocus) return;
138
+ this.trigger('focus', this);
139
+ }, self);
140
+ item.editor.on('blur', function() {
141
+ if (!this.hasFocus) return;
142
+ var self = this;
143
+ setTimeout(function() {
144
+ if (_.find(self.items, function(item) { return item.editor.hasFocus; })) return;
145
+ self.trigger('blur', self);
146
+ }, 0);
147
+ }, self);
148
+
149
+ if (userInitiated || value) {
150
+ item.addEventTriggered = true;
151
+ }
152
+
153
+ if (userInitiated) {
154
+ self.trigger('add', self, item.editor);
155
+ self.trigger('change', self);
156
+ }
157
+ };
158
+
159
+ //Check if we need to wait for the item to complete before adding to the list
160
+ if (this.Editor.isAsync) {
161
+ item.editor.on('readyToAdd', _addItem, this);
162
+ }
163
+
164
+ //Most editors can be added automatically
165
+ else {
166
+ _addItem();
167
+ item.editor.focus();
168
+ }
169
+
170
+ return item;
171
+ },
172
+
173
+ /**
174
+ * Remove an item from the list
175
+ * @param {List.Item} item
176
+ */
177
+ removeItem: function(item) {
178
+ //Confirm delete
179
+ var confirmMsg = this.schema.confirmDelete;
180
+ if (confirmMsg && !confirm(confirmMsg)) return;
181
+
182
+ var index = _.indexOf(this.items, item);
183
+
184
+ this.items[index].remove();
185
+ this.items.splice(index, 1);
186
+
187
+ if (item.addEventTriggered) {
188
+ this.trigger('remove', this, item.editor);
189
+ this.trigger('change', this);
190
+ }
191
+
192
+ if (!this.items.length && !this.Editor.isAsync) this.addItem();
193
+ },
194
+
195
+ getValue: function() {
196
+ var values = _.map(this.items, function(item) {
197
+ return item.getValue();
198
+ });
199
+
200
+ //Filter empty items
201
+ return _.without(values, undefined, '');
202
+ },
203
+
204
+ setValue: function(value) {
205
+ this.value = value;
206
+ this.render();
207
+ },
208
+
209
+ focus: function() {
210
+ if (this.hasFocus) return;
211
+
212
+ if (this.items[0]) this.items[0].editor.focus();
213
+ },
214
+
215
+ blur: function() {
216
+ if (!this.hasFocus) return;
217
+
218
+ var focusedItem = _.find(this.items, function(item) { return item.editor.hasFocus; });
219
+
220
+ if (focusedItem) focusedItem.editor.blur();
221
+ },
222
+
223
+ /**
224
+ * Override default remove function in order to remove item views
225
+ */
226
+ remove: function() {
227
+ _.invoke(this.items, 'remove');
228
+
229
+ Form.editors.Base.prototype.remove.call(this);
230
+ },
231
+
232
+ /**
233
+ * Run validation
234
+ *
235
+ * @return {Object|Null}
236
+ */
237
+ validate: function() {
238
+
239
+ //Collect errors
240
+ var errors = _.map(this.items, function(item) {
241
+ return item.validate();
242
+ });
243
+
244
+ //Check if any item has errors
245
+ var hasErrors = _.compact(errors).length ? true : false;
246
+ if (!hasErrors) return null;
247
+
248
+ //If so create a shared error
249
+ var fieldError = {
250
+ type: 'list',
251
+ message: 'Some of the items in the list failed validation',
252
+ errors: errors
253
+ };
254
+
255
+ return fieldError;
256
+ }
257
+ }, {
258
+
259
+ //STATICS
260
+ template: _.template('\
261
+ <div>\
262
+ <div data-items></div>\
263
+ <button type="button" data-action="add"><%= addLabel %></button>\
264
+ </div>\
265
+ ', null, Form.templateSettings)
266
+
267
+ });
268
+
269
+
270
+ /**
271
+ * A single item in the list
272
+ *
273
+ * @param {editors.List} options.list The List editor instance this item belongs to
274
+ * @param {Function} options.Editor Editor constructor function
275
+ * @param {String} options.key Model key
276
+ * @param {Mixed} options.value Value
277
+ * @param {Object} options.schema Field schema
278
+ */
279
+ Form.editors.List.Item = Form.editors.Base.extend({
280
+
281
+ events: {
282
+ 'click [data-action="remove"]': function(event) {
283
+ event.preventDefault();
284
+ this.list.removeItem(this);
285
+ },
286
+ 'keydown input[type=text]': function(event) {
287
+ if(event.keyCode !== 13) return;
288
+ event.preventDefault();
289
+ this.list.addItem();
290
+ this.list.$list.find("> li:last input").focus();
291
+ }
292
+ },
293
+
294
+ initialize: function(options) {
295
+ this.list = options.list;
296
+ this.schema = options.schema || this.list.schema;
297
+ this.value = options.value;
298
+ this.Editor = options.Editor || Form.editors.Text;
299
+ this.key = options.key;
300
+ this.template = options.template || this.schema.itemTemplate || this.constructor.template;
301
+ this.errorClassName = options.errorClassName || this.constructor.errorClassName;
302
+ this.form = options.form;
303
+ },
304
+
305
+ render: function() {
306
+ var $ = Backbone.$;
307
+
308
+ //Create editor
309
+ this.editor = new this.Editor({
310
+ key: this.key,
311
+ schema: this.schema,
312
+ value: this.value,
313
+ list: this.list,
314
+ item: this,
315
+ form: this.form
316
+ }).render();
317
+
318
+ //Create main element
319
+ var $el = $($.trim(this.template()));
320
+
321
+ $el.find('[data-editor]').append(this.editor.el);
322
+
323
+ //Replace the entire element so there isn't a wrapper tag
324
+ this.setElement($el);
325
+
326
+ return this;
327
+ },
328
+
329
+ getValue: function() {
330
+ return this.editor.getValue();
331
+ },
332
+
333
+ setValue: function(value) {
334
+ this.editor.setValue(value);
335
+ },
336
+
337
+ focus: function() {
338
+ this.editor.focus();
339
+ },
340
+
341
+ blur: function() {
342
+ this.editor.blur();
343
+ },
344
+
345
+ remove: function() {
346
+ this.editor.remove();
347
+
348
+ Backbone.View.prototype.remove.call(this);
349
+ },
350
+
351
+ validate: function() {
352
+ var value = this.getValue(),
353
+ formValues = this.list.form ? this.list.form.getValue() : {},
354
+ validators = this.schema.validators,
355
+ getValidator = this.getValidator;
356
+
357
+ if (this.editor.nestedForm && this.editor.nestedForm.validate) {
358
+ return this.editor.nestedForm.validate();
359
+ }
360
+
361
+ if (!validators) return null;
362
+
363
+ //Run through validators until an error is found
364
+ var error = null;
365
+ _.every(validators, function(validator) {
366
+ error = getValidator(validator)(value, formValues);
367
+
368
+ return error ? false : true;
369
+ });
370
+
371
+ //Show/hide error
372
+ if (error){
373
+ this.setError(error);
374
+ } else {
375
+ this.clearError();
376
+ }
377
+
378
+ //Return error to be aggregated by list
379
+ return error ? error : null;
380
+ },
381
+
382
+ /**
383
+ * Show a validation error
384
+ */
385
+ setError: function(err) {
386
+ this.$el.addClass(this.errorClassName);
387
+ this.$el.attr('title', err.message);
388
+ },
389
+
390
+ /**
391
+ * Hide validation errors
392
+ */
393
+ clearError: function() {
394
+ this.$el.removeClass(this.errorClassName);
395
+ this.$el.attr('title', null);
396
+ }
397
+ }, {
398
+
399
+ //STATICS
400
+ template: _.template('\
401
+ <div>\
402
+ <span data-editor></span>\
403
+ <button type="button" data-action="remove">&times;</button>\
404
+ </div>\
405
+ ', null, Form.templateSettings),
406
+
407
+ errorClassName: 'error'
408
+
409
+ });
410
+
411
+
412
+ /**
413
+ * Base modal object editor for use with the List editor; used by Object
414
+ * and NestedModal list types
415
+ */
416
+ Form.editors.List.Modal = Form.editors.Base.extend({
417
+
418
+ events: {
419
+ 'click': 'openEditor'
420
+ },
421
+
422
+ /**
423
+ * @param {Object} options
424
+ * @param {Form} options.form The main form
425
+ * @param {Function} [options.schema.itemToString] Function to transform the value for display in the list.
426
+ * @param {String} [options.schema.itemType] Editor type e.g. 'Text', 'Object'.
427
+ * @param {Object} [options.schema.subSchema] Schema for nested form,. Required when itemType is 'Object'
428
+ * @param {Function} [options.schema.model] Model constructor function. Required when itemType is 'NestedModel'
429
+ */
430
+ initialize: function(options) {
431
+ options = options || {};
432
+
433
+ Form.editors.Base.prototype.initialize.call(this, options);
434
+
435
+ //Dependencies
436
+ if (!Form.editors.List.Modal.ModalAdapter) throw new Error('A ModalAdapter is required');
437
+
438
+ this.form = options.form;
439
+ if (!options.form) throw new Error('Missing required option: "form"');
440
+
441
+ //Template
442
+ this.template = options.template || this.constructor.template;
443
+ },
444
+
445
+ /**
446
+ * Render the list item representation
447
+ */
448
+ render: function() {
449
+ var self = this;
450
+
451
+ //New items in the list are only rendered when the editor has been OK'd
452
+ if (_.isEmpty(this.value)) {
453
+ this.openEditor();
454
+ }
455
+
456
+ //But items with values are added automatically
457
+ else {
458
+ this.renderSummary();
459
+
460
+ setTimeout(function() {
461
+ self.trigger('readyToAdd');
462
+ }, 0);
463
+ }
464
+
465
+ if (this.hasFocus) this.trigger('blur', this);
466
+
467
+ return this;
468
+ },
469
+
470
+ /**
471
+ * Renders the list item representation
472
+ */
473
+ renderSummary: function() {
474
+ this.$el.html($.trim(this.template({
475
+ summary: this.getStringValue()
476
+ })));
477
+ },
478
+
479
+ /**
480
+ * Function which returns a generic string representation of an object
481
+ *
482
+ * @param {Object} value
483
+ *
484
+ * @return {String}
485
+ */
486
+ itemToString: function(value) {
487
+ var createTitle = function(key) {
488
+ var context = { key: key };
489
+
490
+ return Form.Field.prototype.createTitle.call(context);
491
+ };
492
+
493
+ value = value || {};
494
+
495
+ //Pretty print the object keys and values
496
+ var parts = [];
497
+ _.each(this.nestedSchema, function(schema, key) {
498
+ var desc = schema.title ? schema.title : createTitle(key),
499
+ val = value[key];
500
+
501
+ if (_.isUndefined(val) || _.isNull(val)) val = '';
502
+
503
+ parts.push(desc + ': ' + val);
504
+ });
505
+
506
+ return parts.join('<br />');
507
+ },
508
+
509
+ /**
510
+ * Returns the string representation of the object value
511
+ */
512
+ getStringValue: function() {
513
+ var schema = this.schema,
514
+ value = this.getValue();
515
+
516
+ if (_.isEmpty(value)) return '[Empty]';
517
+
518
+ //If there's a specified toString use that
519
+ if (schema.itemToString) return schema.itemToString(value);
520
+
521
+ //Otherwise use the generic method or custom overridden method
522
+ return this.itemToString(value);
523
+ },
524
+
525
+ openEditor: function() {
526
+ var self = this,
527
+ ModalForm = this.form.constructor;
528
+
529
+ var form = this.modalForm = new ModalForm({
530
+ schema: this.nestedSchema,
531
+ data: this.value
532
+ });
533
+
534
+ var modal = this.modal = new Form.editors.List.Modal.ModalAdapter({
535
+ content: form,
536
+ animate: true
537
+ });
538
+
539
+ modal.open();
540
+
541
+ this.trigger('open', this);
542
+ this.trigger('focus', this);
543
+
544
+ modal.on('cancel', this.onModalClosed, this);
545
+
546
+ modal.on('ok', _.bind(this.onModalSubmitted, this));
547
+ },
548
+
549
+ /**
550
+ * Called when the user clicks 'OK'.
551
+ * Runs validation and tells the list when ready to add the item
552
+ */
553
+ onModalSubmitted: function() {
554
+ var modal = this.modal,
555
+ form = this.modalForm,
556
+ isNew = !this.value;
557
+
558
+ //Stop if there are validation errors
559
+ var error = form.validate();
560
+ if (error) return modal.preventClose();
561
+
562
+ //Store form value
563
+ this.value = form.getValue();
564
+
565
+ //Render item
566
+ this.renderSummary();
567
+
568
+ if (isNew) this.trigger('readyToAdd');
569
+
570
+ this.trigger('change', this);
571
+
572
+ this.onModalClosed();
573
+ },
574
+
575
+ /**
576
+ * Cleans up references, triggers events. To be called whenever the modal closes
577
+ */
578
+ onModalClosed: function() {
579
+ this.modal = null;
580
+ this.modalForm = null;
581
+
582
+ this.trigger('close', this);
583
+ this.trigger('blur', this);
584
+ },
585
+
586
+ getValue: function() {
587
+ return this.value;
588
+ },
589
+
590
+ setValue: function(value) {
591
+ this.value = value;
592
+ },
593
+
594
+ focus: function() {
595
+ if (this.hasFocus) return;
596
+
597
+ this.openEditor();
598
+ },
599
+
600
+ blur: function() {
601
+ if (!this.hasFocus) return;
602
+
603
+ if (this.modal) {
604
+ this.modal.trigger('cancel');
605
+ }
606
+ }
607
+ }, {
608
+ //STATICS
609
+ template: _.template('\
610
+ <div><%= summary %></div>\
611
+ ', null, Form.templateSettings),
612
+
613
+ //The modal adapter that creates and manages the modal dialog.
614
+ //Defaults to BootstrapModal (http://github.com/powmedia/backbone.bootstrap-modal)
615
+ //Can be replaced with another adapter that implements the same interface.
616
+ ModalAdapter: Backbone.BootstrapModal,
617
+
618
+ //Make the wait list for the 'ready' event before adding the item to the list
619
+ isAsync: true
620
+ });
621
+
622
+
623
+ Form.editors.List.Object = Form.editors.List.Modal.extend({
624
+ initialize: function () {
625
+ Form.editors.List.Modal.prototype.initialize.apply(this, arguments);
626
+
627
+ var schema = this.schema;
628
+
629
+ if (!schema.subSchema) throw new Error('Missing required option "schema.subSchema"');
630
+
631
+ this.nestedSchema = schema.subSchema;
632
+ }
633
+ });
634
+
635
+
636
+ Form.editors.List.NestedModel = Form.editors.List.Modal.extend({
637
+ initialize: function() {
638
+ Form.editors.List.Modal.prototype.initialize.apply(this, arguments);
639
+
640
+ var schema = this.schema;
641
+
642
+ if (!schema.model) throw new Error('Missing required option "schema.model"');
643
+
644
+ var nestedSchema = schema.model.prototype.schema;
645
+
646
+ this.nestedSchema = (_.isFunction(nestedSchema)) ? nestedSchema() : nestedSchema;
647
+ },
648
+
649
+ /**
650
+ * Returns the string representation of the object value
651
+ */
652
+ getStringValue: function() {
653
+ var schema = this.schema,
654
+ value = this.getValue();
655
+
656
+ if (_.isEmpty(value)) return null;
657
+
658
+ //If there's a specified toString use that
659
+ if (schema.itemToString) return schema.itemToString(value);
660
+
661
+ //Otherwise use the model
662
+ return new (schema.model)(value).toString();
663
+ }
664
+ });
665
+
666
+ })(Backbone.Form);
667
+
668
+
669
+ });