model.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // ******* Object Model ******** //
  2. $axure.internal(function($ax) {
  3. var _implementations = {};
  4. var _initializeObject = function(type, obj) {
  5. $.extend(obj, _implementations[type]);
  6. };
  7. $ax.initializeObject = _initializeObject;
  8. var _model = $ax.model = {};
  9. _model.idsInRdo = function(rdoId, scriptIds) {
  10. var rdoScriptId = $ax.repeater.getScriptIdFromElementId(rdoId);
  11. var path = $ax.getPathFromScriptId(rdoScriptId);
  12. var rdoRepeater = $ax.getParentRepeaterFromScriptId(rdoScriptId);
  13. if(!scriptIds) scriptIds = [];
  14. $ax('*').each(function(obj, elementId) {
  15. // Make sure in same rdo
  16. var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
  17. var elementPath = $ax.getPathFromScriptId(scriptId);
  18. // This is because last part of path is for the obj itself.
  19. elementPath.pop();
  20. if(elementPath.length != path.length) return;
  21. for(var i = 0; i < path.length; i++) if(elementPath[i] != path[i]) return;
  22. // If object is in a panel, the panel will be hidden, so the obj doesn't have to be.
  23. if(obj.parentDynamicPanel) return;
  24. var repeater = $ax.getParentRepeaterFromScriptId(scriptId);
  25. if(repeater != rdoRepeater) return;
  26. if($ax.public.fn.IsReferenceDiagramObject(obj.type)) _model.idsInRdo(scriptId, scriptIds);
  27. else if(scriptIds.indexOf(scriptId) != -1) return;
  28. // Kind of complicated, but returning for isContained objects, hyperlinks, tabel cell, non-root tree nodes, and images in the tree.
  29. else if (obj.isContained || obj.type == 'hyperlink' || $ax.public.fn.IsTableCell(obj.type) ||
  30. ($ax.public.fn.IsTreeNodeObject(obj.type) && !$jobj(elementId).hasClass('treeroot')) ||
  31. ($ax.public.fn.IsImageBox(obj.type) && $ax.public.fn.IsTreeNodeObject(obj.parent.type))) return;
  32. else scriptIds.push(scriptId);
  33. });
  34. return scriptIds;
  35. };
  36. });