图书馆智能管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
8.7 KiB

5 months ago
  1. /* Licensed under the Apache License, Version 2.0 (the "License");
  2. * you may not use this file except in compliance with the License.
  3. * You may obtain a copy of the License at
  4. *
  5. * http://www.apache.org/licenses/LICENSE-2.0
  6. *
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. var FLOWABLE_EDITOR_TOUR = {
  14. /*
  15. * General 'getting started' tutorial for the Editor.
  16. */
  17. gettingStarted: function($scope, $translate, $q, useLocalStorage) {
  18. var userName;
  19. if ($scope.account.firstName) {
  20. userName = $scope.account.firstName;
  21. } else {
  22. userName = $scope.account.fullname;
  23. }
  24. $q.all([
  25. $translate('TOUR.WELCOME-TITLE', {userName: userName}), $translate('TOUR.WELCOME-CONTENT'),
  26. $translate('TOUR.PALETTE-TITLE'), $translate('TOUR.PALETTE-CONTENT'),
  27. $translate('TOUR.CANVAS-TITLE'), $translate('TOUR.CANVAS-CONTENT'),
  28. $translate('TOUR.DRAGDROP-TITLE'), $translate('TOUR.DRAGDROP-CONTENT'),
  29. $translate('TOUR.PROPERTIES-TITLE'), $translate('TOUR.PROPERTIES-CONTENT'),
  30. $translate('TOUR.TOOLBAR-TITLE'), $translate('TOUR.TOOLBAR-CONTENT'),
  31. $translate('TOUR.END-TITLE'), $translate('TOUR.END-CONTENT')
  32. ]).then(function(translations) {
  33. // We're using a hack here due to https://github.com/sorich87/bootstrap-tour/issues/85:
  34. // when clicking next in the tour, it always sets the 'display' css property to 'none'
  35. // The hack is simple: before the next step is shown, we reset the 'display' property to 'block'
  36. var tourStepDomElements = ['body', '#paletteHelpWrapper', '#canvasHelpWrapper', '#propertiesHelpWrapper', '#editor-header'];
  37. var tour = new Tour({
  38. name: 'activitiEditorTour',
  39. storage: (useLocalStorage ? window.localStorage : false),
  40. container: 'body',
  41. backdrop: true,
  42. keyboard: true,
  43. steps: [
  44. {
  45. orphan: true,
  46. title: translations[0],
  47. content: translations[1],
  48. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false, 300),
  49. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[0])
  50. },
  51. {
  52. element: tourStepDomElements[1],
  53. title: translations[2],
  54. content: translations[3],
  55. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false, 400, 'images/tour/open-group.gif'),
  56. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[1])
  57. },
  58. {
  59. element: tourStepDomElements[2],
  60. title: translations[4],
  61. content: translations[5],
  62. placement: 'left',
  63. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false),
  64. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[2])
  65. },
  66. {
  67. orphan: true,
  68. title: translations[6],
  69. content: translations[7],
  70. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false, 720, 'images/tour/tour-dnd.gif'),
  71. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[0])
  72. },
  73. {
  74. element: tourStepDomElements[3],
  75. title: translations[8],
  76. content: translations[9],
  77. placement: 'top',
  78. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false, 400),
  79. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[3])
  80. },
  81. {
  82. element: tourStepDomElements[4],
  83. title: translations[10],
  84. content: translations[11],
  85. placement: 'bottom',
  86. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, true, false, 400),
  87. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[4])
  88. },
  89. {
  90. orphan: true,
  91. title: translations[12],
  92. content: translations[13],
  93. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, false, true, 400),
  94. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[0])
  95. }
  96. ],
  97. onEnd: FLOWABLE_EDITOR_TOUR._buildOnEndFunction(tourStepDomElements)
  98. });
  99. tour.init();
  100. tour.start();
  101. })
  102. },
  103. /*
  104. * Tutorial showing how to use the bendpoint functionality for sequenceflow
  105. */
  106. sequenceFlowBendpoint: function($scope, $translate, $q, useLocalStorage) {
  107. $q.all([
  108. $translate('FEATURE-TOUR.BENDPOINT.TITLE'), $translate('FEATURE-TOUR.BENDPOINT.DESCRIPTION')
  109. ]).then(function(translations) {
  110. // We're using a hack here due to https://github.com/sorich87/bootstrap-tour/issues/85:
  111. // when clicking next in the tour, it always sets the 'display' css property to 'none'
  112. // The hack is simple: before the next step is shown, we reset the 'display' property to 'block'
  113. var tourStepDomElements = ['body'];
  114. var tour = new Tour({
  115. name: 'bendpointTour',
  116. storage: (useLocalStorage ? window.localStorage : false),
  117. container: 'body',
  118. backdrop: true,
  119. keyboard: true,
  120. steps: [
  121. {
  122. orphan: true,
  123. title: translations[0],
  124. content: translations[1],
  125. template: FLOWABLE_EDITOR_TOUR._buildStepTemplate(false, false, true, 500, 'images/tour/sequenceflow-bendpoint.gif'),
  126. onNext: FLOWABLE_EDITOR_TOUR._buildOnNextFunction(tourStepDomElements[0])
  127. }
  128. ],
  129. onEnd: FLOWABLE_EDITOR_TOUR._buildOnEndFunction(tourStepDomElements)
  130. });
  131. tour.init();
  132. tour.start();
  133. })
  134. },
  135. _buildStepTemplate : function (addPrevButton, addNextButton, addEndTourButton, optionalForcedWidth, image) {
  136. var width = 200;
  137. if (optionalForcedWidth) {
  138. width = optionalForcedWidth;
  139. }
  140. var template =
  141. '<div class=\'popover tour\' style=\'max-width:' + width + 'px\'>' +
  142. '<div class=\'arrow\'></div>' +
  143. '<h3 class=\'popover-title\'></h3>' +
  144. '<div class=\'popover-content\'></div>' +
  145. '<div class=\'popover-navigation\'>';
  146. if (image) {
  147. template = template + '<div><img src=\'' + image + '\' style=\'border 1px solid black;margin:5px 0 5px 0;\'></img></div>';
  148. }
  149. if (addPrevButton) {
  150. template = template + '<button class=\'btn btn-sm btn-default \' data-role=\'prev\'>« Prev</button>';
  151. }
  152. if (addNextButton) {
  153. template = template + '<button class=\'btn btn-sm btn-default\' data-role=\'next\' style=\'float:right\'">Next »</button>';
  154. }
  155. if (addEndTourButton) {
  156. template = template + '<button class=\'btn btn-warning btn-sm\' data-role=\'end\' style=\'float:right\'">Got it!</button>';
  157. }
  158. template = template + '</div>' + '</nav>' + '</div>';
  159. return template;
  160. },
  161. _buildOnNextFunction: function(selector) {
  162. return function () {
  163. jQuery(selector).each(function (i, obj) {
  164. obj.style.display = 'block';
  165. })
  166. };
  167. },
  168. _buildOnEndFunction: function(selectors) {
  169. return function () {
  170. for (var elementsToResetIndex = 0; elementsToResetIndex < selectors.length; elementsToResetIndex++) {
  171. jQuery(selectors[elementsToResetIndex]).each(function (i, obj) {
  172. obj.style.display = 'block';
  173. });
  174. }
  175. }
  176. }
  177. };