产品原型
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.

93 lines
3.3 KiB

4 years ago
  1. // ******* Recording MANAGER ******** //
  2. $axure.internal(function($ax) {
  3. var _recording = $ax.recording = {};
  4. $ax.recording.recordEvent = function(element, eventInfo, axEventObject, timeStamp) {
  5. var elementHtml = $jobj(element);
  6. var className = elementHtml.attr('class');
  7. var inputValue;
  8. if(className === 'ax_checkbox') {
  9. inputValue = elementHtml.find('#' + element + '_input')[0].checked;
  10. eventInfo.inputType = className;
  11. eventInfo.inputValue = inputValue;
  12. }
  13. if(className === 'ax_text_field') {
  14. inputValue = elementHtml.find('#' + element + '_input').val();
  15. eventInfo.inputType = className;
  16. eventInfo.inputValue = inputValue;
  17. }
  18. var scriptId = $ax.repeater.getScriptIdFromElementId(element);
  19. var diagramObjectPath = $ax.getPathFromScriptId(scriptId);
  20. var form = {
  21. recordingId: $ax.recording.recordingId,
  22. elementID: element,
  23. eventType: axEventObject.description,
  24. 'eventInfo': eventInfo,
  25. // eventObject: axEventObject,
  26. 'timeStamp': timeStamp,
  27. 'path': diagramObjectPath
  28. // ,
  29. // 'trigger': function() {
  30. // $ax.event.handleEvent(element, eventInfo, axEventObject);
  31. // return false;
  32. // }
  33. };
  34. $ax.messageCenter.postMessage('logEvent', form);
  35. };
  36. $ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
  37. };
  38. $ax.recording.recordingId = "";
  39. $ax.recording.recordingName = "";
  40. $ax.messageCenter.addMessageListener(function(message, data) {
  41. if(message === 'startRecording') {
  42. $ax.recording.maybeRecordEvent = $ax.recording.recordEvent;
  43. $ax.recording.recordingId = data.recordingId;
  44. $ax.recording.recordingName = data.recordingName;
  45. } else if(message === 'stopRecording') {
  46. $ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
  47. };
  48. }
  49. else if(message === 'playEvent') {
  50. var eventType = makeFirstLetterLower(data.eventType);
  51. var inputElement;
  52. var dObj = data.element === '' ? $ax.pageData.page : $ax.getObjectFromElementId(data.element);
  53. if(!data.axEventObject) {
  54. data.axEventObject = dObj && dObj.interactionMap && dObj.interactionMap[eventType];
  55. }
  56. data.eventInfo.thiswidget = $ax.getWidgetInfo(data.element);
  57. data.eventInfo.item = $ax.getItemInfo(data.element);
  58. if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_checkbox') {
  59. inputElement = $jobj(data.element + '_input');
  60. inputElement[0].checked = data.eventInfo.inputValue;
  61. }
  62. if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_text_field') {
  63. inputElement = $jobj(data.element + '_input');
  64. inputElement.val(data.eventInfo.inputValue);
  65. }
  66. $ax.event.handleEvent(data.element, data.eventInfo, data.axEventObject, false, true);
  67. }
  68. });
  69. var makeFirstLetterLower = function(eventName) {
  70. return eventName.substr(0, 1).toLowerCase() + eventName.substr(1);
  71. };
  72. });