增加docke部署
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,507 @@
|
||||
$axure.internal(function($ax) {
|
||||
$ax.adaptive = {};
|
||||
|
||||
$axure.utils.makeBindable($ax.adaptive, ["viewChanged"]);
|
||||
|
||||
var _auto = true;
|
||||
var _autoIsHandledBySidebar = false;
|
||||
|
||||
var _views;
|
||||
var _idToView;
|
||||
var _enabledViews = [];
|
||||
|
||||
var _initialViewToLoad;
|
||||
var _initialViewSizeToLoad;
|
||||
|
||||
var _loadFinished = false;
|
||||
$ax.adaptive.loadFinished = function() {
|
||||
if(_loadFinished) return;
|
||||
_loadFinished = true;
|
||||
if($ax.adaptive.currentViewId) $ax.viewChangePageAndMasters();
|
||||
else $ax.postAdaptiveViewChanged();
|
||||
};
|
||||
|
||||
var _handleResize = function(forceSwitchTo) {
|
||||
if(!_auto) return;
|
||||
if(_auto && _autoIsHandledBySidebar && !forceSwitchTo) return;
|
||||
|
||||
var $window = $(window);
|
||||
var height = $window.height();
|
||||
var width = $window.width();
|
||||
|
||||
var toView = _getAdaptiveView(width, height);
|
||||
var toViewId = toView && toView.id;
|
||||
|
||||
_switchView(toViewId, forceSwitchTo);
|
||||
};
|
||||
|
||||
var _setAuto = $ax.adaptive.setAuto = function(val) {
|
||||
if(_auto != val) {
|
||||
_auto = Boolean(val);
|
||||
}
|
||||
};
|
||||
|
||||
var _setLineImage = function(id, imageUrl) {
|
||||
var imageQuery = $jobj(id).attr('src', imageUrl);
|
||||
if(imageUrl.indexOf(".png") > -1) $ax.utils.fixPng(imageQuery[0]);
|
||||
};
|
||||
|
||||
var _switchView = function (viewId, forceSwitchTo) {
|
||||
if(!$ax.pageData.isAdaptiveEnabled) return;
|
||||
|
||||
var previousViewId = $ax.adaptive.currentViewId;
|
||||
if(typeof previousViewId == 'undefined') previousViewId = '';
|
||||
if(typeof viewId == 'undefined') viewId = '';
|
||||
if (viewId == previousViewId) {
|
||||
if(forceSwitchTo) $ax.postAdaptiveViewChanged(forceSwitchTo);
|
||||
return;
|
||||
}
|
||||
|
||||
$ax('*').each(function(obj, elementId) {
|
||||
if (!$ax.public.fn.IsTreeNodeObject(obj.type)) return;
|
||||
if(!obj.hasOwnProperty('isExpanded')) return;
|
||||
|
||||
var query = $ax('#' + elementId);
|
||||
var defaultExpanded = obj.isExpanded;
|
||||
|
||||
query.expanded(defaultExpanded);
|
||||
});
|
||||
|
||||
// reset all the positioning on the style tags, including size and transformation
|
||||
$axure('*').each(function(diagramObject, elementId) {
|
||||
var element = document.getElementById(elementId);
|
||||
if(element && !diagramObject.isContained) {
|
||||
var resetCss = {
|
||||
top: "", left: "", width: "", height: "", opacity: "",
|
||||
transform: "", webkitTransform: "", MozTransform: "", msTransform: "", OTransform: ""
|
||||
};
|
||||
var query = $(element);
|
||||
var children = query.children();
|
||||
var sketchyImage = $('#' + $ax.repeater.applySuffixToElementId(elementId, '_image_sketch'));
|
||||
var textChildren = query.children('div.text');
|
||||
|
||||
query.css(resetCss);
|
||||
if(children) children.css(resetCss);
|
||||
if(sketchyImage) sketchyImage.css(resetCss);
|
||||
if(textChildren) textChildren.css(resetCss);
|
||||
|
||||
$ax.dynamicPanelManager.resetFixedPanel(diagramObject, element);
|
||||
$ax.dynamicPanelManager.resetAdaptivePercentPanel(diagramObject, element);
|
||||
}
|
||||
});
|
||||
|
||||
$ax.adaptive.currentViewId = viewId; // we need to set this so the enabled and selected styles will apply properly
|
||||
if(previousViewId) {
|
||||
$ax.style.clearAdaptiveStyles();
|
||||
$('*').removeClass(previousViewId);
|
||||
} else {
|
||||
$ax.style.reselectElements();
|
||||
}
|
||||
|
||||
$axure('*').each(function(obj, elementId) {
|
||||
$ax.style.updateElementIdImageStyle(elementId); // When image override exists, fix styling/borders
|
||||
});
|
||||
|
||||
// reset all the images only if we're going back to the default view
|
||||
if(!viewId) {
|
||||
_updateInputVisibility('', $axure('*'));
|
||||
$axure('*').each(function(diagramObject, elementId) {
|
||||
$ax.placeholderManager.refreshPlaceholder(elementId);
|
||||
|
||||
var images = diagramObject.images;
|
||||
if(diagramObject.type == 'horizontalLine' || diagramObject.type == 'verticalLine') {
|
||||
var startImg = images['start~'];
|
||||
_setLineImage(elementId + "_start", startImg);
|
||||
var endImg = images['end~'];
|
||||
_setLineImage(elementId + "_end", endImg);
|
||||
var lineImg = images['line~'];
|
||||
_setLineImage(elementId + "_line", lineImg);
|
||||
} else if(diagramObject.type == $ax.constants.CONNECTOR_TYPE) {
|
||||
_setAdaptiveConnectorImages(elementId, images, '');
|
||||
} else if(images) {
|
||||
if (diagramObject.generateCompound) {
|
||||
|
||||
if($ax.style.IsWidgetDisabled(elementId)) {
|
||||
disabledImage = _getImageWithTag(images, 'disabled~');
|
||||
if(disabledImage) $ax.style.applyImage(elementId, disabledImage, 'disabled');
|
||||
return;
|
||||
}
|
||||
if($ax.style.IsWidgetSelected(elementId)) {
|
||||
selectedImage = _getImageWithTag(images, 'selected~');
|
||||
if(selectedImage) $ax.style.applyImage(elementId, selectedImage, 'selected');
|
||||
return;
|
||||
}
|
||||
$ax.style.applyImage(elementId, _getImageWithTag(images, 'normal~'));
|
||||
} else {
|
||||
if ($ax.style.IsWidgetDisabled(elementId)) {
|
||||
var disabledImage = $ax.style.getElementImageOverride(elementId, 'disabled') || images['disabled~'];
|
||||
if (disabledImage) $ax.style.applyImage(elementId, disabledImage, 'disabled');
|
||||
return;
|
||||
}
|
||||
if ($ax.style.IsWidgetSelected(elementId)) {
|
||||
var selectedImage = $ax.style.getElementImageOverride(elementId, 'selected') || images['selected~'];
|
||||
if (selectedImage) $ax.style.applyImage(elementId, selectedImage, 'selected');
|
||||
return;
|
||||
}
|
||||
$ax.style.applyImage(elementId, $ax.style.getElementImageOverride(elementId, 'normal') || images['normal~']);
|
||||
}
|
||||
}
|
||||
|
||||
var child = $jobj(elementId).children('.text');
|
||||
if(child.length) $ax.style.transformTextWithVerticalAlignment(child[0].id, function() { });
|
||||
});
|
||||
// we have to reset visibility if we aren't applying a new view
|
||||
$ax.visibility.resetLimboAndHiddenToDefaults();
|
||||
$ax.repeater.refreshAllRepeaters();
|
||||
$ax.dynamicPanelManager.updateAllFitPanels();
|
||||
$ax.dynamicPanelManager.updatePercentPanelCache($ax('*'));
|
||||
} else {
|
||||
$ax.visibility.clearLimboAndHidden();
|
||||
_applyView(viewId);
|
||||
$ax.repeater.refreshAllRepeaters();
|
||||
}
|
||||
|
||||
$ax.adaptive.triggerEvent('viewChanged', {});
|
||||
if(_loadFinished) $ax.viewChangePageAndMasters(forceSwitchTo);
|
||||
};
|
||||
|
||||
var _getImageWithTag = function(image, tag) {
|
||||
var flattened = {};
|
||||
for (var component in image) {
|
||||
var componentImage = image[component][tag];
|
||||
if(componentImage) flattened[component] = componentImage;
|
||||
}
|
||||
return flattened;
|
||||
}
|
||||
|
||||
// gets if input is hidden due to sketch
|
||||
var BORDER_WIDTH = "borderWidth";
|
||||
var COLOR_STYLE = "colorStyle";
|
||||
var SKETCH_FACTOR = "sketchFactor";
|
||||
var _areInputsHidden = function(viewId) {
|
||||
var chain = _getAdaptiveIdChain(viewId);
|
||||
var page = $ax.pageData.page;
|
||||
var adaptiveStyles = page.adaptiveStyles;
|
||||
// keep track of props that are not sketchy, as you continue to climb up your parents;
|
||||
var notSketch = [];
|
||||
for(var i = chain.length - 1; i >= -1; i--) {
|
||||
var style = i == -1 ? page.style : adaptiveStyles[chain[i]];
|
||||
if(notSketch.indexOf(BORDER_WIDTH) == -1 && style.hasOwnProperty(BORDER_WIDTH)) {
|
||||
if(style[BORDER_WIDTH] != 0) return true;
|
||||
notSketch.push(BORDER_WIDTH);
|
||||
}
|
||||
if(notSketch.indexOf(COLOR_STYLE) == -1 && style.hasOwnProperty(COLOR_STYLE)) {
|
||||
if(style[COLOR_STYLE] != 'appliedColor') return true;
|
||||
notSketch.push(COLOR_STYLE);
|
||||
}
|
||||
if(notSketch.indexOf(SKETCH_FACTOR) == -1 && style.hasOwnProperty(SKETCH_FACTOR)) {
|
||||
if(style[SKETCH_FACTOR] != 0) return true;
|
||||
notSketch.push(SKETCH_FACTOR);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var _updateInputVisibility = function(viewId, query) {
|
||||
var func = _areInputsHidden(viewId) ? 'addClass' : 'removeClass';
|
||||
query.each(function(obj, elementId) {
|
||||
var input = $jobj($ax.repeater.applySuffixToElementId(elementId, '_input'));
|
||||
if(input.length == 0) return;
|
||||
input[func]('form_sketch');
|
||||
});
|
||||
};
|
||||
|
||||
// gets the inheritance chain of a particular view.
|
||||
var _getAdaptiveIdChain = $ax.adaptive.getAdaptiveIdChain = function(viewId) {
|
||||
if(!viewId) return [];
|
||||
var view = _idToView[viewId];
|
||||
var chain = [];
|
||||
var current = view;
|
||||
while(current) {
|
||||
chain[chain.length] = current.id;
|
||||
current = _idToView[current.baseViewId];
|
||||
}
|
||||
return chain.reverse();
|
||||
};
|
||||
|
||||
var _getPageStyle = $ax.adaptive.getPageStyle = function() {
|
||||
var currentViewId = $ax.adaptive.currentViewId;
|
||||
var adaptiveChain = _getAdaptiveIdChain(currentViewId);
|
||||
|
||||
var currentStyle = $.extend({}, $ax.pageData.page.style);
|
||||
for(var i = 0; i < adaptiveChain.length; i++) {
|
||||
var viewId = adaptiveChain[i];
|
||||
$.extend(currentStyle, $ax.pageData.page.adaptiveStyles[viewId]);
|
||||
}
|
||||
|
||||
return currentStyle;
|
||||
};
|
||||
|
||||
var _setAdaptiveLineImages = function(elementId, images, viewIdChain) {
|
||||
for(var i = viewIdChain.length - 1; i >= 0; i--) {
|
||||
var viewId = viewIdChain[i];
|
||||
var startImg = images['start~' + viewId];
|
||||
if(startImg) {
|
||||
_setLineImage(elementId + "_start", startImg);
|
||||
var endImg = images['end~' + viewId];
|
||||
_setLineImage(elementId + "_end", endImg);
|
||||
var lineImg = images['line~' + viewId];
|
||||
_setLineImage(elementId + "_line", lineImg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var _setAdaptiveConnectorImages = function (elementId, images, view) {
|
||||
var conn = $jobj(elementId);
|
||||
var count = conn.children().length-1; // -1 for rich text panel
|
||||
for(var i = 0; i < count; i++) {
|
||||
var img = images['' + i + '~' + view];
|
||||
$jobj(elementId + '_seg' + i).attr('src', img);
|
||||
}
|
||||
};
|
||||
|
||||
var _applyView = $ax.adaptive.applyView = function(viewId, query) {
|
||||
var limboIds = {};
|
||||
var hiddenIds = {};
|
||||
|
||||
var jquery;
|
||||
if(query) {
|
||||
jquery = query.jQuery();
|
||||
jquery = jquery.add(jquery.find('*'));
|
||||
var jqueryAnn = $ax.annotation.jQueryAnn(query);
|
||||
jquery = jquery.add(jqueryAnn);
|
||||
} else {
|
||||
jquery = $('*');
|
||||
query = $ax('*');
|
||||
}
|
||||
jquery.addClass(viewId);
|
||||
_updateInputVisibility(viewId, query);
|
||||
var viewIdChain = _getAdaptiveIdChain(viewId);
|
||||
// this could be made more efficient by computing it only once per object
|
||||
query.each(function(diagramObject, elementId) {
|
||||
_applyAdaptiveViewOnObject(diagramObject, elementId, viewIdChain, viewId, limboIds, hiddenIds);
|
||||
});
|
||||
|
||||
$ax.visibility.addLimboAndHiddenIds(limboIds, hiddenIds, query);
|
||||
$ax.dynamicPanelManager.updateAllFitPanels();
|
||||
$ax.dynamicPanelManager.updatePercentPanelCache(query);
|
||||
};
|
||||
|
||||
var _applyAdaptiveViewOnObject = function(diagramObject, elementId, viewIdChain, viewId, limboIds, hiddenIds) {
|
||||
var adaptiveChain = [];
|
||||
for(var i = 0; i < viewIdChain.length; i++) {
|
||||
var viewId = viewIdChain[i];
|
||||
var viewStyle = diagramObject.adaptiveStyles[viewId];
|
||||
if(viewStyle) {
|
||||
adaptiveChain[adaptiveChain.length] = viewStyle;
|
||||
if (viewStyle.size) $ax.public.fn.convertToSingleImage($jobj(elementId));
|
||||
}
|
||||
}
|
||||
|
||||
var state = $ax.style.generateState(elementId);
|
||||
|
||||
// set the image
|
||||
var images = diagramObject.images;
|
||||
if(images) {
|
||||
if(diagramObject.type == 'horizontalLine' || diagramObject.type == 'verticalLine') {
|
||||
_setAdaptiveLineImages(elementId, images, viewIdChain);
|
||||
} else if (diagramObject.type == $ax.constants.CONNECTOR_TYPE) {
|
||||
_setAdaptiveConnectorImages(elementId, images, viewId);
|
||||
} else if (diagramObject.generateCompound) {
|
||||
var compoundUrl = _matchImageCompound(diagramObject, elementId, viewIdChain, state);
|
||||
if (compoundUrl) $ax.style.applyImage(elementId, compoundUrl, state);
|
||||
}else {
|
||||
var imgUrl = _matchImage(elementId, images, viewIdChain, state);
|
||||
if(imgUrl) $ax.style.applyImage(elementId, imgUrl, state);
|
||||
}
|
||||
// for(var i = viewIdChain.length - 1; i >= 0; i--) {
|
||||
// var viewId = viewIdChain[i];
|
||||
// var imgUrl = $ax.style.getElementImageOverride(elementId, state) || images[state + '~' + viewId] || images['normal~' + viewId];
|
||||
// if(imgUrl) {
|
||||
// $ax.style.applyImage(elementId, imgUrl, state);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
// addaptive override style (not including default style props)
|
||||
var adaptiveStyle = $ax.style.computeAllOverrides(elementId, undefined, state, viewId);
|
||||
|
||||
// this style INCLUDES the object's my style
|
||||
var compoundStyle = $.extend({}, diagramObject.style, adaptiveStyle);
|
||||
|
||||
//$ax.style.setAdaptiveStyle(elementId, adaptiveStyle);
|
||||
if(!diagramObject.isContained) {
|
||||
$ax.style.setAdaptiveStyle(elementId, adaptiveStyle);
|
||||
}
|
||||
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
if(compoundStyle.limbo && !diagramObject.isContained) limboIds[scriptId] = true;
|
||||
// sigh, javascript. we need the === here because undefined means not overriden
|
||||
if(compoundStyle.visible === false) hiddenIds[scriptId] = true;
|
||||
};
|
||||
|
||||
var _matchImage = function(id, images, viewIdChain, state) {
|
||||
var override = $ax.style.getElementImageOverride(id, state);
|
||||
if(override) return override;
|
||||
|
||||
if(!images) return undefined;
|
||||
|
||||
// first check all the images for this state
|
||||
for(var i = viewIdChain.length - 1; i >= 0; i--) {
|
||||
var viewId = viewIdChain[i];
|
||||
var img = images[state + "~" + viewId];
|
||||
if(img) return img;
|
||||
}
|
||||
// check for the default state style
|
||||
var defaultStateImage = images[state + '~'];
|
||||
if(defaultStateImage) return defaultStateImage;
|
||||
|
||||
state = $ax.style.progessState(state);
|
||||
if(state) return _matchImage(id, images, viewIdChain, state);
|
||||
|
||||
// SHOULD NOT REACH HERE! NORMAL SHOULD ALWAYS CATCH AT THE DEFAULT!
|
||||
return images['normal~']; // this is the default
|
||||
};
|
||||
|
||||
var _matchImageCompound = function(diagramObject, id, viewIdChain, state) {
|
||||
var images = [];
|
||||
for(var i = 0; i < diagramObject.compoundChildren.length; i++) {
|
||||
var component = diagramObject.compoundChildren[i];
|
||||
images[component] = _matchImage(id, diagramObject.images[component], viewIdChain, state);
|
||||
}
|
||||
return images;
|
||||
};
|
||||
|
||||
|
||||
|
||||
$ax.adaptive.getImageForStateAndView = function(id, state) {
|
||||
var viewIdChain = _getAdaptiveIdChain($ax.adaptive.currentViewId);
|
||||
var diagramObject = $ax.getObjectFromElementId(id);
|
||||
if (diagramObject.generateCompound) return _matchImageCompound(diagramObject, id, viewIdChain, state);
|
||||
else return _matchImage(id, diagramObject.images, viewIdChain, state);
|
||||
};
|
||||
|
||||
var _getAdaptiveView = function(winWidth, winHeight) {
|
||||
var _isViewOneGreaterThanTwo = function(view1, view2) {
|
||||
return view1.size.width > view2.size.width || (view1.size.width == view2.size.width && view1.size.height > view2.size.height);
|
||||
};
|
||||
|
||||
var _isViewOneLessThanTwo = function(view1, view2) {
|
||||
var width2 = view2.size.width || 1000000; // artificially large number
|
||||
var height2 = view2.size.height || 1000000;
|
||||
|
||||
var width1 = view1.size.width || 1000000;
|
||||
var height1 = view1.size.height || 1000000;
|
||||
|
||||
return width1 < width2 || (width1 == width2 && height1 < height2);
|
||||
};
|
||||
|
||||
var _isWindowGreaterThanView = function(view, width, height) {
|
||||
return width >= view.size.width && height >= view.size.height;
|
||||
};
|
||||
|
||||
var _isWindowLessThanView = function(view1, width, height) {
|
||||
var viewWidth = view1.size.width || 1000000;
|
||||
var viewHeight = view1.size.height || 1000000;
|
||||
|
||||
return width <= viewWidth && height <= viewHeight;
|
||||
};
|
||||
|
||||
var greater = undefined;
|
||||
var less = undefined;
|
||||
|
||||
for(var i = 0; i < _enabledViews.length; i++) {
|
||||
var view = _enabledViews[i];
|
||||
if(view.condition == ">=") {
|
||||
if(_isWindowGreaterThanView(view, winWidth, winHeight)) {
|
||||
if(!greater || _isViewOneGreaterThanTwo(view, greater)) greater = view;
|
||||
}
|
||||
} else {
|
||||
if(_isWindowLessThanView(view, winWidth, winHeight)) {
|
||||
if(!less || _isViewOneLessThanTwo(view, less)) less = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return less || greater;
|
||||
};
|
||||
|
||||
var _isAdaptiveInitialized = function() {
|
||||
return typeof _idToView != 'undefined';
|
||||
};
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
//If the adaptive plugin hasn't been initialized yet then
|
||||
//save the view to load so that it can get set when initialize occurs
|
||||
if(message == 'switchAdaptiveView') {
|
||||
var href = window.location.href.split('#')[0];
|
||||
var lastSlash = href.lastIndexOf('/');
|
||||
href = href.substring(lastSlash + 1);
|
||||
if(href != data.src) return;
|
||||
|
||||
var view = data.view == 'auto' ? undefined : (data.view == 'default' ? '' : data.view);
|
||||
|
||||
if(!_isAdaptiveInitialized()) {
|
||||
_initialViewToLoad = view;
|
||||
} else _handleLoadViewId(view);
|
||||
} else if(message == 'setAdaptiveViewForSize') {
|
||||
_autoIsHandledBySidebar = true;
|
||||
if(!_isAdaptiveInitialized()) {
|
||||
_initialViewSizeToLoad = data;
|
||||
} else _handleSetViewForSize(data.width, data.height);
|
||||
}
|
||||
});
|
||||
|
||||
$ax.adaptive.setAdaptiveView = function(view) {
|
||||
var viewIdForSitemapToUnderstand = view == 'auto' ? undefined : (view == 'default' ? '' : view);
|
||||
|
||||
if(!_isAdaptiveInitialized()) {
|
||||
_initialViewToLoad = viewIdForSitemapToUnderstand;
|
||||
} else _handleLoadViewId(viewIdForSitemapToUnderstand);
|
||||
};
|
||||
|
||||
$ax.adaptive.initialize = function() {
|
||||
_views = $ax.document.adaptiveViews;
|
||||
_idToView = {};
|
||||
|
||||
if(_views && _views.length > 0) {
|
||||
for(var i = 0; i < _views.length; i++) {
|
||||
var view = _views[i];
|
||||
_idToView[view.id] = view;
|
||||
}
|
||||
|
||||
var enabledViewIds = $ax.document.configuration.enabledViewIds;
|
||||
for(var i = 0; i < enabledViewIds.length; i++) {
|
||||
_enabledViews[_enabledViews.length] = _idToView[enabledViewIds[i]];
|
||||
}
|
||||
|
||||
if(_autoIsHandledBySidebar && _initialViewSizeToLoad) _handleSetViewForSize(_initialViewSizeToLoad.width, _initialViewSizeToLoad.height);
|
||||
else _handleLoadViewId(_initialViewToLoad);
|
||||
}
|
||||
|
||||
$axure.resize(function(e) {
|
||||
_handleResize();
|
||||
$ax.postResize(e); //window resize fires after view changed
|
||||
});
|
||||
};
|
||||
|
||||
var _handleLoadViewId = function (loadViewId, forceSwitchTo) {
|
||||
if(typeof loadViewId != 'undefined') {
|
||||
_setAuto(false);
|
||||
_switchView(loadViewId != 'default' ? loadViewId : '', forceSwitchTo);
|
||||
} else {
|
||||
_setAuto(true);
|
||||
_handleResize(forceSwitchTo);
|
||||
}
|
||||
};
|
||||
|
||||
var _handleSetViewForSize = function (width, height) {
|
||||
if(!_auto) return;
|
||||
|
||||
var toView = _getAdaptiveView(width, height);
|
||||
var toViewId = toView && toView.id;
|
||||
_switchView(toViewId);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,176 @@
|
||||
// ******* Annotation MANAGER ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var NOTE_SIZE = 10;
|
||||
|
||||
var _annotationManager = $ax.annotation = {};
|
||||
|
||||
var _updateLinkLocations = $ax.annotation.updateLinkLocations = function(textId) {
|
||||
var diagramObject = $ax.getObjectFromElementId(textId);
|
||||
var rotation = (diagramObject && diagramObject.style.rotation);
|
||||
var shapeId = $ax.style.GetShapeIdFromText(textId);
|
||||
|
||||
//we have to do this because webkit reports the post-transform position but when you set
|
||||
//positions it's pre-transform
|
||||
if(WEBKIT && rotation) {
|
||||
//we can dynamiclly rotate a widget now, show need to remember the transform rather than just remove it
|
||||
//here jquery.css will return 'none' if element is display none
|
||||
var oldShapeTransform = document.getElementById(shapeId).style['-webkit-transform'];
|
||||
var oldTextTransform = document.getElementById(textId).style['-webkit-transform'];
|
||||
$('#' + shapeId).css('-webkit-transform', 'scale(1)');
|
||||
$('#' + textId).css('-webkit-transform', 'scale(1)');
|
||||
}
|
||||
|
||||
$('#' + textId).find('span[id$="_ann"]').each(function(index, value) {
|
||||
var elementId = value.id.replace('_ann', '');
|
||||
|
||||
var annPos = $(value).position();
|
||||
var left = annPos.left - NOTE_SIZE;
|
||||
var top = annPos.top;
|
||||
|
||||
$('#' + elementId + 'Note').css('left', left).css('top', top);
|
||||
});
|
||||
|
||||
//undo the transform reset
|
||||
if(WEBKIT && rotation) {
|
||||
$('#' + shapeId).css('-webkit-transform', oldShapeTransform || '');
|
||||
$('#' + textId).css('-webkit-transform', oldTextTransform || '');
|
||||
}
|
||||
};
|
||||
|
||||
var dialogs = {};
|
||||
$ax.annotation.ToggleWorkflow = function(event, id, width, height) {
|
||||
|
||||
if(dialogs[id]) {
|
||||
var $dialog = dialogs[id];
|
||||
// reset the dialog
|
||||
dialogs[id] = undefined;
|
||||
if($dialog.dialog("isOpen")) {
|
||||
$dialog.dialog("close");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we'll need to save the scroll position just for stupid IE which will skip otherwise
|
||||
var win = $(window);
|
||||
var scrollY = win.scrollTop();
|
||||
var scrollX = win.scrollLeft();
|
||||
|
||||
var bufferH = 10;
|
||||
var bufferV = 10;
|
||||
var blnLeft = false;
|
||||
var blnAbove = false;
|
||||
var sourceTop = event.pageY - scrollY;
|
||||
var sourceLeft = event.pageX - scrollX;
|
||||
|
||||
if(sourceLeft > width + bufferH) {
|
||||
blnLeft = true;
|
||||
}
|
||||
if(sourceTop > height + bufferV) {
|
||||
blnAbove = true;
|
||||
}
|
||||
|
||||
var top = 0;
|
||||
var left = 0;
|
||||
if(blnAbove) top = sourceTop - height - 20;
|
||||
else top = sourceTop + 10;
|
||||
if(blnLeft) left = sourceLeft - width - 4;
|
||||
else left = sourceLeft - 6;
|
||||
|
||||
$ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
|
||||
if(IE_10_AND_BELOW) height += 50;
|
||||
|
||||
var dObj = $ax.getObjectFromElementId(id);
|
||||
var ann = dObj.annotation;
|
||||
var $dialog = $('<div></div>')
|
||||
.appendTo('body')
|
||||
.html($ax.legacy.GetAnnotationHtml(ann))
|
||||
.dialog({
|
||||
title: dObj.label,
|
||||
width: width,
|
||||
height: height,
|
||||
minHeight: 150,
|
||||
zIndex: $ax.globals.MaxZIndex,
|
||||
position: [left, top],
|
||||
dialogClass: 'dialogFix',
|
||||
autoOpen: false
|
||||
});
|
||||
$dialog.parent().appendTo('#base');
|
||||
$dialog.dialog('open');
|
||||
dialogs[id] = $dialog;
|
||||
|
||||
// scroll ... just for IE
|
||||
window.scrollTo(scrollX, scrollY);
|
||||
};
|
||||
|
||||
$ax.annotation.InitializeAnnotations = function (query) {
|
||||
if(!$ax.document.configuration.showAnnotations) return;
|
||||
|
||||
query.each(function(dObj, elementId) {
|
||||
if(!dObj.annotation) return;
|
||||
|
||||
if(dObj.type == 'hyperlink') {
|
||||
var textId = $ax.style.GetTextIdFromLink(elementId);
|
||||
|
||||
var elementIdQuery = $('#' + elementId);
|
||||
elementIdQuery.after("<span id='" + elementId + "_ann'>​</span>");
|
||||
|
||||
if($ax.document.configuration.useLabels) {
|
||||
var label = $('#' + elementId).attr("data-label");
|
||||
if(!label || label == "") label = "?";
|
||||
$('#' + textId).append("<div id='" + elementId + "Note' class='annnotelabel' >" + label + "</div>");
|
||||
} else {
|
||||
$('#' + textId).append("<div id='" + elementId + "Note' class='annnoteimage' ></div>");
|
||||
}
|
||||
$('#' + elementId + 'Note').click(function(e) {
|
||||
$ax.annotation.ToggleWorkflow(e, elementId, 300, 200, false);
|
||||
return false;
|
||||
});
|
||||
|
||||
_updateLinkLocations(textId);
|
||||
} else {
|
||||
if($ax.document.configuration.useLabels) {
|
||||
var label = $('#' + elementId).attr("data-label");
|
||||
if(!label || label == "") label = "?";
|
||||
$('#' + elementId + "_ann").append("<div id='" + elementId + "Note' class='annnotelabel'>" + label + "</div>");
|
||||
} else {
|
||||
$('#' + elementId + "_ann").append("<div id='" + elementId + "Note' class='annnoteimage'></div>");
|
||||
}
|
||||
$('#' + elementId + 'Note').click(function(e) {
|
||||
$ax.annotation.ToggleWorkflow(e, elementId, 300, 200, false);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
$('#' + elementId + 'Note.annnoteimage').append("<div class='annnoteline'></div><div class='annnoteline'></div><div class='annnoteline'></div>");
|
||||
});
|
||||
};
|
||||
|
||||
$ax.annotation.jQueryAnn = function(query) {
|
||||
var elementIds = [];
|
||||
query.each(function(diagramObject, elementId) {
|
||||
if(diagramObject.annotation) elementIds[elementIds.length] = elementId;
|
||||
});
|
||||
var elementIdSelectors = jQuery.map(elementIds, function(elementId) { return '#' + elementId + '_ann'; });
|
||||
var jQuerySelectorText = (elementIdSelectors.length > 0) ? elementIdSelectors.join(', ') : '';
|
||||
return $(jQuerySelectorText);
|
||||
};
|
||||
|
||||
$(window.document).ready(function() {
|
||||
$ax.annotation.InitializeAnnotations($ax(function(dObj) { return dObj.annotation; }));
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
//If the annotations are being hidden via the Sitemap toggle button, hide any open dialogs
|
||||
if(message == 'annotationToggle') {
|
||||
if(data == false) {
|
||||
for(var index in dialogs) {
|
||||
var $dialog = dialogs[index];
|
||||
if($dialog.dialog("isOpen")) {
|
||||
$dialog.dialog("close");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,357 @@
|
||||
$axure = function(query) {
|
||||
return $axure.query(query);
|
||||
};
|
||||
|
||||
// ******* AxQuery and Page metadata ******** //
|
||||
(function() {
|
||||
var $ax = function() {
|
||||
var returnVal = $axure.apply(this, arguments);
|
||||
var axFn = $ax.fn;
|
||||
for (var key in axFn) {
|
||||
returnVal[key] = axFn[key];
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
};
|
||||
|
||||
$ax.public = $axure;
|
||||
$ax.fn = {};
|
||||
|
||||
$axure.internal = function(initFunction) {
|
||||
//Attach messagecenter to $ax object so that it can be used in viewer.js, etc in internal scope
|
||||
if(!$ax.messageCenter) $ax.messageCenter = $axure.messageCenter;
|
||||
|
||||
return initFunction($ax);
|
||||
};
|
||||
|
||||
var _lastFiredResize = 0;
|
||||
var _resizeFunctions = [];
|
||||
var _lastTimeout;
|
||||
var _fireResize = function() {
|
||||
if (_lastTimeout) window.clearTimeout(_lastTimeout);
|
||||
_lastTimeout = undefined;
|
||||
_lastFiredResize = new Date().getTime();
|
||||
for(var i = 0; i < _resizeFunctions.length; i++) _resizeFunctions[i]();
|
||||
};
|
||||
|
||||
$axure.resize = function(fn) {
|
||||
if(fn) _resizeFunctions[_resizeFunctions.length] = fn;
|
||||
else $(window).resize();
|
||||
};
|
||||
|
||||
$(window).resize(function() {
|
||||
var THRESHOLD = 50;
|
||||
var now = new Date().getTime();
|
||||
if(now - _lastFiredResize > THRESHOLD) {
|
||||
_fireResize();
|
||||
} else if(!_lastTimeout) {
|
||||
_lastTimeout = window.setTimeout(_fireResize, THRESHOLD);
|
||||
}
|
||||
});
|
||||
|
||||
window.$obj = function(id) {
|
||||
return $ax.getObjectFromElementId(id);
|
||||
};
|
||||
|
||||
window.$id = function(obj) {
|
||||
return obj.scriptIds[0];
|
||||
};
|
||||
|
||||
window.$jobj = function(id) {
|
||||
return $(document.getElementById(id));
|
||||
};
|
||||
|
||||
window.$jobjAll = function(id) {
|
||||
return $addAll($jobj(id), id);
|
||||
};
|
||||
|
||||
window.$addAll = function(jobj, id) {
|
||||
return jobj.add($jobj(id + '_ann')).add($jobj(id + '_ref'));
|
||||
};
|
||||
|
||||
$ax.INPUT = function(id) { return id + "_input"; };
|
||||
$ax.IsImageFocusable = function (type) { return $ax.public.fn.IsImageBox(type) || $ax.public.fn.IsVector(type) || $ax.public.fn.IsTreeNodeObject(type) || $ax.public.fn.IsTableCell(type); };
|
||||
$ax.IsTreeNodeObject = function (type) { return $ax.public.fn.IsTreeNodeObject(type); };
|
||||
$ax.IsSelectionButton = function (type) { return $ax.public.fn.IsCheckBox(type) || $ax.public.fn.IsRadioButton(type); };
|
||||
|
||||
var _fn = {};
|
||||
$axure.fn = _fn;
|
||||
$axure.fn.jQuery = function() {
|
||||
var elements = this.getElements();
|
||||
return $(elements);
|
||||
};
|
||||
$axure.fn.$ = $axure.fn.jQuery;
|
||||
|
||||
var _query = function(query, queryArg) {
|
||||
var returnVal = {};
|
||||
var _axQueryObject = returnVal.query = { };
|
||||
_axQueryObject.filterFunctions = [];
|
||||
|
||||
if (query == '*') {
|
||||
_axQueryObject.filterFunctions[0] = function() { return true; };
|
||||
} else if (typeof(query) === 'function') {
|
||||
_axQueryObject.filterFunctions[0] = query;
|
||||
} else {
|
||||
var firstString = $.trim(query.toString());
|
||||
if (firstString.charAt(0) == '@') {
|
||||
_axQueryObject.filterFunctions[0] = function(diagramObject) {
|
||||
return diagramObject.label == firstString.substring(1);
|
||||
};
|
||||
} else if (firstString.charAt(0) == '#') {
|
||||
_axQueryObject.elementId = firstString.substring(1);
|
||||
} else {
|
||||
if (firstString == 'label') {
|
||||
_axQueryObject.filterFunctions[0] = function(diagramObject) {
|
||||
return queryArg instanceof Array && queryArg.indexOf(diagramObject.label) > 0 ||
|
||||
queryArg instanceof RegExp && queryArg.test(diagramObject.label) ||
|
||||
diagramObject.label == queryArg;
|
||||
};
|
||||
} else if(firstString == 'elementId') {
|
||||
_axQueryObject.filterFunctions[0] = function(diagramObject, elementId) {
|
||||
return queryArg instanceof Array && queryArg.indexOf(elementId) > 0 ||
|
||||
elementId == queryArg;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var axureFn = $axure.fn;
|
||||
for (var key in axureFn) {
|
||||
returnVal[key] = axureFn[key];
|
||||
}
|
||||
return returnVal;
|
||||
};
|
||||
$axure.query = _query;
|
||||
|
||||
var _getFilterFnFromQuery = function(query) {
|
||||
var filter = function(diagramObject, elementId) {
|
||||
// Non diagram objects are allowed to be queryed, such as text inputs.
|
||||
if (diagramObject && !$ax.public.fn.IsReferenceDiagramObject(diagramObject.type) && !document.getElementById(elementId)) return false;
|
||||
var retVal = true;
|
||||
for(var i = 0; i < query.filterFunctions.length && retVal; i++) {
|
||||
retVal = query.filterFunctions[i](diagramObject, elementId);
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
return filter;
|
||||
};
|
||||
|
||||
$ax.public.fn.filter = function(query, queryArg) {
|
||||
var returnVal = _query(query, queryArg);
|
||||
|
||||
if(this.query.elementId) returnVal.query.elementId = this.query.elementId;
|
||||
|
||||
//If there is already a function, offset by 1 when copying other functions over.
|
||||
var offset = returnVal.query.filterFunctions[0] ? 1 : 0;
|
||||
|
||||
//Copy all functions over to new array.
|
||||
for(var i = 0; i < this.query.filterFunctions.length; i++) returnVal.query.filterFunctions[i+offset] = this.query.filterFunctions[i];
|
||||
|
||||
//Functions are in reverse order now
|
||||
returnVal.query.filterFunctions.reverse();
|
||||
|
||||
return returnVal;
|
||||
};
|
||||
|
||||
$ax.public.fn.each = function(fn) {
|
||||
var filter = _getFilterFnFromQuery(this.query);
|
||||
var elementIds = this.query.elementId ? [this.query.elementId] : $ax.getAllElementIds();
|
||||
for (var i = 0; i < elementIds.length; i++) {
|
||||
var elementId = elementIds[i];
|
||||
var diagramObject = $ax.getObjectFromElementId(elementId);
|
||||
if (filter(diagramObject, elementId)) {
|
||||
fn.apply(diagramObject, [diagramObject, elementId]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$ax.public.fn.getElements = function() {
|
||||
var elements = [];
|
||||
this.each(function(dObj, elementId) {
|
||||
var elementById = document.getElementById(elementId);
|
||||
if(elementById) elements[elements.length] = elementById;
|
||||
});
|
||||
return elements;
|
||||
};
|
||||
|
||||
$ax.public.fn.getElementIds = function() {
|
||||
var elementIds = [];
|
||||
this.each(function(dObj, elementId) { elementIds[elementIds.length] = elementId; });
|
||||
return elementIds;
|
||||
};
|
||||
|
||||
// Deep means to keep getting parents parent until at the root parent. Parent is then an array instead of an id.
|
||||
// Filter options: layer, rdo, repeater, item, dynamicPanel, state
|
||||
$ax.public.fn.getParents = function (deep, filter) {
|
||||
if(filter == '*') filter = ['layer', 'rdo', 'repeater', 'item', 'dynamicPanel', 'state'];
|
||||
var elementIds = this.getElementIds();
|
||||
var parentIds = [];
|
||||
|
||||
var getParent = function(elementId) {
|
||||
var containerIndex = elementId.indexOf('_container');
|
||||
if(containerIndex != -1) elementId = elementId.substring(0, containerIndex);
|
||||
|
||||
// Layer only references it if it is a direct layer to it
|
||||
var parent = $ax.getLayerParentFromElementId(elementId);
|
||||
// If layer is allowed we found parent, otherwise ignore and keep climbing
|
||||
if (parent) return filter.indexOf('layer') != -1 ? parent : getParent(parent);
|
||||
|
||||
// if repeater item, then just return repeater
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
var itemNum = $ax.repeater.getItemIdFromElementId(elementId);
|
||||
var parentRepeater = $ax.getParentRepeaterFromScriptId(scriptId);
|
||||
|
||||
// scriptId is item or repeater itself
|
||||
if (parentRepeater == scriptId) {
|
||||
// If you are repeater item, return your repeater
|
||||
if(itemNum) return filter.indexOf('repeater') != -1 ? scriptId : getParent(scriptId);
|
||||
// Otherwise you are actually at repeater, clean parentRepeater, or else you loop
|
||||
parentRepeater = undefined;
|
||||
}
|
||||
|
||||
// if state, then just return panel
|
||||
if(scriptId.indexOf('_state') != -1) {
|
||||
var panelId = $ax.repeater.createElementId(scriptId.split('_')[0], itemNum);
|
||||
// If dynamic panel is allowed we found parent, otherwise ignore and keep climbing
|
||||
return filter.indexOf('dynamicPanel') != -1 ? panelId : getParent(panelId);
|
||||
}
|
||||
|
||||
var parentType = '';
|
||||
if(parentRepeater) {
|
||||
parentType = 'item';
|
||||
parent = $ax.repeater.createElementId(parentRepeater, itemNum);
|
||||
}
|
||||
|
||||
var masterPath = $ax.getPathFromScriptId($ax.repeater.getScriptIdFromElementId(elementId));
|
||||
masterPath.pop();
|
||||
if(masterPath.length > 0) {
|
||||
var masterId = $ax.getElementIdFromPath(masterPath, { itemNum: itemNum });
|
||||
if(!masterId) return undefined;
|
||||
var masterRepeater = $ax.getParentRepeaterFromElementId($ax.repeater.getScriptIdFromElementId(masterId));
|
||||
if(!parentRepeater || masterRepeater) {
|
||||
parentType = 'rdo';
|
||||
parent = masterId;
|
||||
}
|
||||
}
|
||||
|
||||
var obj = $obj(elementId);
|
||||
var parentDynamicPanel = obj.parentDynamicPanel;
|
||||
if(parentDynamicPanel) {
|
||||
// Make sure the parent if not parentRepeater, or dynamic panel is also in that repeater
|
||||
// If there is a parent master, the dynamic panel must be in it, otherwise parentDynamicPanel would be undefined.
|
||||
var panelPath = masterPath;
|
||||
panelPath[panelPath.length] = parentDynamicPanel;
|
||||
panelId = $ax.getElementIdFromPath(panelPath, { itemNum: itemNum });
|
||||
if(!panelId) return undefined;
|
||||
var panelRepeater = $ax.getParentRepeaterFromElementId(panelId);
|
||||
if(!parentRepeater || panelRepeater) {
|
||||
parentType = 'state';
|
||||
parent = panelId + '_state' + obj.panelIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// If at top or parent type is desired, then return parent, otherwise keep climbing
|
||||
return !parent || filter.indexOf(parentType) != -1 ? parent : getParent(parent);
|
||||
};
|
||||
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
var parent = getParent(elementIds[i]);
|
||||
if(deep) {
|
||||
var parents = [];
|
||||
while(parent) {
|
||||
parents[parents.length] = parent;
|
||||
// If id is not a valid object, you are either repeater item or dynamic panel state
|
||||
if(!$obj(parent)) parent = $ax.visibility.getWidgetFromContainer($jobj(parent).parent().attr('id'));
|
||||
|
||||
parent = getParent(parent);
|
||||
}
|
||||
parent = parents;
|
||||
}
|
||||
parentIds[parentIds.length] = parent;
|
||||
}
|
||||
return parentIds;
|
||||
};
|
||||
|
||||
// Get the path to the child, where non leaf nodes can be masters, layers, dynamic panels, and repeaters.
|
||||
$ax.public.fn.getChildren = function(deep) {
|
||||
var elementIds = this.getElementIds();
|
||||
var children = [];
|
||||
|
||||
var getChildren = function(elementId) {
|
||||
var obj = $obj(elementId);
|
||||
if(!obj) return undefined;
|
||||
|
||||
var isRepeater = obj.type == $ax.constants.REPEATER_TYPE;
|
||||
var isDynamicPanel = obj.type == $ax.constants.DYNAMIC_PANEL_TYPE;
|
||||
var isLayer = obj.type == $ax.constants.LAYER_TYPE;
|
||||
var isMaster = obj.type == $ax.constants.MASTER_TYPE;
|
||||
|
||||
var isMenu = obj.type == $ax.constants.MENU_OBJECT_TYPE;
|
||||
var isTreeNode = obj.type == $ax.constants.TREE_NODE_OBJECT_TYPE;
|
||||
var isTable = obj.type == $ax.constants.TABLE_TYPE;
|
||||
//var isCompoundVector = obj.type == $ax.constants.VECTOR_SHAPE_TYPE && obj.generateCompound;
|
||||
|
||||
if (isRepeater || isDynamicPanel || isLayer || isMaster || isMenu || isTreeNode || isTable) {// || isCompoundVector) {
|
||||
// Find parent that children should be pulled from. Default is just the elementId query (used by table and master)
|
||||
var parent = $jobj(elementId);
|
||||
if(isRepeater) {
|
||||
parent = $();
|
||||
var itemIds = $ax.getItemIdsForRepeater(elementId);
|
||||
for(var itemIndex = 0; itemIndex < itemIds.length; itemIndex++) parent = parent.add($jobj($ax.repeater.createElementId(elementId, itemIds[itemIndex])));
|
||||
} else if(isDynamicPanel) {
|
||||
// Really only need to do active state probably...
|
||||
parent = $jobj(elementId).children();
|
||||
// Get through all containers
|
||||
while ($(parent[0]).attr('id').indexOf('container') != -1) parent = parent.children();
|
||||
// Now at states, but want states content
|
||||
parent = parent.children();
|
||||
} else if(isTreeNode) parent = $jobj($ax.repeater.applySuffixToElementId(elementId, '_children'));
|
||||
|
||||
// Menu doesn't want all children, only tables and menus, so it must be handled specially
|
||||
var children = isMenu ? parent.children('.ax_table').add(parent.children('.ax_menu')) : parent.children();
|
||||
children = $ax.visibility.getRealChildren(children);
|
||||
|
||||
// For tree nodes you want the the button shape contained by the elementQuery too
|
||||
if(isTreeNode) {
|
||||
var treeNodeChildren = $jobj(elementId).children();
|
||||
for(var treeNodeIndex = 0; treeNodeIndex < treeNodeChildren.length; treeNodeIndex++) {
|
||||
var treeNodeChild = $(treeNodeChildren[treeNodeIndex]);
|
||||
var childObj = $obj(treeNodeChild.attr('id'));
|
||||
if (childObj && $ax.public.fn.IsVector(childObj.type)) children = children.add(treeNodeChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var childrenIds = [];
|
||||
for(var childIndex = 0; childIndex < children.length; childIndex++) {
|
||||
var childObj = $(children[childIndex]);
|
||||
var id = childObj.attr('id');
|
||||
if(typeof(id) == 'undefined' && childObj.is('a')) id = $(childObj.children()[0]).attr('id');
|
||||
// Ignore annotations and any other children that are not elements
|
||||
if (id.split('_').length > 1) continue;
|
||||
|
||||
childrenIds.push(id);
|
||||
}
|
||||
|
||||
if(deep) {
|
||||
var childObjs = [];
|
||||
for(var i = 0; i < childrenIds.length; i++) {
|
||||
var childId = childrenIds[i];
|
||||
childObjs[i] = { id: childId, children: getChildren(childId) };
|
||||
}
|
||||
childrenIds = childObjs;
|
||||
}
|
||||
|
||||
return childrenIds;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
children[children.length] = { id : elementIds[i], children : getChildren(elementIds[i])};
|
||||
}
|
||||
return children;
|
||||
};
|
||||
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,734 @@
|
||||
$axure.internal(function($ax) {
|
||||
var _pageData;
|
||||
|
||||
|
||||
var _initializePageFragment = function(pageFragment, objIdToObject) {
|
||||
var objectArrayHelper = function(objects, parent) {
|
||||
for(var i = 0; i < objects.length; i++) {
|
||||
diagramObjectHelper(objects[i], parent);
|
||||
}
|
||||
};
|
||||
|
||||
var diagramObjectHelper = function(diagramObject, parent) {
|
||||
$ax.initializeObject('diagramObject', diagramObject);
|
||||
objIdToObject[pageFragment.packageId + '~' + diagramObject.id] = diagramObject;
|
||||
diagramObject.parent = parent;
|
||||
diagramObject.owner = pageFragment;
|
||||
diagramObject.scriptIds = [];
|
||||
if(diagramObject.diagrams) { //dynamic panel
|
||||
for(var i = 0; i < diagramObject.diagrams.length; i++) {
|
||||
var diagram = diagramObject.diagrams[i];
|
||||
objectArrayHelper(diagram.objects, diagram);
|
||||
}
|
||||
}
|
||||
if(diagramObject.objects) objectArrayHelper(diagramObject.objects, diagramObject);
|
||||
};
|
||||
|
||||
objectArrayHelper(pageFragment.diagram.objects, pageFragment.diagram);
|
||||
};
|
||||
|
||||
var _initalizeStylesheet = function(stylesheet) {
|
||||
var stylesById = {};
|
||||
var customStyles = stylesheet.customStyles;
|
||||
for(var key in customStyles) {
|
||||
var style = customStyles[key];
|
||||
stylesById[style.id] = style;
|
||||
}
|
||||
stylesheet.stylesById = stylesById;
|
||||
};
|
||||
|
||||
|
||||
var _initializeDocumentData = function() {
|
||||
_initalizeStylesheet($ax.document.stylesheet);
|
||||
};
|
||||
|
||||
|
||||
var _initializePageData;
|
||||
// ******* Dictionaries ******** //
|
||||
(function () {
|
||||
var scriptIdToParentLayer = {};
|
||||
var elementIdToObject = {};
|
||||
var scriptIdToObject = {};
|
||||
var scriptIdToRepeaterId = {};
|
||||
var repeaterIdToScriptIds = {};
|
||||
var repeaterIdToItemIds = {};
|
||||
var scriptIdToPath = {};
|
||||
var _scriptIds = [];
|
||||
var elementIdToText = {};
|
||||
var radioGroupToSelectedElementId = {};
|
||||
_initializePageData = function() {
|
||||
if(!_pageData || !_pageData.page || !_pageData.page.diagram) return;
|
||||
|
||||
var objIdToObject = {};
|
||||
_initializePageFragment(_pageData.page, objIdToObject);
|
||||
for(var masterId in _pageData.masters) {
|
||||
var master = _pageData.masters[masterId];
|
||||
_initializePageFragment(master, objIdToObject);
|
||||
}
|
||||
|
||||
var _pathsToScriptIds = [];
|
||||
_pathToScriptIdHelper(_pageData.objectPaths, [], _pathsToScriptIds, scriptIdToPath);
|
||||
|
||||
for(var i = 0; i < _pathsToScriptIds.length; i++) {
|
||||
var path = _pathsToScriptIds[i].idPath;
|
||||
var scriptId = _pathsToScriptIds[i].scriptId;
|
||||
|
||||
var packageId = _pageData.page.packageId;
|
||||
if(path.length > 1) {
|
||||
for(var j = 0; j < path.length - 1; j++) {
|
||||
var rdoId = path[j];
|
||||
var rdo = objIdToObject[packageId + '~' + rdoId];
|
||||
packageId = rdo.masterId;
|
||||
}
|
||||
}
|
||||
var diagramObject = objIdToObject[packageId + '~' + path[path.length - 1]];
|
||||
diagramObject.scriptIds[diagramObject.scriptIds.length] = scriptId;
|
||||
|
||||
scriptIdToObject[scriptId] = diagramObject;
|
||||
_scriptIds[_scriptIds.length] = scriptId;
|
||||
}
|
||||
|
||||
// Now map scriptIds to repeaters and layers
|
||||
var mapScriptIdToRepeaterId = function(scriptId, repeaterId) {
|
||||
scriptIdToRepeaterId[scriptId] = repeaterId;
|
||||
var scriptIds = repeaterIdToScriptIds[repeaterId];
|
||||
if(scriptIds) scriptIds[scriptIds.length] = scriptId;
|
||||
else repeaterIdToScriptIds[repeaterId] = [scriptId];
|
||||
};
|
||||
var mapScriptIdToLayerId = function (obj, layerId, path) {
|
||||
var pathCopy = $ax.deepCopy(path);
|
||||
pathCopy[path.length] = obj.id;
|
||||
var scriptId = $ax.getScriptIdFromPath(pathCopy);
|
||||
if ($ax.public.fn.IsLayer(obj.type)) {
|
||||
for(var i = 0; i < obj.objs.length; i++) mapScriptIdToLayerId(obj.objs[i], scriptId, path);
|
||||
}
|
||||
scriptIdToParentLayer[scriptId] = layerId;
|
||||
}
|
||||
var mapIdsToRepeaterAndLayer = function(path, objs, repeaterId) {
|
||||
var pathCopy = $ax.deepCopy(path);
|
||||
|
||||
for(var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
pathCopy[path.length] = obj.id;
|
||||
var scriptId = $ax.getScriptIdFromPath(pathCopy);
|
||||
// Rdo have no element on page and are not mapped to the repeater
|
||||
if(repeaterId) mapScriptIdToRepeaterId(scriptId, repeaterId);
|
||||
|
||||
if ($ax.public.fn.IsDynamicPanel(obj.type)) {
|
||||
for(var j = 0; j < obj.diagrams.length; j++) mapIdsToRepeaterAndLayer(path, obj.diagrams[j].objects, repeaterId);
|
||||
} else if ($ax.public.fn.IsReferenceDiagramObject(obj.type)) {
|
||||
mapIdsToRepeaterAndLayer(pathCopy, $ax.pageData.masters[obj.masterId].diagram.objects, repeaterId);
|
||||
} else if ($ax.public.fn.IsRepeater(obj.type)) {
|
||||
mapScriptIdToRepeaterId(scriptId, scriptId);
|
||||
mapIdsToRepeaterAndLayer(path, obj.objects, scriptId);
|
||||
} else if ($ax.public.fn.IsLayer(obj.type)) {
|
||||
var layerObjs = obj.objs;
|
||||
for(var j = 0; j < layerObjs.length; j++) {
|
||||
mapScriptIdToLayerId(layerObjs[j], scriptId, path);
|
||||
}
|
||||
} else if(obj.objects && obj.objects.length) {
|
||||
if(repeaterId) {
|
||||
for(var j = 0; j < obj.objects.length; j++) {
|
||||
mapIdsToRepeaterAndLayer(path, obj.objects, repeaterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mapIdsToRepeaterAndLayer([], $ax.pageData.page.diagram.objects);
|
||||
};
|
||||
|
||||
|
||||
|
||||
$ax.getPathFromScriptId = function(scriptId) {
|
||||
var reversedPath = [];
|
||||
var path = scriptIdToPath[scriptId];
|
||||
while(path && path.uniqueId) {
|
||||
reversedPath[reversedPath.length] = path.uniqueId;
|
||||
path = path.parent;
|
||||
}
|
||||
return reversedPath.reverse();
|
||||
};
|
||||
|
||||
var _getScriptIdFromFullPath = function(path) {
|
||||
var current = $ax.pageData.objectPaths;
|
||||
for(var i = 0; i < path.length; i++) {
|
||||
current = current[path[i]];
|
||||
if(!current) return current;
|
||||
}
|
||||
return current && current.scriptId;
|
||||
};
|
||||
|
||||
|
||||
var _getScriptIdFromPath = function(path, relativeTo) {
|
||||
var relativePath = [];
|
||||
var includeMasterInPath = false;
|
||||
if(relativeTo) {
|
||||
var relativeToScriptId;
|
||||
if(relativeTo.srcElement) { //this is eventInfo
|
||||
relativeToScriptId = $ax.repeater.getScriptIdFromElementId(relativeTo.srcElement);
|
||||
includeMasterInPath = relativeTo.isMasterEvent;
|
||||
} else if(typeof relativeTo === 'string') { //this is an element id
|
||||
relativeToScriptId = relativeTo;
|
||||
}
|
||||
|
||||
if(relativeToScriptId) {
|
||||
relativePath = $ax.getPathFromScriptId(relativeToScriptId);
|
||||
if(!includeMasterInPath) relativePath = relativePath.slice(0, relativePath.length - 1);
|
||||
} else if(relativeTo instanceof Array) { //this is a path
|
||||
relativePath = relativeTo;
|
||||
}
|
||||
}
|
||||
var fullPath = relativePath.concat(path);
|
||||
var scriptId = _getScriptIdFromFullPath(fullPath);
|
||||
return !$ax.visibility.isScriptIdLimbo(scriptId) && scriptId;
|
||||
};
|
||||
$ax.getScriptIdFromPath = _getScriptIdFromPath;
|
||||
|
||||
var _getElementIdsFromPath = function(path, eventInfo) {
|
||||
var scriptId = _getScriptIdFromPath(path, eventInfo);
|
||||
if (!scriptId) return [];
|
||||
// Don't need placed check hear. If unplaced, scriptId will be undefined and exit out before here.
|
||||
return $ax.getElementIdsFromEventAndScriptId(eventInfo, scriptId);
|
||||
};
|
||||
$ax.getElementIdsFromPath = _getElementIdsFromPath;
|
||||
|
||||
var _getElementIdFromPath = function (path, params) {
|
||||
var scriptId = _getScriptIdFromPath(path, params.relativeTo);
|
||||
if (!scriptId) return scriptId;
|
||||
|
||||
var itemNum = params.itemNum;
|
||||
if(params.relativeTo && typeof params.relativeTo === 'string') {
|
||||
if($jobj(params.relativeTo)) itemNum = $ax.repeater.getItemIdFromElementId(params.relativeTo);
|
||||
}
|
||||
return $ax.repeater.createElementId(scriptId, itemNum);
|
||||
};
|
||||
$ax.getElementIdFromPath = _getElementIdFromPath;
|
||||
|
||||
var _getElementsIdFromEventAndScriptId = function(eventInfo, scriptId) {
|
||||
var itemId = eventInfo && $ax.repeater.getItemIdFromElementId(eventInfo.srcElement);
|
||||
var target = false;
|
||||
// Try to get itemId from target if you can't get it from source.
|
||||
if(!itemId) {
|
||||
itemId = eventInfo && eventInfo.targetElement && $ax.repeater.getItemIdFromElementId(eventInfo.targetElement);
|
||||
if(itemId) target = true;
|
||||
}
|
||||
|
||||
var parentRepeater = $ax.getParentRepeaterFromScriptId(scriptId);
|
||||
if(parentRepeater && scriptId != parentRepeater) {
|
||||
if(itemId && (!eventInfo || parentRepeater == $ax.getParentRepeaterFromScriptId($ax.repeater.getScriptIdFromElementId(target ? eventInfo.targetElement : eventInfo.srcElement)))) {
|
||||
return [$ax.repeater.createElementId(scriptId, itemId)];
|
||||
}
|
||||
var elementIds = [];
|
||||
var itemIds = $ax.getItemIdsForRepeater(parentRepeater);
|
||||
if(!itemIds) return [];
|
||||
|
||||
for(var i = 0; i < itemIds.length; i++) elementIds[i] = $ax.repeater.createElementId(scriptId, itemIds[i]);
|
||||
return elementIds;
|
||||
}
|
||||
return [scriptId];
|
||||
};
|
||||
$ax.getElementIdsFromEventAndScriptId = _getElementsIdFromEventAndScriptId;
|
||||
|
||||
var _getSrcElementIdFromEvent = function(event) {
|
||||
var currentQuery = $(event.srcElement || event.target);
|
||||
while(currentQuery && currentQuery.length && (!$obj(currentQuery.attr('id')) || $jobj(currentQuery.attr('id')).hasClass('text'))) {
|
||||
currentQuery = currentQuery.parent();
|
||||
};
|
||||
return currentQuery.attr('id');
|
||||
};
|
||||
$ax.getSrcElementIdFromEvent = _getSrcElementIdFromEvent;
|
||||
|
||||
var _getEventInfoFromEvent = function(event, skipShowDescriptions, elementId) {
|
||||
var eventInfo = {};
|
||||
eventInfo.srcElement = elementId;
|
||||
eventInfo.now = new Date();
|
||||
|
||||
if(event != null) {
|
||||
//elementId can be empty string, so can't simple use "or" assignment here.
|
||||
eventInfo.srcElement = elementId || elementId == '' ? elementId : _getSrcElementIdFromEvent(event);
|
||||
eventInfo.which = event.which;
|
||||
|
||||
// When getting locations in mobile, need to extract the touch object to get the mouse location attributes
|
||||
var mouseEvent = (event.originalEvent && event.originalEvent.changedTouches && event.originalEvent.changedTouches[0]) || event.originalEvent;
|
||||
if(mouseEvent && !mouseEvent.type) mouseEvent.type = event.type;
|
||||
|
||||
if(skipShowDescriptions) eventInfo.skipShowDescriptions = true;
|
||||
|
||||
// Always update mouse location if possible
|
||||
$ax.event.updateMouseLocation(mouseEvent);
|
||||
}
|
||||
|
||||
// Always set event info about cursor
|
||||
var _cursor = eventInfo.cursor = {};
|
||||
_cursor.x = $ax.mouseLocation.x;
|
||||
_cursor.y = $ax.mouseLocation.y;
|
||||
|
||||
eventInfo.pageX = _cursor.x + 'px';
|
||||
eventInfo.pageY = _cursor.y + 'px';
|
||||
|
||||
// Do Keyboard Info
|
||||
eventInfo.keyInfo = $ax.event.keyState();
|
||||
|
||||
eventInfo.window = _getWindowInfo();
|
||||
|
||||
eventInfo.thiswidget = _getWidgetInfo(eventInfo.srcElement);
|
||||
eventInfo.item = _getItemInfo(eventInfo.srcElement);
|
||||
eventInfo.dragInfo = $ax.drag.GetWidgetDragInfo();
|
||||
|
||||
return eventInfo;
|
||||
};
|
||||
$ax.getEventInfoFromEvent = _getEventInfoFromEvent;
|
||||
|
||||
var _getWindowInfo = function() {
|
||||
var win = {};
|
||||
win.width = $(window).width();
|
||||
win.height = $(window).height();
|
||||
win.scrollx = $(window).scrollLeft();
|
||||
win.scrolly = $(window).scrollTop();
|
||||
return win;
|
||||
};
|
||||
$ax.getWindowInfo = _getWindowInfo;
|
||||
|
||||
var _getItemInfo = function(elementId) {
|
||||
if(!elementId) return { valid: false };
|
||||
|
||||
elementId = _getParentElement(elementId);
|
||||
|
||||
var index = $ax.repeater.getItemIdFromElementId(elementId);
|
||||
if(!index) return { valid: false };
|
||||
|
||||
var item = { valid: true };
|
||||
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
var repeaterId = $ax.getParentRepeaterFromScriptId(scriptId);
|
||||
item.repeater = _getWidgetInfo(repeaterId);
|
||||
$ax.repeater.setDisplayProps(item, repeaterId, index);
|
||||
item.ismarked = $ax.repeater.isEditItem(repeaterId, index);
|
||||
item.isvisible = Boolean($jobj(elementId).length);
|
||||
|
||||
return item;
|
||||
};
|
||||
$ax.getItemInfo = _getItemInfo;
|
||||
|
||||
var _getWidgetInfo = function(elementId) {
|
||||
if(!elementId) return { valid: false };
|
||||
|
||||
elementId = _getParentElement(elementId);
|
||||
|
||||
var elementAxQuery = $ax('#' + elementId);
|
||||
var elementQuery = $jobj(elementId);
|
||||
var obj = $obj(elementId);
|
||||
var widget = { valid: true, isWidget: true };
|
||||
widget.elementId = elementId;
|
||||
widget.name = widget.label = (elementQuery.data('label') ? elementQuery.data('label') : '');
|
||||
widget.text = $ax('#' + elementId).text();
|
||||
widget.opacity = Number(elementQuery.css('opacity')) * 100;
|
||||
widget.rotation = $ax.move.getRotationDegree(widget.elementId);
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
var repeaterId = $ax.getParentRepeaterFromScriptId(scriptId);
|
||||
if (repeaterId) widget.repeater = $ax.public.fn.IsRepeater(obj.type) ? widget : _getWidgetInfo(repeaterId);
|
||||
|
||||
var boundingRect = $ax.public.fn.getWidgetBoundingRect(elementId);
|
||||
|
||||
if($ax.public.fn.IsLayer(obj.type)) {
|
||||
|
||||
widget.x = boundingRect.left;
|
||||
widget.y = boundingRect.top;
|
||||
widget.width = boundingRect.width;
|
||||
widget.height = boundingRect.height;
|
||||
if(elementQuery.length != 0) {
|
||||
widget.pagex = elementAxQuery.left();
|
||||
widget.pagey = elementAxQuery.top();
|
||||
}
|
||||
} else {
|
||||
var elementExists = elementQuery.length > 0;
|
||||
var x = elementExists ? elementAxQuery.locRelativeIgnoreLayer(false) : 0;
|
||||
var y = elementExists ? elementAxQuery.locRelativeIgnoreLayer(true) : 0;
|
||||
|
||||
widget.x = x;
|
||||
widget.y = y;
|
||||
|
||||
if(elementExists) {
|
||||
widget.pagex = elementAxQuery.left();
|
||||
widget.pagey = elementAxQuery.top();
|
||||
widget.width = elementAxQuery.width();
|
||||
widget.height = elementAxQuery.height();
|
||||
}
|
||||
|
||||
//if (obj.generateCompound) {
|
||||
// // assume this means that this is a compound vector.
|
||||
// widget.x = boundingRect.left;
|
||||
// widget.y = boundingRect.top;
|
||||
|
||||
// //widget.pagex += boundingRect.left;
|
||||
// //widget.pagey += boundingRect.top;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Right now only dynamic panel can scroll
|
||||
if ($ax.public.fn.IsDynamicPanel(obj.type)) {
|
||||
var stateQuery = $('#' + $ax.visibility.GetPanelState(elementId));
|
||||
widget.scrollx = stateQuery.scrollLeft();
|
||||
widget.scrolly = stateQuery.scrollTop();
|
||||
|
||||
if($ax.dynamicPanelManager.isIdFitToContent(elementId)) {
|
||||
widget.width = stateQuery.width();
|
||||
widget.height = stateQuery.height();
|
||||
}
|
||||
} else {
|
||||
widget.scrollx = 0;
|
||||
widget.scrolly = 0;
|
||||
}
|
||||
|
||||
// repeater only props
|
||||
if ($ax.public.fn.IsRepeater(obj.type)) {
|
||||
widget.visibleitemcount = repeaterIdToItemIds[scriptId] ? repeaterIdToItemIds[scriptId].length : $ax.repeater.getVisibleDataCount(scriptId);
|
||||
widget.itemcount = $ax.repeater.getFilteredDataCount(scriptId);
|
||||
widget.datacount = $ax.repeater.getDataCount(scriptId);
|
||||
widget.pagecount = $ax.repeater.getPageCount(scriptId);
|
||||
widget.pageindex = $ax.repeater.getPageIndex(scriptId);
|
||||
}
|
||||
|
||||
widget.left = widget.x;
|
||||
widget.top = widget.y;
|
||||
widget.right = widget.x + widget.width;
|
||||
widget.bottom = widget.y + widget.height;
|
||||
|
||||
return widget;
|
||||
};
|
||||
$ax.getWidgetInfo = _getWidgetInfo;
|
||||
|
||||
var _getParentElement = $ax.getParentElement = function(elementId) {
|
||||
var obj = $obj(elementId);
|
||||
while(obj.isContained) {
|
||||
var path = $ax.getPathFromScriptId($ax.repeater.getScriptIdFromElementId(elementId));
|
||||
var itemId = $ax.repeater.getItemIdFromElementId(elementId);
|
||||
path[path.length - 1] = obj.parent.id;
|
||||
elementId = $ax.getElementIdFromPath(path, { itemNum: itemId });
|
||||
obj = $obj(elementId);
|
||||
}
|
||||
|
||||
return elementId;
|
||||
};
|
||||
|
||||
$ax.addItemIdToRepeater = function(itemId, repeaterId) {
|
||||
var itemIds = repeaterIdToItemIds[repeaterId];
|
||||
if(itemIds) itemIds[itemIds.length] = itemId;
|
||||
else repeaterIdToItemIds[repeaterId] = [itemId];
|
||||
|
||||
var scriptIds = repeaterIdToScriptIds[repeaterId];
|
||||
for(var i = 0; i < scriptIds.length; i++) elementIdToObject[$ax.repeater.createElementId(scriptIds[i], itemId)] = $ax.getObjectFromScriptId(scriptIds[i]);
|
||||
};
|
||||
|
||||
$ax.getAllElementIds = function() {
|
||||
var elementIds = [];
|
||||
for(var i = 0; i < _scriptIds.length; i++) {
|
||||
var scriptId = _scriptIds[i];
|
||||
var repeaterId = scriptIdToRepeaterId[scriptId];
|
||||
if(repeaterId && repeaterId != scriptId) {
|
||||
var itemIds = repeaterIdToItemIds[repeaterId] || [];
|
||||
for(var j = 0; j < itemIds.length; j++) elementIds[elementIds.length] = $ax.repeater.createElementId(scriptId, itemIds[j]);
|
||||
} else elementIds[elementIds.length] = scriptId;
|
||||
}
|
||||
return elementIds;
|
||||
};
|
||||
|
||||
$ax.getAllScriptIds = function() {
|
||||
return _scriptIds;
|
||||
};
|
||||
|
||||
$ax.getObjectFromElementId = function(elementId) {
|
||||
return $ax.getObjectFromScriptId($ax.repeater.getScriptIdFromElementId(elementId));
|
||||
};
|
||||
|
||||
$ax.getObjectFromScriptId = function(scriptId) {
|
||||
return scriptIdToObject[scriptId];
|
||||
};
|
||||
|
||||
$ax.getParentRepeaterFromElementId = function(elementId) {
|
||||
return $ax.getParentRepeaterFromScriptId($ax.repeater.getScriptIdFromElementId(elementId));
|
||||
};
|
||||
|
||||
$ax.getParentRepeaterFromScriptId = function(scriptId) {
|
||||
return scriptIdToRepeaterId[scriptId];
|
||||
};
|
||||
|
||||
var _getChildScriptIdsForRepeater = function(repeaterId) {
|
||||
return repeaterIdToScriptIds[repeaterId];
|
||||
};
|
||||
|
||||
var _getItemIdsForRepeater = function(repeaterId) {
|
||||
return repeaterIdToItemIds[repeaterId] || [];
|
||||
};
|
||||
$ax.getItemIdsForRepeater = _getItemIdsForRepeater;
|
||||
|
||||
var _clearItemIdsForRepeater = function(repeaterId) {
|
||||
repeaterIdToItemIds[repeaterId] = [];
|
||||
};
|
||||
$ax.clearItemsForRepeater = _clearItemIdsForRepeater;
|
||||
|
||||
$ax.getChildElementIdsForRepeater = function(repeaterId) {
|
||||
var scriptIds = _getChildScriptIdsForRepeater(repeaterId);
|
||||
var itemIds = _getItemIdsForRepeater(repeaterId);
|
||||
|
||||
var retVal = [];
|
||||
if(!itemIds || !scriptIds) return retVal;
|
||||
|
||||
for(var i = 0; i < scriptIds.length; i++) {
|
||||
for(var j = 0; j < itemIds.length; j++) {
|
||||
retVal[retVal.length] = $ax.repeater.createElementId(scriptIds[i], itemIds[j]);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
|
||||
$ax.getRdoParentFromElementId = function(elementId) {
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
var rdoId = scriptIdToPath[scriptId].parent.scriptId;
|
||||
if($ax.getParentRepeaterFromScriptId(rdoId)) rdoId = $ax.repeater.createElementId(rdoId, $ax.repeater.getItemIdFromElementId(elementId));
|
||||
return rdoId;
|
||||
};
|
||||
|
||||
$ax.getLayerParentFromElementId = function (elementId) {
|
||||
var itemId = $ax.repeater.getItemIdFromElementId(elementId);
|
||||
var scriptId = scriptIdToParentLayer[$ax.repeater.getScriptIdFromElementId(elementId)];
|
||||
return $ax.getParentRepeaterFromElementId(scriptId) ? $ax.repeater.createElementId(scriptId, itemId) : scriptId;
|
||||
}
|
||||
|
||||
$ax.updateElementText = function(elementId, text) {
|
||||
elementIdToText[elementId] = text;
|
||||
};
|
||||
|
||||
$ax.hasElementTextChanged = function(elementId, text) {
|
||||
return elementIdToText[elementId] != text;
|
||||
};
|
||||
|
||||
$ax.updateRadioButtonSelected = function(group, elementId) {
|
||||
var old = radioGroupToSelectedElementId[group];
|
||||
radioGroupToSelectedElementId[group] = elementId;
|
||||
return old;
|
||||
};
|
||||
|
||||
$ax.hasRadioButtonSelectedChanged = function(group, elementId) {
|
||||
return radioGroupToSelectedElementId[group] != elementId;
|
||||
};
|
||||
})();
|
||||
|
||||
//Recursively populates fullPathArray with:
|
||||
// [ { idPath, scriptId }, ... ]
|
||||
//for every scriptId in the object
|
||||
//also populates an object of scriptId -> path
|
||||
var _pathToScriptIdHelper = function(currentPath, currentChain, fullPathArray, scriptIdToPath) {
|
||||
for(var key in currentPath) {
|
||||
if(key != "scriptId") {
|
||||
var nextPath = currentPath[key];
|
||||
_pathToScriptIdHelper(nextPath, currentChain.concat(key), fullPathArray, scriptIdToPath);
|
||||
nextPath.parent = currentPath;
|
||||
nextPath.uniqueId = key;
|
||||
} else {
|
||||
fullPathArray[fullPathArray.length] = { idPath: currentChain, scriptId: currentPath.scriptId };
|
||||
scriptIdToPath[currentPath.scriptId] = currentPath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$ax.public.loadCurrentPage = $ax.loadCurrentPage = function(pageData) {
|
||||
$ax.pageData = _pageData = pageData;
|
||||
_initializePageData();
|
||||
};
|
||||
|
||||
$ax.public.loadDocument = $ax.loadDocument = function(document) {
|
||||
$ax.document = document;
|
||||
_initializeDocumentData();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Navigates to a page
|
||||
|
||||
|
||||
*/
|
||||
$ax.public.navigate = $ax.navigate = function(to) { //url, includeVariables, type) {
|
||||
var targetUrl;
|
||||
if(typeof (to) === 'object') {
|
||||
includeVariables = to.includeVariables;
|
||||
targetUrl = !includeVariables ? to.url : $ax.globalVariableProvider.getLinkUrl(to.url);
|
||||
|
||||
if(to.target == "new") {
|
||||
window.open(targetUrl, to.name);
|
||||
} else if(to.target == "popup") {
|
||||
var features = _getPopupFeatures(to.popupOptions);
|
||||
window.open(targetUrl, to.name, features);
|
||||
} else {
|
||||
var targetLocation = window.location;
|
||||
if(to.target == "current") {
|
||||
} else if(to.target == "parent") {
|
||||
targetLocation = top.opener.window.location;
|
||||
} else if(to.target == "parentFrame") {
|
||||
targetLocation = parent.location;
|
||||
} else if(to.target == "frame") {
|
||||
// targetLocation = to.frame.contentWindow.location;
|
||||
$(to.frame).attr('src', targetUrl || 'about:blank');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_needsReload(targetLocation, to.url)) {
|
||||
targetLocation.href = targetUrl || 'about:blank';
|
||||
} else {
|
||||
targetLocation.href = $axure.utils.getReloadPath() + "#" + encodeURI(targetUrl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ax.navigate({
|
||||
url: to,
|
||||
target: "current",
|
||||
includeVariables: arguments[1]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var _needsReload = function(oldLocation, newBaseUrl) {
|
||||
var reload = false;
|
||||
try {
|
||||
var oldUrl = oldLocation.href;
|
||||
var oldBaseUrl = oldUrl.split("#")[0];
|
||||
var lastslash = oldBaseUrl.lastIndexOf("/");
|
||||
if(lastslash > 0) {
|
||||
oldBaseUrl = oldBaseUrl.substring(lastslash + 1, oldBaseUrl.length);
|
||||
if(oldBaseUrl == encodeURI(newBaseUrl)) {
|
||||
reload = true;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
return reload;
|
||||
};
|
||||
|
||||
var _getPopupFeatures = function(options) {
|
||||
var defaultOptions = {
|
||||
toolbar: true,
|
||||
scrollbars: true,
|
||||
location: true,
|
||||
status: true,
|
||||
menubar: true,
|
||||
directories: true,
|
||||
resizable: true,
|
||||
centerwindow: true,
|
||||
left: -1,
|
||||
top: -1,
|
||||
height: -1,
|
||||
width: -1
|
||||
};
|
||||
|
||||
var selectedOptions = $.extend({}, defaultOptions, options);
|
||||
|
||||
var optionsList = [];
|
||||
optionsList.push('toolbar=' + (selectedOptions.toolbar ? 'yes' : 'no'));
|
||||
optionsList.push('scrollbars=' + (selectedOptions.scrollbars ? 'yes' : 'no'));
|
||||
optionsList.push('location=' + (selectedOptions.location ? 'yes' : 'no'));
|
||||
optionsList.push('status=' + (selectedOptions.status ? 'yes' : 'no'));
|
||||
optionsList.push('menubar=' + (selectedOptions.menubar ? 'yes' : 'no'));
|
||||
optionsList.push('directories=' + (selectedOptions.directories ? 'yes' : 'no'));
|
||||
optionsList.push('resizable=' + (selectedOptions.resizable ? 'yes' : 'no'));
|
||||
|
||||
if(selectedOptions.centerwindow == false) {
|
||||
if(selectedOptions.left > -1) {
|
||||
optionsList.push('left=' + selectedOptions.left);
|
||||
}
|
||||
|
||||
if(selectedOptions.top > -1) {
|
||||
optionsList.push('top=' + selectedOptions.top);
|
||||
}
|
||||
}
|
||||
|
||||
var height = 0;
|
||||
var width = 0;
|
||||
if(selectedOptions.height > 0) {
|
||||
optionsList.push('height=' + selectedOptions.height);
|
||||
height = selectedOptions.height;
|
||||
}
|
||||
|
||||
if(selectedOptions.width > 0) {
|
||||
optionsList.push('width=' + selectedOptions.width);
|
||||
width = selectedOptions.width;
|
||||
}
|
||||
|
||||
var features = optionsList.join(',');
|
||||
if(selectedOptions.centerwindow) {
|
||||
var winl = (window.screen.width - width) / 2;
|
||||
var wint = (window.screen.height - height) / 2;
|
||||
features = features + ',left=' + winl + ',top=' + wint;
|
||||
}
|
||||
|
||||
return features;
|
||||
};
|
||||
|
||||
/**
|
||||
Closes a window
|
||||
|
||||
|
||||
*/
|
||||
$ax.public.closeWindow = $ax.closeWindow = function() {
|
||||
parent.window.close();
|
||||
};
|
||||
|
||||
/**
|
||||
Goes back
|
||||
|
||||
|
||||
*/
|
||||
$ax.public.back = $ax.back = function() {
|
||||
window.history.go(-1);
|
||||
};
|
||||
|
||||
/**
|
||||
Reloads the current page.
|
||||
# includeVariables: true if it should re-include the variables when the page is reloaded
|
||||
*/
|
||||
$ax.public.reload = $ax.reload = function(includeVariables) {
|
||||
var targetUrl = (includeVariables === false)
|
||||
? $axure.utils.getReloadPath() + "#" + encodeURI($ax.pageData.url)
|
||||
: $axure.utils.getReloadPath() + "#" + encodeURI($ax.globalVariableProvider.getLinkUrl($ax.pageData.url));
|
||||
window.location.href = targetUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
Sets a variable.
|
||||
# name: The name of the global variable to set
|
||||
# value: The value that should be set
|
||||
*/
|
||||
$ax.public.setGlobalVariable = $ax.setGlobalVariable = function(name, value) {
|
||||
if(!name || !value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ax.globalVariableProvider.setVariableValue(name, value);
|
||||
};
|
||||
|
||||
/**
|
||||
Gets the value of a global variable
|
||||
# name: The name of the global variable value to get
|
||||
*/
|
||||
$ax.public.getGlobalVariable = $ax.getGlobalVariable = function(name) {
|
||||
$ax.globalVariableProvider.getVariableValue(name);
|
||||
};
|
||||
|
||||
$ax.getObjectFromElementIdDisregardHex = function (elementId) {
|
||||
var elementIdInput = elementId.charAt(0) == '#' ? elementId.substring(1) : elementId;
|
||||
return this.getObjectFromElementId(elementIdInput);
|
||||
}
|
||||
|
||||
|
||||
$ax.getTypeFromElementId = function(elementId) {
|
||||
var obj = this.getObjectFromElementIdDisregardHex(elementId);
|
||||
return obj && obj.type;
|
||||
};
|
||||
|
||||
$ax.getNumFromPx = function(pxNum) {
|
||||
return Number(pxNum.replace('px', ''));
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,322 @@
|
||||
$axure.internal(function($ax) {
|
||||
var widgetDragInfo = new Object();
|
||||
var _drag = {};
|
||||
$ax.drag = _drag;
|
||||
|
||||
$ax.drag.GetWidgetDragInfo = function() {
|
||||
return $.extend({}, widgetDragInfo);
|
||||
};
|
||||
|
||||
$ax.drag.StartDragWidget = function(event, id) {
|
||||
$ax.setjBrowserEvent(jQuery.Event(event));
|
||||
if(event.donotdrag) return;
|
||||
|
||||
var x, y;
|
||||
var tg;
|
||||
if(IE_10_AND_BELOW) {
|
||||
x = window.event.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft;
|
||||
y = window.event.clientY + window.document.documentElement.scrollTop + window.document.body.scrollTop;
|
||||
tg = window.event.srcElement;
|
||||
} else {
|
||||
if(event.changedTouches) {
|
||||
x = event.changedTouches[0].pageX;
|
||||
y = event.changedTouches[0].pageY;
|
||||
} else {
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
event.preventDefault();
|
||||
}
|
||||
tg = event.target;
|
||||
}
|
||||
|
||||
widgetDragInfo.hasStarted = false;
|
||||
widgetDragInfo.widgetId = id;
|
||||
widgetDragInfo.cursorStartX = x;
|
||||
widgetDragInfo.cursorStartY = y;
|
||||
widgetDragInfo.lastX = x;
|
||||
widgetDragInfo.lastY = y;
|
||||
widgetDragInfo.currentX = x;
|
||||
widgetDragInfo.currentY = y;
|
||||
|
||||
widgetDragInfo.movedWidgets = new Object();
|
||||
widgetDragInfo.startTime = (new Date()).getTime();
|
||||
widgetDragInfo.targetWidget = tg;
|
||||
|
||||
var movedownName = IE_10_AND_BELOW && $ax.features.supports.windowsMobile ?
|
||||
$ax.features.eventNames.mouseDownName : $ax.features.eventNames.mouseMoveName;
|
||||
$ax.event.addEvent(document, movedownName, _dragWidget, true);
|
||||
$ax.event.addEvent(document, $ax.features.eventNames.mouseUpName, _stopDragWidget, true);
|
||||
|
||||
// if(IE && BROWSER_VERSION < 9) {
|
||||
// if($ax.features.supports.windowsMobile) {
|
||||
// window.document.attachEvent($ax.features.eventNames.mouseDownName, _dragWidget);
|
||||
// window.document.attachEvent($ax.features.eventNames.mouseUpName, _stopDragWidget);
|
||||
// } else {
|
||||
// window.document.attachEvent('on' + $ax.features.eventNames.mouseMoveName, _dragWidget);
|
||||
// window.document.attachEvent('on' + $ax.features.eventNames.mouseUpName, _stopDragWidget);
|
||||
// }
|
||||
// } else {
|
||||
// window.document.addEventListener($ax.features.eventNames.mouseMoveName, _dragWidget, true);
|
||||
// window.document.addEventListener($ax.features.eventNames.mouseUpName, _stopDragWidget, true);
|
||||
// }
|
||||
$ax.legacy.SuppressBubble(event);
|
||||
};
|
||||
|
||||
var _dragWidget = function(event) {
|
||||
$ax.setjBrowserEvent(jQuery.Event(event));
|
||||
|
||||
var x, y;
|
||||
if(IE_10_AND_BELOW) {
|
||||
x = window.event.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft;
|
||||
y = window.event.clientY + window.document.documentElement.scrollTop + window.document.body.scrollTop;
|
||||
} else {
|
||||
if(event.changedTouches) {
|
||||
x = event.changedTouches[0].pageX;
|
||||
y = event.changedTouches[0].pageY;
|
||||
//allow scroll (defaults) if only swipe events have cases and delta x is less than 5px and not blocking scrolling
|
||||
var deltaX = x - widgetDragInfo.currentX;
|
||||
var target = window.document.getElementById(widgetDragInfo.widgetId);
|
||||
if($ax.event.hasSyntheticEvent(widgetDragInfo.widgetId, "onDrag") || $ax.event.hasSyntheticEvent(widgetDragInfo.widgetId, "onSwipeUp") ||
|
||||
$ax.event.hasSyntheticEvent(widgetDragInfo.widgetId, "onSwipeDown") || (deltaX * deltaX) > 25
|
||||
|| ($ax.document.configuration.preventScroll && $ax.legacy.GetScrollable(target) == window.document.body)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
} else {
|
||||
x = event.pageX;
|
||||
y = event.pageY;
|
||||
}
|
||||
}
|
||||
widgetDragInfo.xDelta = x - widgetDragInfo.currentX;
|
||||
widgetDragInfo.yDelta = y - widgetDragInfo.currentY;
|
||||
widgetDragInfo.lastX = widgetDragInfo.currentX;
|
||||
widgetDragInfo.lastY = widgetDragInfo.currentY;
|
||||
widgetDragInfo.currentX = x;
|
||||
widgetDragInfo.currentY = y;
|
||||
|
||||
widgetDragInfo.currentTime = (new Date()).getTime();
|
||||
|
||||
$ax.legacy.SuppressBubble(event);
|
||||
|
||||
if(!widgetDragInfo.hasStarted) {
|
||||
widgetDragInfo.hasStarted = true;
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onDragStart");
|
||||
|
||||
widgetDragInfo.oldBodyCursor = window.document.body.style.cursor;
|
||||
window.document.body.style.cursor = 'move';
|
||||
var widget = window.document.getElementById(widgetDragInfo.widgetId);
|
||||
widgetDragInfo.oldCursor = widget.style.cursor;
|
||||
widget.style.cursor = 'move';
|
||||
}
|
||||
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onDrag");
|
||||
};
|
||||
|
||||
var _suppressClickAfterDrag = function(event) {
|
||||
_removeSuppressEvents();
|
||||
|
||||
$ax.legacy.SuppressBubble(event);
|
||||
};
|
||||
|
||||
var _removeSuppressEvents = function () {
|
||||
if(IE_10_AND_BELOW) {
|
||||
$ax.event.removeEvent(event.srcElement, 'click', _suppressClickAfterDrag, undefined, true);
|
||||
$ax.event.removeEvent(widgetDragInfo.targetWidget, 'mousemove', _removeSuppressEvents, undefined, true);
|
||||
} else {
|
||||
$ax.event.removeEvent(document, "click", _suppressClickAfterDrag, true);
|
||||
$ax.event.removeEvent(document, 'mousemove', _removeSuppressEvents, true);
|
||||
}
|
||||
};
|
||||
|
||||
var _stopDragWidget = function(event) {
|
||||
$ax.setjBrowserEvent(jQuery.Event(event));
|
||||
|
||||
var tg;
|
||||
|
||||
|
||||
var movedownName = IE_10_AND_BELOW && $ax.features.supports.windowsMobile ?
|
||||
$ax.features.eventNames.mouseDownName : $ax.features.eventNames.mouseMoveName;
|
||||
$ax.event.removeEvent(document, movedownName, _dragWidget, true);
|
||||
$ax.event.removeEvent(document, $ax.features.eventNames.mouseUpName, _stopDragWidget, true);
|
||||
|
||||
tg = IE_10_AND_BELOW ? window.event.srcElement : event.target;
|
||||
//
|
||||
//
|
||||
// if(OLD_IE && BROWSER_VERSION < 9) {
|
||||
// if($ax.features.supports.windowsMobile) {
|
||||
// window.document.detachEvent($ax.features.eventNames.mouseDownName, _dragWidget);
|
||||
// window.document.detachEvent($ax.features.eventNames.mouseUpName, _stopDragWidget);
|
||||
//
|
||||
// } else {
|
||||
// window.document.detachEvent('on' + $ax.features.eventNames.mouseMoveName, _dragWidget);
|
||||
// window.document.detachEvent('on' + $ax.features.eventNames.mouseUpName, _stopDragWidget);
|
||||
// }
|
||||
// tg = window.event.srcElement;
|
||||
// } else {
|
||||
// window.document.removeEventListener($ax.features.eventNames.mouseMoveName, _dragWidget, true);
|
||||
// window.document.removeEventListener($ax.features.eventNames.mouseUpName, _stopDragWidget, true);
|
||||
// tg = event.target;
|
||||
// }
|
||||
|
||||
if(widgetDragInfo.hasStarted) {
|
||||
widgetDragInfo.currentTime = (new Date()).getTime();
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onDragDrop");
|
||||
|
||||
if($ax.globalVariableProvider.getVariableValue('totaldragx') < -30 && $ax.globalVariableProvider.getVariableValue('dragtime') < 1000) {
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onSwipeLeft");
|
||||
}
|
||||
|
||||
if($ax.globalVariableProvider.getVariableValue('totaldragx') > 30 && $ax.globalVariableProvider.getVariableValue('dragtime') < 1000) {
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onSwipeRight");
|
||||
}
|
||||
|
||||
var totalDragY = $ax.globalVariableProvider.getVariableValue('totaldragy');
|
||||
if(totalDragY < -30 && $ax.globalVariableProvider.getVariableValue('dragtime') < 1000) {
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onSwipeUp");
|
||||
}
|
||||
|
||||
if(totalDragY > 30 && $ax.globalVariableProvider.getVariableValue('dragtime') < 1000) {
|
||||
$ax.event.raiseSyntheticEvent(widgetDragInfo.widgetId, "onSwipeDown");
|
||||
}
|
||||
|
||||
window.document.body.style.cursor = widgetDragInfo.oldBodyCursor;
|
||||
var widget = window.document.getElementById(widgetDragInfo.widgetId);
|
||||
// It may be null if OnDragDrop filtered out the widget
|
||||
if(widget != null) widget.style.cursor = widgetDragInfo.oldCursor;
|
||||
|
||||
if(widgetDragInfo.targetWidget == tg && !event.changedTouches) {
|
||||
// suppress the click after the drag on desktop browsers
|
||||
if(IE_10_AND_BELOW && widgetDragInfo.targetWidget) {
|
||||
$ax.event.addEvent(widgetDragInfo.targetWidget, 'click', _suppressClickAfterDrag, true, true);
|
||||
$ax.event.addEvent(widgetDragInfo.targetWidget, "onmousemove", _removeSuppressEvents, true, true);
|
||||
} else {
|
||||
$ax.event.addEvent(document, "click", _suppressClickAfterDrag, true);
|
||||
$ax.event.addEvent(document, "mousemove", _removeSuppressEvents, true);
|
||||
|
||||
}
|
||||
//
|
||||
//
|
||||
// if(IE && BROWSER_VERSION < 9 && widgetDragInfo.targetWidget) {
|
||||
// widgetDragInfo.targetWidget.attachEvent("onclick", _suppressClickAfterDrag);
|
||||
// widgetDragInfo.targetWidget.attachEvent("onmousemove", _removeSuppressEvents);
|
||||
// } else {
|
||||
// window.document.addEventListener("click", _suppressClickAfterDrag, true);
|
||||
// window.document.addEventListener("mousemove", _removeSuppressEvents, true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
widgetDragInfo.hasStarted = false;
|
||||
widgetDragInfo.movedWidgets = new Object();
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
$ax.drag.GetDragX = function() {
|
||||
if(widgetDragInfo.hasStarted) return widgetDragInfo.xDelta;
|
||||
return 0;
|
||||
};
|
||||
|
||||
$ax.drag.GetDragY = function() {
|
||||
if(widgetDragInfo.hasStarted) return widgetDragInfo.yDelta;
|
||||
return 0;
|
||||
};
|
||||
|
||||
$ax.drag.GetTotalDragX = function() {
|
||||
if(widgetDragInfo.hasStarted) return widgetDragInfo.currentX - widgetDragInfo.cursorStartX;
|
||||
return 0;
|
||||
};
|
||||
|
||||
$ax.drag.GetTotalDragY = function() {
|
||||
if(widgetDragInfo.hasStarted) return widgetDragInfo.currentY - widgetDragInfo.cursorStartY;
|
||||
return 0;
|
||||
};
|
||||
|
||||
$ax.drag.GetDragTime = function() {
|
||||
if(widgetDragInfo.hasStarted) return widgetDragInfo.currentTime - widgetDragInfo.startTime;
|
||||
return 600000;
|
||||
};
|
||||
|
||||
// $ax.drag.GetCursorRectangles = function() {
|
||||
// var rects = new Object();
|
||||
// rects.lastRect = new rect($ax.lastMouseLocation.x, $ax.lastMouseLocation.y, 1, 1);
|
||||
// rects.currentRect = new rect($ax.mouseLocation.x, $ax.mouseLocation.y, 1, 1);
|
||||
// return rects;
|
||||
// };
|
||||
|
||||
// $ax.drag.GetWidgetRectangles = function(id) {
|
||||
// var widget = window.document.getElementById(id);
|
||||
// var rects = new Object();
|
||||
// rects.lastRect = new rect($ax.legacy.getAbsoluteLeft(widget), $ax.legacy.getAbsoluteTop(widget), Number($('#' + id).css('width').replace("px", "")), Number($('#' + id).css('height').replace("px", "")));
|
||||
// rects.currentRect = rects.lastRect;
|
||||
// return rects;
|
||||
// };
|
||||
|
||||
// $ax.drag.IsEntering = function(movingRects, targetRects) {
|
||||
// return !movingRects.lastRect.IntersectsWith(targetRects.currentRect) && movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
// };
|
||||
|
||||
// $ax.drag.IsLeaving = function(movingRects, targetRects) {
|
||||
// return movingRects.lastRect.IntersectsWith(targetRects.currentRect) && !movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
// };
|
||||
|
||||
// function IsOver(movingRects, targetRects) {
|
||||
// return movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
// }
|
||||
|
||||
// function IsNotOver(movingRects, targetRects) {
|
||||
// return !IsOver(movingRects, targetRects);
|
||||
// }
|
||||
|
||||
$ax.drag.LogMovedWidgetForDrag = function (id, dragInfo) {
|
||||
dragInfo = dragInfo || widgetDragInfo;
|
||||
if(dragInfo.hasStarted) {
|
||||
var containerIndex = id.indexOf('_container');
|
||||
if(containerIndex != -1) id = id.substring(0, containerIndex);
|
||||
|
||||
// If state or other non-widget id, this should not be dragged, and should exit out to avoid exceptions.
|
||||
if(!$obj(id)) return;
|
||||
|
||||
var query = $ax('#' + id);
|
||||
var x = query.left();
|
||||
var y = query.top();
|
||||
|
||||
var movedWidgets = dragInfo.movedWidgets;
|
||||
if(!movedWidgets[id]) {
|
||||
movedWidgets[id] = new Location(x, y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var Location = function(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
$ax.drag.location = Location;
|
||||
|
||||
var Rectangle = $ax.drag.Rectangle = function(x, y, width, height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.right = x + width;
|
||||
this.bottom = y + height;
|
||||
};
|
||||
|
||||
Rectangle.prototype.IntersectsWith = function(rect) {
|
||||
if(this.Invalid()) return false;
|
||||
if(rect.length) {
|
||||
for(var i = 0; i < rect.length; i++) if(!rect[i].Invalid && this.IntersectsWith(rect[i])) return true;
|
||||
return false;
|
||||
}
|
||||
if(rect.Invalid()) return false;
|
||||
return this.x < rect.right && this.right > rect.x && this.y < rect.bottom && this.bottom > rect.y;
|
||||
};
|
||||
|
||||
Rectangle.prototype.Invalid = function() {
|
||||
return this.x == -1 && this.y == -1 && this.width == -1 && this.height == -1;
|
||||
};
|
||||
|
||||
Rectangle.prototype.Move = function(x, y) {
|
||||
return new Rectangle(x, y, this.width, this.height);
|
||||
};
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,554 @@
|
||||
// ******* Expr MANAGER ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var _expr = $ax.expr = {};
|
||||
var _binOpHandlers = {
|
||||
'&&': function(left, right) { return _binOpOverride(left, right, function(left) { return $ax.getBool(left) && $ax.getBool(right()); }); },
|
||||
'||': function(left, right) { return _binOpOverride(left, right, function(left) { return $ax.getBool(left) || $ax.getBool(right()); }); },
|
||||
'==': function(left, right) { return isEqual(left, right, true); },
|
||||
'!=': function(left, right) { return !isEqual(left, right, true); },
|
||||
'>': function(left, right) { return _binOpNum(left, right, function(left, right) { return left > right; }); },
|
||||
'<': function(left, right) { return _binOpNum(left, right, function(left, right) { return left < right; }); },
|
||||
'>=': function(left, right) { return _binOpNum(left, right, function(left, right) { return left >= right; }); },
|
||||
'<=': function(left, right) { return _binOpNum(left, right, function(left, right) { return left <= right; }); }
|
||||
};
|
||||
|
||||
var checkOps = function(left, right) {
|
||||
return left == undefined || right == undefined;
|
||||
};
|
||||
|
||||
var isEqual = function (left, right, isFunction) {
|
||||
if (isFunction) {
|
||||
//if left and right is function, then get the value
|
||||
//otherwise left and right should be already the value we want
|
||||
left = left();
|
||||
right = right();
|
||||
}
|
||||
|
||||
if(checkOps(left, right)) return false;
|
||||
|
||||
if(left instanceof Date && right instanceof Date) {
|
||||
if(left.getMilliseconds() != right.getMilliseconds()) return false;
|
||||
if(left.getSeconds() != right.getSeconds()) return false;
|
||||
if(left.getMinutes() != right.getMinutes()) return false;
|
||||
if(left.getHours() != right.getHours()) return false;
|
||||
if(left.getDate() != right.getDate()) return false;
|
||||
if(left.getMonth() != right.getMonth()) return false;
|
||||
if(left.getYear() != right.getYear()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(left instanceof Object && right instanceof Object) {
|
||||
var prop;
|
||||
// Go through all of lefts properties and compare them to rights.
|
||||
for(prop in left) {
|
||||
if(!left.hasOwnProperty(prop)) continue;
|
||||
// If left has a property that the right doesn't they are not equal.
|
||||
if(!right.hasOwnProperty(prop)) return false;
|
||||
// If any of their properties are not equal, they are not equal.
|
||||
if(!isEqual(left[prop], right[prop], false)) return false;
|
||||
}
|
||||
|
||||
for(prop in right) {
|
||||
// final check to make sure right doesn't have some extra properties that make them not equal.
|
||||
if(left.hasOwnProperty(prop) != right.hasOwnProperty(prop)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return $ax.getBool(left) == $ax.getBool(right);
|
||||
};
|
||||
|
||||
var _binOpOverride = function(left, right, func) {
|
||||
left = left();
|
||||
if(left == undefined) return false;
|
||||
var res = func(left, right);
|
||||
return res == undefined ? false : res;
|
||||
};
|
||||
|
||||
var _binOpNum = function(left, right, func) {
|
||||
var left = left();
|
||||
var right = right();
|
||||
if(checkOps(left, right)) return false;
|
||||
|
||||
return func(left, Number(right));
|
||||
};
|
||||
|
||||
var _exprHandlers = {};
|
||||
_exprHandlers.array = function(expr, eventInfo) {
|
||||
var returnVal = [];
|
||||
for(var i = 0; i < expr.items.length; i++) {
|
||||
returnVal[returnVal.length] = _evaluateExpr(expr.items[i], eventInfo);
|
||||
}
|
||||
return returnVal;
|
||||
};
|
||||
|
||||
_exprHandlers.binaryOp = function(expr, eventInfo) {
|
||||
var left = function() { return expr.leftExpr && _evaluateExpr(expr.leftExpr, eventInfo); };
|
||||
var right = function() { return expr.rightExpr && _evaluateExpr(expr.rightExpr, eventInfo); };
|
||||
|
||||
if(left == undefined || right == undefined) return false;
|
||||
return _binOpHandlers[expr.op](left, right);
|
||||
};
|
||||
|
||||
_exprHandlers.block = function(expr, eventInfo) {
|
||||
var subExprs = expr.subExprs;
|
||||
for(var i = 0; i < subExprs.length; i++) {
|
||||
_evaluateExpr(subExprs[i], eventInfo); //ignore the result
|
||||
}
|
||||
};
|
||||
|
||||
_exprHandlers.booleanLiteral = function(expr) {
|
||||
return expr.value;
|
||||
};
|
||||
|
||||
_exprHandlers.nullLiteral = function() { return null; };
|
||||
|
||||
_exprHandlers.pathLiteral = function(expr, eventInfo) {
|
||||
if(expr.isThis) return [eventInfo.srcElement];
|
||||
if(expr.isFocused && window.lastFocusedControl) {
|
||||
$ax('#' + window.lastFocusedControl).focus();
|
||||
return [window.lastFocusedControl];
|
||||
}
|
||||
if(expr.isTarget) return [eventInfo.targetElement];
|
||||
|
||||
return $ax.getElementIdsFromPath(expr.value, eventInfo);
|
||||
};
|
||||
|
||||
_exprHandlers.panelDiagramLiteral = function(expr, eventInfo) {
|
||||
var elementIds = $ax.getElementIdsFromPath(expr.panelPath, eventInfo);
|
||||
var elementIdsWithSuffix = [];
|
||||
var suffix = '_state' + expr.panelIndex;
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
elementIdsWithSuffix[i] = $ax.repeater.applySuffixToElementId(elementIds[i], suffix);
|
||||
}
|
||||
return String($jobj(elementIdsWithSuffix).data('label'));
|
||||
};
|
||||
|
||||
_exprHandlers.fcall = function(expr, eventInfo) {
|
||||
var oldTarget = eventInfo.targetElement;
|
||||
var targets = [];
|
||||
var fcallArgs = [];
|
||||
var exprArgs = expr.arguments;
|
||||
for(var i = 0; i < expr.arguments.length; i++) {
|
||||
var exprArg = exprArgs[i];
|
||||
var fcallArg = '';
|
||||
if(targets.length) {
|
||||
for(var j = 0; j < targets.length; j++) {
|
||||
if(exprArg == null) {
|
||||
fcallArgs[j][i] = null;
|
||||
continue;
|
||||
}
|
||||
eventInfo.targetElement = targets[j];
|
||||
fcallArg = _evaluateExpr(exprArg, eventInfo);
|
||||
if(typeof (fcallArg) == 'undefined') return '';
|
||||
fcallArgs[j][i] = fcallArg;
|
||||
}
|
||||
} else {
|
||||
if(exprArg == null) {
|
||||
fcallArgs[i] = null;
|
||||
continue;
|
||||
}
|
||||
fcallArg = _evaluateExpr(exprArg, eventInfo);
|
||||
if(typeof (fcallArg) == 'undefined') return '';
|
||||
fcallArgs[i] = fcallArg;
|
||||
}
|
||||
|
||||
// We do support null exprArgs...
|
||||
// TODO: This makes 2 assumptions that may change in the future. 1. The pathLiteral is the always the first arg. 2. there is always only 1 pathLiteral
|
||||
if(exprArg && exprArg.exprType == 'pathLiteral') {
|
||||
targets = fcallArg;
|
||||
|
||||
// fcallArgs is now an array of an array of args
|
||||
for(j = 0; j < targets.length; j++) fcallArgs[j] = [[fcallArg[j]]];
|
||||
}
|
||||
}
|
||||
|
||||
// we want to preserve the target element from outside this function.
|
||||
eventInfo.targetElement = oldTarget;
|
||||
|
||||
var retval = '';
|
||||
if(targets.length) {
|
||||
// Go backwards so retval is the first item.
|
||||
for(i = targets.length - 1; i >= 0; i--) {
|
||||
var args = fcallArgs[i];
|
||||
// Add event info to the end
|
||||
args[args.length] = eventInfo;
|
||||
retval = _exprFunctions[expr.functionName].apply(this, args);
|
||||
}
|
||||
} else fcallArgs[fcallArgs.length] = eventInfo;
|
||||
return targets.length ? retval : _exprFunctions[expr.functionName].apply(this, fcallArgs);
|
||||
};
|
||||
|
||||
_exprHandlers.globalVariableLiteral = function(expr) {
|
||||
return expr.variableName;
|
||||
};
|
||||
|
||||
_exprHandlers.keyPressLiteral = function(expr) {
|
||||
var keyInfo = {};
|
||||
keyInfo.keyCode = expr.keyCode;
|
||||
keyInfo.ctrl = expr.ctrl;
|
||||
keyInfo.alt = expr.alt;
|
||||
keyInfo.shift = expr.shift;
|
||||
|
||||
return keyInfo;
|
||||
};
|
||||
|
||||
_exprHandlers.adaptiveViewLiteral = function(expr) {
|
||||
return expr.id;
|
||||
};
|
||||
|
||||
_exprHandlers.optionLiteral = function(expr) {
|
||||
return expr.value;
|
||||
}
|
||||
|
||||
var _substituteSTOs = function(expr, eventInfo) {
|
||||
//first evaluate the local variables
|
||||
var scope = {};
|
||||
for(var varName in expr.localVariables) {
|
||||
scope[varName] = $ax.expr.evaluateExpr(expr.localVariables[varName], eventInfo);
|
||||
}
|
||||
|
||||
// TODO: [ben] Date and data object (obj with info for url or image) both need to return non-strings.
|
||||
var i = 0;
|
||||
var retval;
|
||||
var retvalString = expr.value.replace(/\[\[(?!\[)(.*?)\]\](?=\]*)/g, function(match) {
|
||||
var sto = expr.stos[i++];
|
||||
if(sto.sto == 'error') return match;
|
||||
try {
|
||||
var result = $ax.evaluateSTO(sto, scope, eventInfo);
|
||||
} catch(e) {
|
||||
return match;
|
||||
}
|
||||
|
||||
if((result instanceof Object) && i == 1 && expr.value.substring(0, 2) == '[[' &&
|
||||
expr.value.substring(expr.value.length - 2) == ']]') {
|
||||
// If the result was an object, this was the first result, and the whole thing was this expresion.
|
||||
retval = result;
|
||||
}
|
||||
return ((result instanceof Object) && (result.label || result.text)) || result;
|
||||
});
|
||||
// If more than one group returned, the object is not valid
|
||||
if(i != 1) retval = false;
|
||||
return retval || retvalString;
|
||||
};
|
||||
|
||||
_exprHandlers.htmlLiteral = function (expr, eventInfo) {
|
||||
eventInfo.htmlLiteral = true;
|
||||
var html = _substituteSTOs(expr, eventInfo);
|
||||
eventInfo.htmlLiteral = false
|
||||
return html;
|
||||
};
|
||||
|
||||
_exprHandlers.stringLiteral = function(expr, eventInfo) {
|
||||
return _substituteSTOs(expr, eventInfo);
|
||||
};
|
||||
|
||||
var _exprFunctions = {};
|
||||
|
||||
_exprFunctions.SetCheckState = function(elementIds, value) {
|
||||
var toggle = value == 'toggle';
|
||||
var boolValue = Boolean(value) && value != 'false';
|
||||
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
var query = $ax('#' + elementIds[i]);
|
||||
query.selected(toggle ? !query.selected() : boolValue);
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.SetSelectedOption = function(elementIds, value) {
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
var elementId = elementIds[i];
|
||||
var obj = $jobj($ax.INPUT(elementId));
|
||||
|
||||
if(obj.val() == value) return;
|
||||
obj.val(value);
|
||||
|
||||
if($ax.event.HasSelectionChanged($ax.getObjectFromElementId(elementId))) $ax.event.raiseSyntheticEvent(elementId, 'onSelectionChange');
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.SetGlobalVariableValue = function(varName, value) {
|
||||
$ax.globalVariableProvider.setVariableValue(varName, value);
|
||||
};
|
||||
|
||||
_exprFunctions.SetWidgetFormText = function(elementIds, value) {
|
||||
for(var i = 0; i < elementIds.length; i++) {
|
||||
var elementId = elementIds[i];
|
||||
var inputId = $ax.repeater.applySuffixToElementId(elementId, '_input');
|
||||
|
||||
var obj = $jobj(inputId);
|
||||
if(obj.val() == value || (value == '' && $ax.placeholderManager.isActive(elementId))) return;
|
||||
obj.val(value);
|
||||
$ax.placeholderManager.updatePlaceholder(elementId, !value);
|
||||
if($ax.event.HasTextChanged($ax.getObjectFromElementId(elementId))) $ax.event.TryFireTextChanged(elementId);
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.SetFocusedWidgetText = function(elementId, value) {
|
||||
if(window.lastFocusedControl) {
|
||||
var elementId = window.lastFocusedControl;
|
||||
var type = $obj(elementId).type;
|
||||
if ($ax.public.fn.IsTextBox(type) || $ax.public.fn.IsTextArea(type)) _exprFunctions.SetWidgetFormText([elementId], value);
|
||||
else _exprFunctions.SetWidgetRichText([elementId], value, true);
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.GetRtfElementHeight = function(rtfElement) {
|
||||
if(rtfElement.innerHTML == '') rtfElement.innerHTML = ' ';
|
||||
return rtfElement.offsetHeight;
|
||||
};
|
||||
|
||||
_exprFunctions.SetWidgetRichText = function(ids, value, plain) {
|
||||
// Converts dates, widgetinfo, and the like to strings.
|
||||
value = _exprFunctions.ToString(value);
|
||||
|
||||
//Replace any newlines with line breaks
|
||||
var finalValue = value.replace(/\r\n/g, '<br>').replace(/\n/g, '<br>');
|
||||
|
||||
for(var i = 0; i < ids.length; i++) {
|
||||
var id = ids[i];
|
||||
|
||||
// If calling this on button shape, get the id of the rich text panel inside instead
|
||||
var type = $obj(id).type;
|
||||
if(type != 'richTextPanel' && type != 'hyperlink') {
|
||||
id = $jobj(id).find('.text')[0].id;
|
||||
}
|
||||
|
||||
var element = window.document.getElementById(id);
|
||||
$ax.visibility.SetVisible(element, value != '');
|
||||
|
||||
$ax.style.transformTextWithVerticalAlignment(id, function() {
|
||||
var spans = $jobj(id).find('span');
|
||||
if(plain) {
|
||||
// Wrap in span and p, style them accordingly.
|
||||
var span = $('<span></span>');
|
||||
if(spans.length > 0) {
|
||||
span.attr('style', $(spans[0]).attr('style'));
|
||||
span.attr('id', $(spans[0]).attr('id'));
|
||||
}
|
||||
|
||||
// Can't set value as text because '<br/>' doesn't actually do a line break
|
||||
// Can't set vaule as html because it doesn't like '<' and ignores all after it
|
||||
// Create tags yourself
|
||||
var lines = value.split(/\r\n|\n/);
|
||||
if(lines.length == 1) span.text(value);
|
||||
else {
|
||||
for(var i = 0; i < lines.length; i++) {
|
||||
if (i != 0) span.append($('<br />'));
|
||||
var line = lines[i];
|
||||
if(line.length == 0) continue;
|
||||
|
||||
var subSpan = $('<span />');
|
||||
subSpan.text(line);
|
||||
span.append(subSpan);
|
||||
}
|
||||
}
|
||||
|
||||
var p = $('<p></p>');
|
||||
var ps = $jobj(id).find('p');
|
||||
if(ps.length > 0) {
|
||||
p.attr('style', $(ps[0]).attr('style'));
|
||||
p.attr('id', $(ps[0]).attr('id'));
|
||||
}
|
||||
p.append(span);
|
||||
finalValue = $('<div></div>').append(p).html();
|
||||
}
|
||||
|
||||
element.innerHTML = finalValue;
|
||||
});
|
||||
|
||||
if(!plain) $ax.style.CacheOriginalText(id, true);
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.GetCheckState = function(ids) {
|
||||
return $ax('#' + ids[0]).selected();
|
||||
};
|
||||
|
||||
_exprFunctions.GetSelectedOption = function (ids) {
|
||||
var inputs = $jobj($ax.INPUT(ids[0]));
|
||||
return inputs.length ? inputs[0].value : '';
|
||||
};
|
||||
|
||||
_exprFunctions.GetNum = function(str) {
|
||||
//Setting a GlobalVariable to some blank text then setting a widget to the value of that variable would result in 0 not ""
|
||||
//I have fixed this another way so commenting this should be fine now
|
||||
//if (!str) return "";
|
||||
return isNaN(str) ? str : Number(str);
|
||||
};
|
||||
|
||||
_exprFunctions.GetGlobalVariableValue = function(id) {
|
||||
return $ax.globalVariableProvider.getVariableValue(id);
|
||||
};
|
||||
|
||||
_exprFunctions.GetGlobalVariableLength = function(id) {
|
||||
return _exprFunctions.GetGlobalVariableValue(id).length;
|
||||
};
|
||||
|
||||
_exprFunctions.GetWidgetText = function(ids) {
|
||||
if($ax.placeholderManager.isActive(ids[0])) return '';
|
||||
var input = $ax.INPUT(ids[0]);
|
||||
return $ax('#' + ($jobj(input).length ? input : ids[0])).text();
|
||||
};
|
||||
|
||||
_exprFunctions.GetFocusedWidgetText = function() {
|
||||
if(window.lastFocusedControl) {
|
||||
return $ax('#' + window.lastFocusedControl).text();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
_exprFunctions.GetWidgetValueLength = function(ids) {
|
||||
var id = ids[0];
|
||||
if(!id) return undefined;
|
||||
if($ax.placeholderManager.isActive(id)) return 0;
|
||||
var obj = $jobj($ax.INPUT(id));
|
||||
if(!obj.length) obj = $jobj(id);
|
||||
var val = obj[0].value || _exprFunctions.GetWidgetText([id]);
|
||||
return val.length;
|
||||
};
|
||||
|
||||
_exprFunctions.GetPanelState = function(ids) {
|
||||
var id = ids[0];
|
||||
if(!id) return undefined;
|
||||
var stateId = $ax.visibility.GetPanelState(id);
|
||||
return stateId && String($jobj(stateId).data('label'));
|
||||
};
|
||||
|
||||
_exprFunctions.GetWidgetVisibility = function(ids) {
|
||||
var id = ids[0];
|
||||
if(!id) return undefined;
|
||||
return $ax.visibility.IsIdVisible(id);
|
||||
};
|
||||
|
||||
// ***************** Validation Functions ***************** //
|
||||
|
||||
_exprFunctions.IsValueAlpha = function(val) {
|
||||
var isAlphaRegex = new RegExp("^[a-z\\s]+$", "gi");
|
||||
return isAlphaRegex.test(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueNumeric = function(val) {
|
||||
var isNumericRegex = new RegExp("^[0-9,\\.\\s]+$", "gi");
|
||||
return isNumericRegex.test(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueAlphaNumeric = function(val) {
|
||||
var isAlphaNumericRegex = new RegExp("^[0-9a-z\\s]+$", "gi");
|
||||
return isAlphaNumericRegex.test(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueOneOf = function(val, values) {
|
||||
for(var i = 0; i < values.length; i++) {
|
||||
var option = values[i];
|
||||
if(val == option) return true;
|
||||
}
|
||||
//by default, return false
|
||||
return false;
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueNotAlpha = function(val) {
|
||||
return !_exprFunctions.IsValueAlpha(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueNotNumeric = function(val) {
|
||||
return !_exprFunctions.IsValueNumeric(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueNotAlphaNumeric = function(val) {
|
||||
return !_exprFunctions.IsValueAlphaNumeric(val);
|
||||
};
|
||||
|
||||
_exprFunctions.IsValueNotOneOf = function(val, values) {
|
||||
return !_exprFunctions.IsValueOneOf(val, values);
|
||||
};
|
||||
|
||||
_exprFunctions.GetKeyPressed = function(eventInfo) {
|
||||
return eventInfo.keyInfo;
|
||||
};
|
||||
|
||||
_exprFunctions.GetCursorRectangles = function() {
|
||||
var rects = new Object();
|
||||
rects.lastRect = new $ax.drag.Rectangle($ax.lastMouseLocation.x, $ax.lastMouseLocation.y, 1, 1);
|
||||
rects.currentRect = new $ax.drag.Rectangle($ax.mouseLocation.x, $ax.mouseLocation.y, 1, 1);
|
||||
return rects;
|
||||
};
|
||||
|
||||
_exprFunctions.GetWidgetRectangles = function (elementIds, eventInfo) {
|
||||
var elementId = elementIds[0];
|
||||
var rects = new Object();
|
||||
var jObj = $jobj(elementId);
|
||||
var axObj = $ax('#' + elementId);
|
||||
var invalid = jObj.length == 0;
|
||||
var parent = jObj;
|
||||
// Or are in valid if no obj can be found, or if it is not visible.
|
||||
while(parent.length != 0 && !parent.is('body')) {
|
||||
if(parent.css('display') == 'none') {
|
||||
invalid = true;
|
||||
break;
|
||||
}
|
||||
parent = parent.parent();
|
||||
}
|
||||
if(invalid) {
|
||||
rects.lastRect = rects.currentRect = new $ax.drag.Rectangle(-1, -1, -1, -1);
|
||||
return rects;
|
||||
}
|
||||
|
||||
rects.lastRect = new $ax.drag.Rectangle(
|
||||
axObj.left(),
|
||||
axObj.top(),
|
||||
axObj.width(),
|
||||
axObj.height());
|
||||
|
||||
rects.currentRect = rects.lastRect;
|
||||
return rects;
|
||||
};
|
||||
|
||||
_exprFunctions.GetWidget = function(elementId) {
|
||||
return $ax.getWidgetInfo(elementId[0]);
|
||||
};
|
||||
|
||||
_exprFunctions.GetAdaptiveView = function() {
|
||||
return $ax.adaptive.currentViewId || '';
|
||||
};
|
||||
|
||||
_exprFunctions.IsEntering = function(movingRects, targetRects) {
|
||||
return !movingRects.lastRect.IntersectsWith(targetRects.currentRect) && movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
};
|
||||
|
||||
_exprFunctions.IsLeaving = function(movingRects, targetRects) {
|
||||
return movingRects.lastRect.IntersectsWith(targetRects.currentRect) && !movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
};
|
||||
|
||||
var _IsOver = _exprFunctions.IsOver = function(movingRects, targetRects) {
|
||||
return movingRects.currentRect.IntersectsWith(targetRects.currentRect);
|
||||
};
|
||||
|
||||
_exprFunctions.IsNotOver = function(movingRects, targetRects) {
|
||||
return !_IsOver(movingRects, targetRects);
|
||||
};
|
||||
|
||||
_exprFunctions.ValueContains = function(inputString, value) {
|
||||
return inputString.indexOf(value) > -1;
|
||||
};
|
||||
|
||||
_exprFunctions.ValueNotContains = function(inputString, value) {
|
||||
return !_exprFunctions.ValueContains(inputString, value);
|
||||
};
|
||||
|
||||
_exprFunctions.ToString = function(value) {
|
||||
if(value.isWidget) {
|
||||
return value.text;
|
||||
}
|
||||
return String(value);
|
||||
};
|
||||
|
||||
var _evaluateExpr = $ax.expr.evaluateExpr = function(expr, eventInfo, toString) {
|
||||
if(expr === undefined || expr === null) return undefined;
|
||||
var result = _exprHandlers[expr.exprType](expr, eventInfo);
|
||||
return toString ? _exprFunctions.ToString(result) : result;
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,273 @@
|
||||
// ******* Flyout MANAGER ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var _flyoutManager = $ax.flyoutManager = {};
|
||||
|
||||
var getFlyoutLabel = function(panelId) {
|
||||
return panelId + '_flyout';
|
||||
};
|
||||
|
||||
var _unregisterPanel = function(panelId, keepShown) {
|
||||
$ax.geometry.unregister(getFlyoutLabel(panelId));
|
||||
if(panelToSrc[panelId]) {
|
||||
$ax.style.RemoveRolloverOverride(panelToSrc[panelId]);
|
||||
delete panelToSrc[panelId];
|
||||
}
|
||||
if(!keepShown) {
|
||||
$ax.action.addAnimation(panelId, $ax.action.queueTypes.fade, function() {
|
||||
$ax('#' + panelId).hide();
|
||||
});
|
||||
}
|
||||
};
|
||||
_flyoutManager.unregisterPanel = _unregisterPanel;
|
||||
|
||||
var genPoint = $ax.geometry.genPoint;
|
||||
|
||||
var _updateFlyout = function(panelId) {
|
||||
var label = getFlyoutLabel(panelId);
|
||||
if(!$ax.geometry.polygonRegistered(label)) return;
|
||||
var info = $ax.geometry.getPolygonInfo(label);
|
||||
var rects = info && info.rects;
|
||||
|
||||
var targetWidget = $ax.getWidgetInfo(panelId);
|
||||
rects.target = $ax.geometry.genRect(targetWidget);
|
||||
|
||||
// Src will stay the same, just updating
|
||||
$ax.flyoutManager.registerFlyout(rects, panelId, panelToSrc[panelId]);
|
||||
|
||||
if(!$ax.geometry.checkInsideRegion(label)) _unregisterPanel(panelId);
|
||||
};
|
||||
_flyoutManager.updateFlyout = _updateFlyout;
|
||||
|
||||
var panelToSrc = {};
|
||||
var _registerFlyout = function(rects, panelId, srcId) {
|
||||
var label = _getFlyoutLabel(panelId);
|
||||
var callback = function(info) {
|
||||
// If leaving object or already outside it, then unregister, otherwise just return
|
||||
if(!info.exiting && !info.outside) return;
|
||||
_unregisterPanel(panelId);
|
||||
};
|
||||
var points = [];
|
||||
|
||||
var lastSrcId = panelToSrc[panelId];
|
||||
if(lastSrcId != srcId) {
|
||||
if(lastSrcId) $ax.style.RemoveRolloverOverride(lastSrcId);
|
||||
if(srcId) {
|
||||
$ax.style.AddRolloverOverride(srcId);
|
||||
panelToSrc[panelId] = srcId;
|
||||
} else delete panelToSrc[panelId];
|
||||
}
|
||||
|
||||
// rects should be one or two rectangles
|
||||
if(!rects.src) {
|
||||
var rect = rects.target;
|
||||
points.push(genPoint(rect.Left(), rect.Top()));
|
||||
points.push(genPoint(rect.Right(), rect.Top()));
|
||||
points.push(genPoint(rect.Right(), rect.Bottom()));
|
||||
points.push(genPoint(rect.Left(), rect.Bottom()));
|
||||
} else {
|
||||
var r0 = rects.src;
|
||||
var r1 = rects.target;
|
||||
|
||||
// Right left of right, left right of left, top below top, bottom above bottom
|
||||
var rlr = r0.Right() <= r1.Right();
|
||||
var lrl = r0.Left() >= r1.Left();
|
||||
var tbt = r0.Top() >= r1.Top();
|
||||
var bab = r0.Bottom() <= r1.Bottom();
|
||||
|
||||
var info = { rlr: rlr, lrl: lrl, tbt: tbt, bab: bab };
|
||||
|
||||
if((rlr && lrl) || (tbt && bab)) {
|
||||
points = getSmallPolygon(r0, r1, info);
|
||||
} else {
|
||||
points = getLargePolygon(r0, r1, info);
|
||||
}
|
||||
}
|
||||
|
||||
$ax.geometry.registerPolygon(label, points, callback, { rects: rects });
|
||||
};
|
||||
_flyoutManager.registerFlyout = _registerFlyout;
|
||||
|
||||
var _getFlyoutLabel = function(panelId) {
|
||||
return panelId + '_flyout';
|
||||
};
|
||||
|
||||
var _reregisterAllFlyouts = function() {
|
||||
for(var panelId in panelToSrc) _reregisterFlyout(panelId);
|
||||
};
|
||||
_flyoutManager.reregisterAllFlyouts = _reregisterAllFlyouts;
|
||||
|
||||
var _reregisterFlyout = function(panelId) {
|
||||
var rects = $ax.geometry.getPolygonInfo(getFlyoutLabel(panelId)).rects;
|
||||
_registerFlyout(rects, panelId, panelToSrc[panelId]);
|
||||
};
|
||||
|
||||
// This is the reduced size polygon connecting r0 to r1 by means of horizontal or vertical lines.
|
||||
var getSmallPolygon = function(r0, r1, info) {
|
||||
var points = [];
|
||||
|
||||
// NOTE: currently I make the assumption that if horizontal/vertical connecting lines from the src hit the target
|
||||
// Meaning if horizontal, rlr and lrl are true, and if vertical, tbt and bab are true.
|
||||
|
||||
var r0Left = r0.Left();
|
||||
var r0Right = r0.Right();
|
||||
var r0Top = r0.Top();
|
||||
var r0Bottom = r0.Bottom();
|
||||
var r1Left = r1.Left();
|
||||
var r1Right = r1.Right();
|
||||
var r1Top = r1.Top();
|
||||
var r1Bottom = r1.Bottom();
|
||||
|
||||
points.push(genPoint(r1Left, r1Top));
|
||||
|
||||
if(!info.tbt) {
|
||||
points.push(genPoint(r0Left, r1Top));
|
||||
points.push(genPoint(r0Left, r0Top));
|
||||
points.push(genPoint(r0Right, r0Top));
|
||||
points.push(genPoint(r0Right, r1Top));
|
||||
}
|
||||
|
||||
points.push(genPoint(r1Right, r1Top));
|
||||
|
||||
if(!info.rlr) {
|
||||
points.push(genPoint(r1Right, r0Top));
|
||||
points.push(genPoint(r0Right, r0Top));
|
||||
points.push(genPoint(r0Right, r0Bottom));
|
||||
points.push(genPoint(r1Right, r0Bottom));
|
||||
}
|
||||
|
||||
points.push(genPoint(r1Right, r1Bottom));
|
||||
|
||||
if(!info.bab) {
|
||||
points.push(genPoint(r0Right, r1Bottom));
|
||||
points.push(genPoint(r0Right, r0Bottom));
|
||||
points.push(genPoint(r0Left, r0Bottom));
|
||||
points.push(genPoint(r0Left, r1Bottom));
|
||||
}
|
||||
|
||||
points.push(genPoint(r1Left, r1Bottom));
|
||||
|
||||
if(!info.lrl) {
|
||||
points.push(genPoint(r1Left, r0Bottom));
|
||||
points.push(genPoint(r0Left, r0Bottom));
|
||||
points.push(genPoint(r0Left, r0Top));
|
||||
points.push(genPoint(r1Left, r0Top));
|
||||
}
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
// This is the original algorithm that connects the most extream corners to make polygon
|
||||
var getLargePolygon = function(r0, r1, info) {
|
||||
var points = [];
|
||||
|
||||
var r0Left = r0.Left();
|
||||
var r0Right = r0.Right();
|
||||
var r0Top = r0.Top();
|
||||
var r0Bottom = r0.Bottom();
|
||||
var r1Left = r1.Left();
|
||||
var r1Right = r1.Right();
|
||||
var r1Top = r1.Top();
|
||||
var r1Bottom = r1.Bottom();
|
||||
|
||||
// Top lefts
|
||||
if(info.tbt) {
|
||||
if(!info.lrl) points.push(genPoint(r0Left, r0Top));
|
||||
points.push(genPoint(r1Left, r1Top));
|
||||
} else {
|
||||
if(info.lrl) points.push(genPoint(r1Left, r1Top));
|
||||
points.push(genPoint(r0Left, r0Top));
|
||||
}
|
||||
|
||||
// Top rights
|
||||
if(info.tbt) {
|
||||
points.push(genPoint(r1Right, r1Top));
|
||||
if(!info.rlr) points.push(genPoint(r0Right, r0Top));
|
||||
} else {
|
||||
points.push(genPoint(r0Right, r0Top));
|
||||
if(info.rlr) points.push(genPoint(r1Right, r1Top));
|
||||
}
|
||||
|
||||
// Bottom rights
|
||||
if(info.bab) {
|
||||
if(!info.rlr) points.push(genPoint(r0Right, r0Bottom));
|
||||
points.push(genPoint(r1Right, r1Bottom));
|
||||
} else {
|
||||
if(info.rlr) points.push(genPoint(r1Right, r1Bottom));
|
||||
points.push(genPoint(r0Right, r0Bottom));
|
||||
}
|
||||
|
||||
// Bottom Lefts
|
||||
if(info.bab) {
|
||||
points.push(genPoint(r1Left, r1Bottom));
|
||||
if(!info.lrl) points.push(genPoint(r0Left, r0Bottom));
|
||||
} else {
|
||||
points.push(genPoint(r0Left, r0Bottom));
|
||||
if(info.lrl) points.push(genPoint(r1Left, r1Bottom));
|
||||
}
|
||||
return points;
|
||||
};
|
||||
});
|
||||
|
||||
// ******* Placeholder Manager ********* //
|
||||
|
||||
$axure.internal(function($ax) {
|
||||
var _placeholderManager = $ax.placeholderManager = {};
|
||||
var idToPlaceholderInfo = {};
|
||||
|
||||
var _registerPlaceholder = function(elementId, text, password) {
|
||||
idToPlaceholderInfo[elementId] = { text: text, password: password, active: false };
|
||||
};
|
||||
_placeholderManager.registerPlaceholder = _registerPlaceholder;
|
||||
|
||||
_placeholderManager.refreshPlaceholder = function (elementId) {
|
||||
var info = idToPlaceholderInfo[elementId];
|
||||
if (!info || !info.active) return;
|
||||
$ax.style.SetWidgetPlaceholder(elementId, true, info.text, info.password);
|
||||
}
|
||||
|
||||
var _updatePlaceholder = function(elementId, active, clearText) {
|
||||
var inputId = $ax.repeater.applySuffixToElementId(elementId, '_input');
|
||||
|
||||
var info = idToPlaceholderInfo[elementId];
|
||||
if(!info || info.active == active) return;
|
||||
info.active = active;
|
||||
var value = active ? info.text : clearText ? '' : $jobj(inputId).val();
|
||||
$ax.style.SetWidgetPlaceholder(elementId, active, value, info.password);
|
||||
};
|
||||
_placeholderManager.updatePlaceholder = _updatePlaceholder;
|
||||
|
||||
var _isActive = function(elementId) {
|
||||
var info = idToPlaceholderInfo[elementId];
|
||||
return Boolean(info && info.active);
|
||||
};
|
||||
_placeholderManager.isActive = _isActive;
|
||||
|
||||
var _selectRange = function(elementId, start, end) {
|
||||
$jobj(elementId).each(function() {
|
||||
if(this.setSelectionRange) {
|
||||
var validTypes = ["text", "search", "url", "tel", "password"];
|
||||
if(this.tagName.toLowerCase() != "input" || validTypes.indexOf(this.type) > -1) {
|
||||
this.focus();
|
||||
this.setSelectionRange(start, end);
|
||||
}
|
||||
} else if(this.createTextRange) {
|
||||
var range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', end);
|
||||
range.moveStart('character', start);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
};
|
||||
_placeholderManager.selectRange = _selectRange;
|
||||
|
||||
var _moveCaret = function(id, index) {
|
||||
var inputIndex = id.indexOf('_input');
|
||||
if(inputIndex == -1) return;
|
||||
var inputId = id.substring(0, inputIndex);
|
||||
|
||||
if(!_isActive(inputId)) return;
|
||||
_selectRange(id, index, index);
|
||||
};
|
||||
_placeholderManager.moveCaret = _moveCaret;
|
||||
});
|
||||
@@ -0,0 +1,301 @@
|
||||
// ******* Region MANAGER ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var _geometry = $ax.geometry = {};
|
||||
var regionMap = {};
|
||||
var regionList = [];
|
||||
|
||||
var _unregister = function(label) {
|
||||
var regionIndex = regionList.indexOf(label);
|
||||
if(regionIndex != -1) {
|
||||
var end = $ax.splice(regionList, regionIndex + 1);
|
||||
$ax.splice(regionList, regionIndex, regionList.length - regionIndex);
|
||||
regionList = regionList.concat(end);
|
||||
}
|
||||
delete regionMap[label];
|
||||
};
|
||||
_geometry.unregister = _unregister;
|
||||
|
||||
var clear = function() {
|
||||
regionMap = {};
|
||||
regionList = [];
|
||||
};
|
||||
|
||||
var _polygonRegistered = function(label) {
|
||||
return Boolean(regionMap[label]);
|
||||
};
|
||||
_geometry.polygonRegistered = _polygonRegistered;
|
||||
|
||||
// Must be counterclockwise, or enter/exit will be wrong
|
||||
var _registerPolygon = function(label, points, callback, info) {
|
||||
var regionIndex = regionList.indexOf(label);
|
||||
if(regionIndex == -1) regionList.push(label);
|
||||
regionMap[label] = { points: points, callback: callback, info: info };
|
||||
};
|
||||
_geometry.registerPolygon = _registerPolygon;
|
||||
|
||||
var _getPolygonInfo = function(label) {
|
||||
if(!_polygonRegistered(label)) return undefined;
|
||||
return regionMap[label].info;
|
||||
};
|
||||
_geometry.getPolygonInfo = _getPolygonInfo;
|
||||
|
||||
|
||||
|
||||
var _genRect = function(info, roundHalfPixel) {
|
||||
var x = info.pagex;
|
||||
var y = info.pagey;
|
||||
var w = info.width;
|
||||
var h = info.height;
|
||||
|
||||
if(roundHalfPixel) {
|
||||
if(x % 1 != 0) {
|
||||
x = Math.floor(x);
|
||||
w++;
|
||||
}
|
||||
if(y % 1 != 0) {
|
||||
y = Math.floor(y);
|
||||
h++;
|
||||
}
|
||||
}
|
||||
|
||||
var r = x + w;
|
||||
var b = y + h;
|
||||
|
||||
var rect = {
|
||||
X: function() { return x; },
|
||||
Y: function() { return y; },
|
||||
Wigth: function() { return w; },
|
||||
Height: function() { return h; },
|
||||
Left: function() { return x; },
|
||||
Right: function() { return r; },
|
||||
Top: function() { return y; },
|
||||
Bottom: function() { return b; }
|
||||
};
|
||||
return rect;
|
||||
};
|
||||
_geometry.genRect = _genRect;
|
||||
|
||||
var _genPoint = function(x, y) {
|
||||
return { x: x, y: y };
|
||||
};
|
||||
_geometry.genPoint = _genPoint;
|
||||
|
||||
var oldPoint = _genPoint(0, 0);
|
||||
_geometry.tick = function(x, y, end) {
|
||||
var lastPoint = oldPoint;
|
||||
var nextPoint = oldPoint = _genPoint(x, y);
|
||||
var line = { p1: lastPoint, p2: nextPoint };
|
||||
if(!regionList.length) return;
|
||||
|
||||
for(var i = 0; i < regionList.length; i++) {
|
||||
var region = regionMap[regionList[i]];
|
||||
var points = region.points;
|
||||
if(!region.checked) {
|
||||
if(!_checkInside(points, $ax.mouseLocation)) {
|
||||
region.callback({ outside: true });
|
||||
continue;
|
||||
}
|
||||
region.checked = true;
|
||||
}
|
||||
for(var j = 0; j < points.length; j++) {
|
||||
var startSegment = points[j];
|
||||
var endSegment = points[(j + 1) % points.length];
|
||||
var intersectInfo = linesIntersect(line, { p1: startSegment, p2: endSegment });
|
||||
if(intersectInfo) {
|
||||
region.callback(intersectInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(end) clear();
|
||||
};
|
||||
|
||||
// Info if the one line touches the other (even barely), false otherwise
|
||||
// Info includes point, if l1 is entering or exiting l2, and any ties that happened, or parallel info
|
||||
var linesIntersect = function(l1, l2) {
|
||||
var retval = {};
|
||||
var ties = {};
|
||||
|
||||
var l1p1 = l1.p1.x < l1.p2.x || (l1.p1.x == l1.p2.x && l1.p1.y < l1.p2.y) ? l1.p1 : l1.p2;
|
||||
var l1p2 = l1.p1.x < l1.p2.x || (l1.p1.x == l1.p2.x && l1.p1.y < l1.p2.y) ? l1.p2 : l1.p1;
|
||||
var m1 = (l1p2.y - l1p1.y) / (l1p2.x - l1p1.x);
|
||||
|
||||
var l2p1 = l2.p1.x < l2.p2.x || (l2.p1.x == l2.p2.x && l2.p1.y < l2.p2.y) ? l2.p1 : l2.p2;
|
||||
var l2p2 = l2.p1.x < l2.p2.x || (l2.p1.x == l2.p2.x && l2.p1.y < l2.p2.y) ? l2.p2 : l2.p1;
|
||||
var m2 = (l2p2.y - l2p1.y) / (l2p2.x - l2p1.x);
|
||||
|
||||
var l1Vert = l1.p1.x == l1.p2.x;
|
||||
var l2Vert = l2.p1.x == l2.p2.x;
|
||||
if(l1Vert || l2Vert) {
|
||||
if(l1Vert && l2Vert) {
|
||||
// If the lines don't follow the same path, return
|
||||
if(l1p1.x != l2p1.x) return false;
|
||||
// if they never meet, return
|
||||
if(l1p2.y < l2p1.y || l1p1.y > l2p2.y) return false;
|
||||
var firstVert = l1p1.y >= l2p1.y ? l1p1 : l2p1;
|
||||
var secondVert = l1p2.y <= l2p2.y ? l1p2 : l2p2;
|
||||
// First is from the perspective of l1
|
||||
retval.parallel = {
|
||||
first: l1p1 == l1.p1 ? firstVert : secondVert,
|
||||
second: l1p2 == l1.p2 ? secondVert : firstVert,
|
||||
sameDirection: (l1p1 == l1.p1) == (l2p1 == l2.p1)
|
||||
};
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
var x1 = l2Vert ? l1p1.x : l2p1.x;
|
||||
var x2 = l2Vert ? l1p2.x : l2p2.x;
|
||||
var xVert = l2Vert ? l2p1.x : l1p1.x;
|
||||
|
||||
var y = l2Vert ? l1p1.y + (xVert - x1) * m1 : l2p1.y + (xVert - x1) * m2;
|
||||
var y1 = l2Vert ? l2p1.y : l1p1.y;
|
||||
var y2 = l2Vert ? l2p2.y : l1p2.y;
|
||||
if(xVert >= x1 && xVert <= x2 && y >= y1 && y <= y2) {
|
||||
retval.point = { x: xVert, y: y };
|
||||
retval.exiting = l2Vert == (y1 == (l2Vert ? l2.p1.y : l1.p1.y)) == (x1 == (l2Vert ? l1.p1.x : l2.p1.x));
|
||||
retval.entering = !retval.exiting;
|
||||
|
||||
// Calculate ties
|
||||
if(x1 == xVert) {
|
||||
ties[l2Vert ? 'l1' : 'l2'] = (x1 == (l2Vert ? l1.p1.x : l2.p1.x)) ? 'start' : 'end';
|
||||
retval.ties = ties;
|
||||
} else if(x2 == xVert) {
|
||||
ties[l2Vert ? 'l1' : 'l2'] = (x2 == (l2Vert ? l1.p2.x : l2.p2.x)) ? 'end' : 'start';
|
||||
retval.ties = ties;
|
||||
}
|
||||
if(y1 == y) {
|
||||
ties[l2Vert ? 'l2' : 'l1'] = (y1 == (l2Vert ? l2.p1.y : l1.p1.y)) ? 'start' : 'end';
|
||||
retval.ties = ties;
|
||||
} else if(y2 == y) {
|
||||
ties[l2Vert ? 'l2' : 'l1'] = (y2 == (l2Vert ? l2.p2.y : l1.p2.y)) ? 'end' : 'start';
|
||||
retval.ties = ties;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// If here, no vertical lines
|
||||
|
||||
if(m1 == m2) {
|
||||
// If the lines don't follow the same path, return
|
||||
if(l1p1.y != (l2p1.y + (l1p1.x - l2p1.x) * m1)) return false;
|
||||
// if they never meet, return
|
||||
if(l1p2.x < l2p1.x || l1p1.x > l2p2.x) return false;
|
||||
var first = l1p1.x >= l2p1.x ? l1p1 : l2p1;
|
||||
var second = l1p2.x <= l2p2.x ? l1p2 : l2p2;
|
||||
// First is from the perspective of l1
|
||||
retval.parallel = {
|
||||
first: l1p1 == l1.p1 ? first : second,
|
||||
second: l1p2 == l1.p2 ? second : first,
|
||||
sameDirection: (l1p1 == l1.p1) == (l2p1 == l2.p1)
|
||||
};
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
var x = (l2p1.y - l2p1.x * m2 - l1p1.y + l1p1.x * m1) / (m1 - m2);
|
||||
|
||||
// Check if x is out of bounds
|
||||
if(x >= l1p1.x && x <= l1p2.x && x >= l2p1.x && x <= l2p2.x) {
|
||||
var y = l1p1.y + (x - l1p1.x) * m1;
|
||||
retval.point = { x: x, y: y };
|
||||
retval.entering = m1 > m2 == (l1p1 == l1.p1) == (l2p1 == l2.p1);
|
||||
retval.exiting = !retval.entering;
|
||||
|
||||
// Calculate ties
|
||||
if(l1.p1.x == x) {
|
||||
ties.l1 = 'start';
|
||||
retval.ties = ties;
|
||||
} else if(l1.p2.x == x) {
|
||||
ties.l1 = 'end';
|
||||
retval.ties = ties;
|
||||
}
|
||||
if(l2.p1.x == x) {
|
||||
ties.l2 = 'start';
|
||||
retval.ties = ties;
|
||||
} else if(l2.p2.x == x) {
|
||||
ties.l2 = 'end';
|
||||
retval.ties = ties;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var _checkInsideRegion = function(label, point) {
|
||||
if(!_polygonRegistered(label)) return false;
|
||||
|
||||
return _checkInside(regionMap[label].points, point || $ax.mouseLocation);
|
||||
};
|
||||
_geometry.checkInsideRegion = _checkInsideRegion;
|
||||
|
||||
// Returns true if point is inside the polygon, including ties
|
||||
var _checkInside = function(polygon, point) {
|
||||
// Make horizontal line wider than the polygon, with the y of point to test location
|
||||
var firstX = polygon[0].x;
|
||||
var secondX = firstX;
|
||||
var i;
|
||||
for(i = 1; i < polygon.length; i++) {
|
||||
var polyX = polygon[i].x;
|
||||
firstX = Math.min(firstX, polyX);
|
||||
secondX = Math.max(secondX, polyX);
|
||||
}
|
||||
var line = {
|
||||
p1: _genPoint(--firstX, point.y),
|
||||
p2: _genPoint(++secondX, point.y)
|
||||
};
|
||||
|
||||
// If entered true, with closest intersection says you are inside the polygon.
|
||||
var entered = false;
|
||||
// Closest is the closest intersection to the left of the point
|
||||
var closest = line.p1.x;
|
||||
// This is for if intersections hit the same point, to find out which is correct
|
||||
var cos = -2;
|
||||
|
||||
var getCos = function(line) {
|
||||
var x = line.p2.x - line.p1.x;
|
||||
var y = line.p2.y - line.p1.y;
|
||||
return x / Math.sqrt(x * x + y * y);
|
||||
};
|
||||
|
||||
for(i = 0; i < polygon.length; i++) {
|
||||
var polyLine = { p1: polygon[i], p2: polygon[(i + 1) % polygon.length] };
|
||||
var intersectInfo = linesIntersect(line, polyLine);
|
||||
if(!intersectInfo) continue;
|
||||
|
||||
if(intersectInfo.parallel) {
|
||||
// Only really care about this if it actually touches the point
|
||||
if(intersectInfo.parallel.first.x <= point.x && intersectInfo.parallel.second.x >= point.x) return true;
|
||||
continue;
|
||||
}
|
||||
|
||||
var intersectionX = intersectInfo.point.x;
|
||||
if(intersectionX > point.x || intersectionX < closest) continue;
|
||||
if(intersectionX == point.x) return true;
|
||||
|
||||
// If closer than last time, reset cosine.
|
||||
if(intersectionX != closest) cos = -2;
|
||||
|
||||
// For getting cosine, need to possibly reverse the direction of polyLine.
|
||||
if(intersectInfo.ties) {
|
||||
// Tie must be on l2, if the ties is end, reverse so cosine indicates how close the angle is to that of 'point' from here.
|
||||
if(intersectInfo.ties.l2 == 'end') polyLine = { p1: polyLine.p2, p2: polyLine.p1 };
|
||||
} else {
|
||||
// It is on both side, so you can take the larger one
|
||||
if(polyLine.p1.x > polyLine.p2.x) polyLine = { p1: polyLine.p2, p2: polyLine.p1 };
|
||||
}
|
||||
var currCos = getCos(polyLine);
|
||||
if(currCos > cos) {
|
||||
cos = currCos;
|
||||
closest = intersectionX;
|
||||
entered = intersectInfo.entering;
|
||||
}
|
||||
}
|
||||
return entered;
|
||||
};
|
||||
_geometry.checkInside = _checkInside;
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
$axure.internal(function($ax) {
|
||||
var _globals = $ax.globals = {};
|
||||
|
||||
$ax.globals.MaxZIndex = 1000;
|
||||
$ax.globals.MinZIndex = -1000;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,344 @@
|
||||
|
||||
// ******* Internet Explorer MANAGER ******** //
|
||||
//this is to handle all the stupid IE Stuff
|
||||
$axure.internal(function($ax) {
|
||||
if(!IE_10_AND_BELOW) return;
|
||||
|
||||
var _ieColorManager = {};
|
||||
if(Number(BROWSER_VERSION) < 9) $ax.ieColorManager = _ieColorManager;
|
||||
|
||||
var _applyIEFixedPosition = function() {
|
||||
if(Number(BROWSER_VERSION) >= 7) return;
|
||||
|
||||
$axure(function(diagramObject) { return diagramObject.fixedVertical; }).$()
|
||||
.appendTo($('body'))
|
||||
.css('position', 'absolute').css('margin-left', 0 + 'px').css('margin-top', 0 + 'px');
|
||||
|
||||
var handleScroll = function() {
|
||||
$axure(function(diagramObject) { return diagramObject.fixedVertical; })
|
||||
.each(function(diagramObject, elementId) {
|
||||
var win = $(window);
|
||||
var windowWidth = win.width();
|
||||
var windowHeight = win.height();
|
||||
var windowScrollLeft = win.scrollLeft();
|
||||
var windowScrollTop = win.scrollTop();
|
||||
|
||||
var newLeft = 0;
|
||||
var newTop = 0;
|
||||
var elementQuery = $('#' + elementId);
|
||||
var elementAxQuery = $ax('#' + elementId);
|
||||
var width = elementAxQuery.width();
|
||||
var height = elementAxQuery.height();
|
||||
|
||||
var horz = diagramObject.fixedHorizontal;
|
||||
if(horz == 'left') {
|
||||
newLeft = windowScrollLeft + diagramObject.fixedMarginHorizontal;
|
||||
} else if(horz == 'center') {
|
||||
newLeft = windowScrollLeft + ((windowWidth - width) / 2) + diagramObject.fixedMarginHorizontal;
|
||||
} else if(horz == 'right') {
|
||||
newLeft = windowScrollLeft + windowWidth - width - diagramObject.fixedMarginHorizontal;
|
||||
}
|
||||
|
||||
var vert = diagramObject.fixedVertical;
|
||||
if(vert == 'top') {
|
||||
newTop = windowScrollTop + diagramObject.fixedMarginVertical;
|
||||
} else if(vert == 'middle') {
|
||||
newTop = windowScrollTop + ((windowHeight - height) / 2) + diagramObject.fixedMarginVertical;
|
||||
} else if(vert == 'bottom') {
|
||||
newTop = windowScrollTop + windowHeight - height - diagramObject.fixedMarginVertical;
|
||||
}
|
||||
elementQuery.css('top', newTop + 'px').css('left', newLeft + 'px');
|
||||
});
|
||||
};
|
||||
|
||||
$(window).scroll(handleScroll);
|
||||
$axure.resize(handleScroll);
|
||||
handleScroll();
|
||||
};
|
||||
|
||||
var _applyBackground = function() {
|
||||
if(Number(BROWSER_VERSION) >= 9) return;
|
||||
|
||||
var styleChain = $ax.adaptive.getAdaptiveIdChain($ax.adaptive.currentViewId);
|
||||
var argb = _getArgb($ax.pageData.page, styleChain);
|
||||
var hexColor = _getHexColor(argb, false);
|
||||
if(hexColor) $('body').css('background-color', hexColor);
|
||||
|
||||
_applyBackgroundToQuery($ax('*'));
|
||||
};
|
||||
|
||||
var _applyBackgroundToQuery = function(query) {
|
||||
if(Number(BROWSER_VERSION) >= 9) return;
|
||||
|
||||
var styleChain = $ax.adaptive.getAdaptiveIdChain($ax.adaptive.currentViewId);
|
||||
query.each(function(obj, elementId) {
|
||||
if ($ax.public.fn.IsDynamicPanel(obj.type)) {
|
||||
var stateCount = obj.diagrams.length;
|
||||
for(var j = 0; j < stateCount; j++) {
|
||||
var stateId = $ax.repeater.applySuffixToElementId(elementId, '_state' + j);
|
||||
var argb = _getArgb(obj.diagrams[j], styleChain);
|
||||
var hexColor = _getHexColor(argb, true);
|
||||
if(hexColor) $jobj(stateId).css('background-color', hexColor);
|
||||
}
|
||||
} else if ($ax.public.fn.IsRepeater(obj.type)) {
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
_ieColorManager.applyBackground = _applyBackgroundToQuery;
|
||||
|
||||
var _getArgb = function(diagram, styleChain) {
|
||||
var argb = undefined;
|
||||
for(var i = 0; i < styleChain.length && !argb; i++) {
|
||||
var style = diagram.adaptiveStyles[styleChain[i]];
|
||||
argb = style.fill && style.fill.color;
|
||||
}
|
||||
if(!argb) argb = diagram.style.fill.color;
|
||||
return argb;
|
||||
};
|
||||
|
||||
var gMult = 256;
|
||||
var rMult = gMult * 256;
|
||||
var aMult = rMult * 256;
|
||||
|
||||
var _getHexColor = function(argb, allowWhite) {
|
||||
var a = Math.floor(argb / aMult);
|
||||
argb -= a * aMult;
|
||||
|
||||
var r = Math.floor(argb / rMult);
|
||||
argb -= r * rMult;
|
||||
|
||||
var g = Math.floor(argb / gMult);
|
||||
var b = argb - g * gMult;
|
||||
|
||||
return _getColorFromArgb(a, r, g, b, allowWhite);
|
||||
};
|
||||
|
||||
var _getColorFromArgb = function(a, r, g, b, allowWhite) {
|
||||
if(Number(BROWSER_VERSION) >= 9) return undefined;
|
||||
|
||||
//convert the color with alpha to a color with no alpha (assuming white background)
|
||||
r = Math.min((r * a) / 255 + 255 - a, 255);
|
||||
g = Math.min((g * a) / 255 + 255 - a, 255);
|
||||
b = Math.min((b * a) / 255 + 255 - a, 255);
|
||||
|
||||
if(a == 0) return undefined;
|
||||
if(!allowWhite && (r == 255 && g == 255 && b == 255)) return undefined;
|
||||
|
||||
var color = '#';
|
||||
color += Math.floor(r / 16).toString(16);
|
||||
color += Math.floor(r % 16).toString(16);
|
||||
color += Math.floor(g / 16).toString(16);
|
||||
color += Math.floor(g % 16).toString(16);
|
||||
color += Math.floor(b / 16).toString(16);
|
||||
color += Math.floor(b % 16).toString(16);
|
||||
return color;
|
||||
};
|
||||
_ieColorManager.getColorFromArgb = _getColorFromArgb;
|
||||
|
||||
var getIEOffset = function(transform, rect) {
|
||||
var translatedVertexes = [
|
||||
$axure.utils.Vector2D(0, 0), //we dont translate, so the orgin is fixed
|
||||
transform.mul($axure.utils.Vector2D(0, rect.height)),
|
||||
transform.mul($axure.utils.Vector2D(rect.width, 0)),
|
||||
transform.mul($axure.utils.Vector2D(rect.width, rect.height))];
|
||||
|
||||
var minX = 0, minY = 0, maxX = 0, maxY = 0;
|
||||
$.each(translatedVertexes, function(index, p) {
|
||||
minX = Math.min(minX, p.x);
|
||||
minY = Math.min(minY, p.y);
|
||||
maxX = Math.max(maxX, p.x);
|
||||
maxY = Math.max(maxY, p.y);
|
||||
});
|
||||
|
||||
return $axure.utils.Vector2D(
|
||||
(maxX - minX - rect.width) / 2,
|
||||
(maxY - minY - rect.height) / 2);
|
||||
};
|
||||
|
||||
var _filterFromTransform = function(transform) {
|
||||
return "progid:DXImageTransform.Microsoft.Matrix(M11=" + transform.m11 +
|
||||
", M12=" + transform.m12 + ", M21=" + transform.m21 +
|
||||
", M22=" + transform.m22 + ", SizingMethod='auto expand')";
|
||||
};
|
||||
|
||||
var _applyIERotation = function() {
|
||||
if(Number(BROWSER_VERSION) >= 9) return;
|
||||
|
||||
$axure(function(diagramObject) {
|
||||
return ((diagramObject.style.rotation && Math.abs(diagramObject.style.rotation) > 0.1)
|
||||
|| (diagramObject.style.textRotation && Math.abs(diagramObject.style.textRotation) > 0.1))
|
||||
&& !diagramObject.isContained;
|
||||
}).each(function(diagramObject, elementId) {
|
||||
var rotation = diagramObject.style.rotation || 0;
|
||||
var $element = $('#' + elementId);
|
||||
var axElement = $ax('#' + elementId);
|
||||
var width = axElement.width();
|
||||
var height = axElement.height();
|
||||
var originX = width / 2;
|
||||
var originY = height / 2;
|
||||
|
||||
var shapeIeOffset;
|
||||
$element.children().each(function() {
|
||||
var $child = $(this);
|
||||
var axChild = $ax('#' + $child.attr('id'));
|
||||
var childWidth = axChild.width();
|
||||
var childHeight = axChild.height() + $child.position().top;
|
||||
var centerX = $child.position().left + (childWidth / 2);
|
||||
var centerY = $child.position().top + (childHeight / 2);
|
||||
var deltaX = centerX - originX;
|
||||
var deltaY = centerY - originY;
|
||||
|
||||
var effectiveRotation = rotation;
|
||||
var textObject = $ax.getObjectFromElementId($child.attr('id'));
|
||||
if(textObject) {
|
||||
if(textObject.style.textRotation) effectiveRotation = textObject.style.textRotation;
|
||||
else return;
|
||||
}
|
||||
|
||||
var transform = $ax.utils.Matrix2D.identity().rotate(effectiveRotation);
|
||||
var filter = _filterFromTransform(transform);
|
||||
|
||||
$child.css('filter', filter)
|
||||
.width(childWidth + 1)
|
||||
.height(childHeight + 1);
|
||||
|
||||
var p = transform.mul($ax.utils.Vector2D(deltaX, deltaY));
|
||||
var ieOffset = getIEOffset(transform, { width: childWidth, height: childHeight });
|
||||
if(!textObject) {
|
||||
shapeIeOffset = ieOffset;
|
||||
} else {
|
||||
// This is a close approximation, but not exact
|
||||
if(diagramObject.style.verticalAlignment != 'top') ieOffset.y -= shapeIeOffset.y + Math.abs(shapeIeOffset.x);
|
||||
}
|
||||
|
||||
$child.css("margin-left", -ieOffset.x - deltaX + p.x).css("margin-top", -ieOffset.y - deltaY + p.y);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var _fixIEStretchBackground = function() {
|
||||
if(Number(BROWSER_VERSION) >= 9) return;
|
||||
var pageStyle = $ax.adaptive.getPageStyle();
|
||||
if(!pageStyle.imageRepeat || pageStyle.imageRepeat == 'auto') return;
|
||||
|
||||
$('body').css('background-image', 'none');
|
||||
var viewId = $ax.adaptive.currentViewId;
|
||||
var imageInfo = viewId ? $ax.pageData.viewIdToBackgroundImageInfo && $ax.pageData.viewIdToBackgroundImageInfo[viewId] : $ax.pageData.defaultBackgroundImageInfo;
|
||||
if(imageInfo && imageInfo.path) {
|
||||
if($('#bg_img').length == 0) $('body').append('<img id="bg_img"/>');
|
||||
$('#bg_img').attr('src', imageInfo.path).css('position', 'fixed').css('z-index', '-10000');
|
||||
_resizeIEBackground();
|
||||
} else $('#bg_img').remove();
|
||||
};
|
||||
|
||||
var _resizeIEBackground = function() {
|
||||
if(Number(BROWSER_VERSION) >= 9) return;
|
||||
//var page = $ax.pageData.page;
|
||||
var viewId = $ax.adaptive.currentViewId;
|
||||
var pageStyle = $ax.adaptive.getPageStyle();
|
||||
if(!$ax.pageData.defaultBackgroundImageInfo && !$ax.pageData.viewIdToBackgroundImageInfo) return;
|
||||
var imageInfo = viewId ? $ax.pageData.viewIdToBackgroundImageInfo[viewId] : $ax.pageData.defaultBackgroundImageInfo;
|
||||
if(!imageInfo) return;
|
||||
var imageWidth = imageInfo.width;
|
||||
var imageHeight = imageInfo.height;
|
||||
var windowWidth = $(window).width();
|
||||
var windowHeight = $(window).height();
|
||||
var isCover = pageStyle.imageRepeat == 'cover';
|
||||
|
||||
var wRatio = windowWidth / imageWidth;
|
||||
var hRatio = windowHeight / imageHeight;
|
||||
var ratio = wRatio;
|
||||
if(isCover) {
|
||||
if(hRatio > wRatio) ratio = hRatio;
|
||||
} else {
|
||||
if(hRatio < wRatio) ratio = hRatio;
|
||||
}
|
||||
var width = imageWidth * ratio;
|
||||
var height = imageHeight * ratio;
|
||||
|
||||
var left = '0px';
|
||||
if((isCover && width > windowWidth) || (!isCover && width < windowWidth)) {
|
||||
if(pageStyle.imageHorizontalAlignment == 'center') {
|
||||
left = ((windowWidth - width) / 2) + 'px';
|
||||
} else if(pageStyle.imageHorizontalAlignment == 'far') {
|
||||
left = (windowWidth - width) + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
var top = '0px';
|
||||
if((isCover && height > windowHeight) || (!isCover && height < windowHeight)) {
|
||||
if(pageStyle.imageVerticalAlignment == 'center') {
|
||||
top = ((windowHeight - height) / 2) + 'px';
|
||||
} else if(pageStyle.imageVerticalAlignment == 'far') {
|
||||
top = (windowHeight - height) + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
$('#bg_img').css('top', top).css('left', left).css('width', width).css('height', height);
|
||||
};
|
||||
|
||||
var _fixAllPngs = function() {
|
||||
if(!(/MSIE ((5\.5)|6)/.test(window.navigator.userAgent) && window.navigator.platform == "Win32")) return;
|
||||
|
||||
$('img[src$=".png"]').each(function() {
|
||||
if(!this.complete) {
|
||||
this.onload = function() { $axure.utils.fixPng(this); };
|
||||
} else {
|
||||
$axure.utils.fixPng(this);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var _fixInputSize = function() {
|
||||
if(Number(BROWSER_VERSION) >= 8 || window.navigator.userAgent.indexOf("Trident/4.0") > -1) return;
|
||||
var inputs = $('input').not(':input[type=button], :input[type=submit], :input[type=radio], :input[type=checkbox]');
|
||||
inputs.each(function() {
|
||||
var $input = $(this);
|
||||
var axInput = $ax('#' + $input.attr('id'));
|
||||
$input.css('height', (axInput.height() - 4 + 'px')).css('width', (axInput.width() - 2 + 'px'));
|
||||
});
|
||||
|
||||
var textAreas = $($ax.constants.TEXT_AREA_TYPE);
|
||||
textAreas.each(function() {
|
||||
var $textArea = $(this);
|
||||
var axText = $ax('#' + $textArea.attr('id'));
|
||||
$textArea.css('height', (axText.height() - 6 + 'px')).css('width', (axText.width() - 6 + 'px'));
|
||||
});
|
||||
};
|
||||
|
||||
var _fixInputBackground = function() {
|
||||
var inputs = $('input').not(':input[type=button], :input[type=submit], :input[type=radio], :input[type=checkbox]');
|
||||
inputs = inputs.add($($ax.constants.TEXT_AREA_TYPE));
|
||||
inputs.each(function() {
|
||||
var $input = $(this);
|
||||
if($input.css('background-color') == 'transparent') {
|
||||
$input.css('background-image', 'url(../../transparent.gif)');
|
||||
} else {
|
||||
$input.css('background-image', '');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
_fixIEStretchBackground();
|
||||
_applyIEFixedPosition();
|
||||
$axure.resize(function() {
|
||||
_resizeIEBackground();
|
||||
});
|
||||
$ax.adaptive.bind('viewChanged', function() {
|
||||
_fixIEStretchBackground();
|
||||
_applyBackground();
|
||||
_fixInputBackground();
|
||||
});
|
||||
|
||||
|
||||
_fixAllPngs();
|
||||
_applyIERotation();
|
||||
_applyBackground();
|
||||
_fixInputSize();
|
||||
_fixInputBackground();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,224 @@
|
||||
$axure.internal(function($ax) {
|
||||
|
||||
$(window.document).ready(function() {
|
||||
var readyStart = (new Date()).getTime();
|
||||
|
||||
//this is because the page id is not formatted as a guid
|
||||
var pageId = $ax.pageData.page.packageId;
|
||||
|
||||
var pageData = {
|
||||
id: pageId,
|
||||
pageName: $ax.pageData.page.name,
|
||||
location: window.location.toString(),
|
||||
notes: $ax.pageData.page.notes
|
||||
};
|
||||
|
||||
var anns = [];
|
||||
$ax('*').each(function (dObj, elementId) {
|
||||
pushAnnotation(dObj, elementId);
|
||||
});
|
||||
|
||||
function pushAnnotation(dObj, elementId) {
|
||||
var ann = dObj.annotation;
|
||||
if(ann) {
|
||||
ann["id"] = elementId;
|
||||
ann["label"] = dObj.label + " (" + dObj.friendlyType + ")";
|
||||
anns.push(ann);
|
||||
}
|
||||
|
||||
if(dObj.type == 'repeater') {
|
||||
if(dObj.objects) {
|
||||
for(var i = 0, len = dObj.objects.length; i < len; i++) {
|
||||
pushAnnotation(dObj.objects[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pageData.widgetNotes = anns;
|
||||
|
||||
//only trigger the page.data setting if the window is on the mainframe
|
||||
var isMainFrame = false;
|
||||
try {
|
||||
if(window.name == 'mainFrame' ||
|
||||
(!CHROME_5_LOCAL && window.parent.$ && window.parent.$('#mainFrame').length > 0)) {
|
||||
isMainFrame = true;
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
if(message == 'finishInit') {
|
||||
_processTempInit();
|
||||
}
|
||||
});
|
||||
|
||||
$axure.messageCenter.setState('page.data', pageData);
|
||||
window.focus();
|
||||
}
|
||||
} catch(e) { }
|
||||
|
||||
//attach here for chrome local
|
||||
$(window).load(function() {
|
||||
$ax.style.initializeObjectTextAlignment($ax('*'));
|
||||
});
|
||||
|
||||
if(!isMainFrame) _processTempInit();
|
||||
});
|
||||
|
||||
|
||||
var _processTempInit = function() {
|
||||
//var start = (new Date()).getTime();
|
||||
//var end = (new Date()).getTime();
|
||||
//window.alert('elapsed ' + (end - start));
|
||||
|
||||
$('iframe').each(function() {
|
||||
var origSrc = $(this).attr('basesrc');
|
||||
|
||||
var $this = $(this);
|
||||
if(origSrc) {
|
||||
var newSrcUrl = origSrc.toLowerCase().indexOf('http://') == -1 ? $ax.globalVariableProvider.getLinkUrl(origSrc) : origSrc;
|
||||
$this.attr('src', newSrcUrl);
|
||||
}
|
||||
|
||||
if(IOS) {
|
||||
$this.parent().css('overflow', 'auto').css('-webkit-overflow-scrolling', 'touch').css('-ms-overflow-x', 'hidden').css('overflow-x', 'hidden');
|
||||
}
|
||||
});
|
||||
|
||||
$axure.messageCenter.addMessageListener(function(message, data) {
|
||||
if(message == 'setGlobalVar') {
|
||||
$ax.globalVariableProvider.setVariableValue(data.globalVarName, data.globalVarValue, true);
|
||||
}
|
||||
});
|
||||
|
||||
window.lastFocusedClickable = null;
|
||||
var _lastFocusedClickableSelector = 'div[tabIndex=0], img[tabIndex=0], a';
|
||||
var shouldOutline = true;
|
||||
|
||||
$ax(function (dObj) { return dObj.tabbable; }).each(function (dObj, elementId) {
|
||||
if ($ax.public.fn.IsLayer(dObj.type)) $ax.event.layerMapFocus(dObj, elementId);
|
||||
var focusableId = $ax.event.getFocusableWidgetOrChildId(elementId);
|
||||
$('#' + focusableId).attr("tabIndex", 0);
|
||||
});
|
||||
|
||||
$('div[tabIndex=0], img[tabIndex=0]').bind($ax.features.eventNames.mouseDownName, function() {
|
||||
shouldOutline = false;
|
||||
});
|
||||
|
||||
$(window.document).bind($ax.features.eventNames.mouseUpName, function() {
|
||||
shouldOutline = true;
|
||||
});
|
||||
|
||||
$(_lastFocusedClickableSelector).focus(function () {
|
||||
if(shouldOutline) {
|
||||
$(this).css('outline', '');
|
||||
} else {
|
||||
$(this).css('outline', 'none');
|
||||
}
|
||||
|
||||
window.lastFocusedClickable = this;
|
||||
});
|
||||
|
||||
$(_lastFocusedClickableSelector).blur(function () {
|
||||
if(window.lastFocusedClickable == this) window.lastFocusedClickable = null;
|
||||
});
|
||||
|
||||
$(window.document).bind('keyup', function(e) {
|
||||
if(e.keyCode == '13' || e.keyCode == '32') {
|
||||
if(window.lastFocusedClickable) $(window.lastFocusedClickable).click();
|
||||
}
|
||||
});
|
||||
|
||||
if($ax.document.configuration.hideAddress) {
|
||||
$(window).load(function() {
|
||||
window.setTimeout(function() {
|
||||
window.scrollTo(0, 0.9);
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
|
||||
if($ax.document.configuration.preventScroll) {
|
||||
$(window.document).bind('touchmove', function(e) {
|
||||
var inScrollable = $ax.legacy.GetScrollable(e.target) != window.document.body;
|
||||
if(!inScrollable) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$ax(function(diagramObject) {
|
||||
return $ax.public.fn.IsDynamicPanel(diagramObject.type) && diagramObject.scrollbars != 'none';
|
||||
}).$().children().bind('touchstart', function() {
|
||||
var target = this;
|
||||
var top = target.scrollTop;
|
||||
if(top <= 0) target.scrollTop = 1;
|
||||
if(top + target.offsetHeight >= target.scrollHeight) target.scrollTop = target.scrollHeight - target.offsetHeight - 1;
|
||||
});
|
||||
}
|
||||
|
||||
if(OS_MAC && WEBKIT) {
|
||||
$ax(function(diagramObject) {
|
||||
return $ax.public.fn.IsComboBox(diagramObject.type);
|
||||
}).each(function(obj, id) {
|
||||
$jobj($ax.INPUT(id)).css('-webkit-appearance', 'menulist-button').css('border-color', '#999999');
|
||||
});
|
||||
}
|
||||
|
||||
$ax.legacy.BringFixedToFront();
|
||||
$ax.event.initialize();
|
||||
$ax.style.initialize();
|
||||
$ax.visibility.initialize();
|
||||
$ax.repeater.initialize();
|
||||
$ax.dynamicPanelManager.initialize(); //needs to be called after visibility is initialized
|
||||
$ax.adaptive.initialize();
|
||||
$ax.loadDynamicPanelsAndMasters();
|
||||
$ax.adaptive.loadFinished();
|
||||
var start = (new Date()).getTime();
|
||||
$ax.repeater.initRefresh();
|
||||
var end = (new Date()).getTime();
|
||||
console.log('loadTime: ' + (end - start) / 1000);
|
||||
$ax.style.prefetch();
|
||||
|
||||
$(window).resize();
|
||||
|
||||
//var readyEnd = (new Date()).getTime();
|
||||
//window.alert('elapsed ' + (readyEnd - readyStart));
|
||||
};
|
||||
});
|
||||
|
||||
/* extend canvas */
|
||||
var gv_hasCanvas = false;
|
||||
(function() {
|
||||
var _canvas = document.createElement('canvas'), proto, abbrev;
|
||||
if(gv_hasCanvas = !!(_canvas.getContext && _canvas.getContext('2d')) && typeof (CanvasGradient) !== 'undefined') {
|
||||
function chain(func) {
|
||||
return function() {
|
||||
return func.apply(this, arguments) || this;
|
||||
};
|
||||
}
|
||||
|
||||
with(proto = CanvasRenderingContext2D.prototype) for(var func in abbrev = {
|
||||
a: arc,
|
||||
b: beginPath,
|
||||
n: clearRect,
|
||||
c: clip,
|
||||
p: closePath,
|
||||
g: createLinearGradient,
|
||||
f: fill,
|
||||
j: fillRect,
|
||||
z: function(s) { this.fillStyle = s; },
|
||||
l: lineTo,
|
||||
w: function(w) { this.lineWidth = w; },
|
||||
m: moveTo,
|
||||
q: quadraticCurveTo,
|
||||
h: rect,
|
||||
r: restore,
|
||||
o: rotate,
|
||||
s: save,
|
||||
x: scale,
|
||||
y: function(s) { this.strokeStyle = s; },
|
||||
u: setTransform,
|
||||
k: stroke,
|
||||
i: strokeRect,
|
||||
t: translate
|
||||
}) proto[func] = chain(abbrev[func]);
|
||||
CanvasGradient.prototype.a = chain(CanvasGradient.prototype.addColorStop);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,208 @@
|
||||
//stored on each browser event
|
||||
var windowEvent;
|
||||
|
||||
$axure.internal(function($ax) {
|
||||
var _legacy = {};
|
||||
$ax.legacy = _legacy;
|
||||
|
||||
|
||||
// ************************** GLOBAL VARS *********************************//
|
||||
|
||||
// ************************************************************************//
|
||||
//Check if IE
|
||||
//var bIE = false;
|
||||
//if ((index = navigator.userAgent.indexOf("MSIE")) >= 0) {
|
||||
// bIE = true;
|
||||
//}
|
||||
|
||||
var Forms = window.document.getElementsByTagName("FORM");
|
||||
for(var i = 0; i < Forms.length; i++) {
|
||||
var Form = Forms[i];
|
||||
Form.onclick = $ax.legacy.SuppressBubble;
|
||||
}
|
||||
|
||||
$ax.legacy.SuppressBubble = function(event) {
|
||||
if(IE_10_AND_BELOW) {
|
||||
window.event.cancelBubble = true;
|
||||
window.event.returnValue = false;
|
||||
} else {
|
||||
if(event) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// function InsertAfterBegin(dom, html) {
|
||||
// if(!IE) {
|
||||
// var phtml;
|
||||
// var range = dom.ownerDocument.createRange();
|
||||
// range.selectNodeContents(dom);
|
||||
// range.collapse(true);
|
||||
// phtml = range.createContextualFragment(html);
|
||||
// dom.insertBefore(phtml, dom.firstChild);
|
||||
// } else {
|
||||
// dom.insertAdjacentHTML("afterBegin", html);
|
||||
// }
|
||||
// }
|
||||
|
||||
// function InsertBeforeEnd(dom, html) {
|
||||
// if(!IE) {
|
||||
// var phtml;
|
||||
// var range = dom.ownerDocument.createRange();
|
||||
// range.selectNodeContents(dom);
|
||||
// range.collapse(dom);
|
||||
// phtml = range.createContextualFragment(html);
|
||||
// dom.appendChild(phtml);
|
||||
// } else {
|
||||
// dom.insertAdjacentHTML("beforeEnd", html);
|
||||
// }
|
||||
// }
|
||||
|
||||
//Get the id of the Workflow Dialog belonging to element with id = id
|
||||
|
||||
// function Workflow(id) {
|
||||
// return id + 'WF';
|
||||
// }
|
||||
|
||||
$ax.legacy.BringToFront = function(id, skipFixed) {
|
||||
_bringToFrontHelper(id);
|
||||
if(!skipFixed) $ax.legacy.BringFixedToFront();
|
||||
};
|
||||
|
||||
var _bringToFrontHelper = function(id) {
|
||||
var target = window.document.getElementById(id);
|
||||
if(target == null) return;
|
||||
$ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
|
||||
target.style.zIndex = $ax.globals.MaxZIndex;
|
||||
};
|
||||
|
||||
$ax.legacy.BringFixedToFront = function() {
|
||||
$ax(function(diagramObject) { return diagramObject.fixedKeepInFront; }).each(function(diagramObject, scriptId) {
|
||||
_bringToFrontHelper(scriptId);
|
||||
});
|
||||
};
|
||||
|
||||
$ax.legacy.SendToBack = function(id) {
|
||||
var target = window.document.getElementById(id);
|
||||
if(target == null) return;
|
||||
target.style.zIndex = $ax.globals.MinZIndex = $ax.globals.MinZIndex - 1;
|
||||
};
|
||||
|
||||
$ax.legacy.RefreshScreen = function() {
|
||||
var oldColor = window.document.body.style.backgroundColor;
|
||||
var setColor = (oldColor == "rgb(0,0,0)") ? "#FFFFFF" : "#000000";
|
||||
window.document.body.style.backgroundColor = setColor;
|
||||
window.document.body.style.backgroundColor = oldColor;
|
||||
};
|
||||
|
||||
$ax.legacy.getAbsoluteLeft = function(currentNode, elementId) {
|
||||
var oldDisplay = currentNode.css('display');
|
||||
var displaySet = false;
|
||||
if(oldDisplay == 'none') {
|
||||
currentNode.css('display', '');
|
||||
displaySet = true;
|
||||
}
|
||||
var left = currentNode.offset().left;
|
||||
|
||||
// Special Layer code
|
||||
if($ax.getTypeFromElementId(elementId) == 'layer') {
|
||||
var first = true;
|
||||
var children = currentNode.children();
|
||||
for(var i = 0; i < children.length; i++) {
|
||||
var child = $(children[i]);
|
||||
var subDisplaySet = false;
|
||||
if(child.css('display') == 'none') {
|
||||
child.css('display', '');
|
||||
subDisplaySet = true;
|
||||
}
|
||||
if(first) left = child.offset().left;
|
||||
else left = Math.min(child.offset().left, left);
|
||||
first = false;
|
||||
|
||||
if(subDisplaySet) child.css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
if (displaySet) currentNode.css('display', oldDisplay);
|
||||
|
||||
return $axure.fn.bodyToWorld(left, true);
|
||||
};
|
||||
|
||||
$ax.legacy.getAbsoluteTop = function(currentNode, elementId) {
|
||||
var oldDisplay = currentNode.css('display');
|
||||
var displaySet = false;
|
||||
if(oldDisplay == 'none') {
|
||||
currentNode.css('display', '');
|
||||
displaySet = true;
|
||||
}
|
||||
var top = currentNode.offset().top;
|
||||
|
||||
// Special Layer code
|
||||
if ($ax.getTypeFromElementId(elementId) == 'layer') {
|
||||
var first = true;
|
||||
var children = currentNode.children();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = $(children[i]);
|
||||
var subDisplaySet = false;
|
||||
if (child.css('display') == 'none') {
|
||||
child.css('display', '');
|
||||
subDisplaySet = true;
|
||||
}
|
||||
if (first) top = child.offset().top;
|
||||
else top = Math.min(child.offset().top, top);
|
||||
first = false;
|
||||
|
||||
if (subDisplaySet) child.css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
if(displaySet) currentNode.css('display', oldDisplay);
|
||||
return top;
|
||||
};
|
||||
|
||||
// ****************** Annotation and Link Functions ****************** //
|
||||
|
||||
$ax.legacy.GetAnnotationHtml = function(annJson) {
|
||||
var retVal = "";
|
||||
for(var noteName in annJson) {
|
||||
if(noteName != "label" && noteName != "id") {
|
||||
retVal += "<div class='annotationName'>" + noteName + "</div>";
|
||||
retVal += "<div class='annotationValue'>" + linkify(annJson[noteName]) + "</div>";
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
|
||||
function linkify(text) {
|
||||
var urlRegex = /(\b(((https?|ftp|file):\/\/)|(www\.))[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
|
||||
return text.replace(urlRegex, function (url, b, c) {
|
||||
var url2 = (c == 'www.') ? 'http://' + url : url;
|
||||
return '<a href="' + url2 + '" target="_blank" class="noteLink">' + url + '</a>';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$ax.legacy.GetScrollable = function(target) {
|
||||
var $target = $(target);
|
||||
var last = $target;
|
||||
// Start past inital target. Can't scroll to target in itself, must be some ancestor.
|
||||
var current = last.parent();
|
||||
|
||||
while(!current.is('body') && !current.is('html')) {
|
||||
var elementId = current.attr('id');
|
||||
var diagramObject = elementId && $ax.getObjectFromElementId(elementId);
|
||||
if (diagramObject && $ax.public.fn.IsDynamicPanel(diagramObject.type) && diagramObject.scrollbars != 'none') {
|
||||
//returns the panel diagram div which handles scrolling
|
||||
return window.document.getElementById(last.attr('id'));
|
||||
}
|
||||
last = current;
|
||||
current = current.parent();
|
||||
}
|
||||
// Need to do this because of ie
|
||||
if(IE_10_AND_BELOW) return window.document.documentElement;
|
||||
else return window.document.body;
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,358 @@
|
||||
$axure.internal(function($ax) {
|
||||
$ax.public.fn.matrixMultiply = function(matrix, vector) {
|
||||
if(!matrix.tx) matrix.tx = 0;
|
||||
if(!matrix.ty) matrix.ty = 0;
|
||||
var outX = matrix.m11 * vector.x + matrix.m12 * vector.y + matrix.tx;
|
||||
var outY = matrix.m21 * vector.x + matrix.m22 * vector.y + matrix.ty;
|
||||
return { x: outX, y: outY };
|
||||
}
|
||||
|
||||
$ax.public.fn.matrixInverse = function(matrix) {
|
||||
if(!matrix.tx) matrix.tx = 0;
|
||||
if(!matrix.ty) matrix.ty = 0;
|
||||
|
||||
var determinant = matrix.m11*matrix.m22 - matrix.m12*matrix.m21;
|
||||
//var threshold = (M11 * M11 + M22 *M22 + M12 *M12+ M21 *M21) / 100000;
|
||||
//if(determinant.DeltaEquals(0, threshold) && determinant < 0.01) {
|
||||
// return Invalid;
|
||||
//}
|
||||
return {
|
||||
m11 : matrix.m22/determinant,
|
||||
m12 : -matrix.m12/determinant,
|
||||
tx : (matrix.ty*matrix.m12 - matrix.tx*matrix.m22)/determinant,
|
||||
m21: -matrix.m21 / determinant,
|
||||
m22: matrix.m11 / determinant,
|
||||
ty: (matrix.tx * matrix.m21 - matrix.ty * matrix.m11) / determinant
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
$ax.public.fn.matrixMultiplyMatrix = function (matrix1, matrix2) {
|
||||
if (!matrix1.tx) matrix1.tx = 0;
|
||||
if (!matrix1.ty) matrix1.ty = 0;
|
||||
if (!matrix2.tx) matrix2.tx = 0;
|
||||
if (!matrix2.ty) matrix2.ty = 0;
|
||||
|
||||
return {
|
||||
m11: matrix1.m12*matrix2.m21 + matrix1.m11*matrix2.m11,
|
||||
m12: matrix1.m12*matrix2.m22 + matrix1.m11*matrix2.m12,
|
||||
tx: matrix1.m12 * matrix2.ty + matrix1.m11 * matrix2.tx + matrix1.tx,
|
||||
m21: matrix1.m22 * matrix2.m21 + matrix1.m21 * matrix2.m11,
|
||||
m22: matrix1.m22 * matrix2.m22 + matrix1.m21 * matrix2.m12,
|
||||
ty: matrix1.m22 * matrix2.ty + matrix1.m21 * matrix2.tx + matrix1.ty,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
$ax.public.fn.transformFromElement = function (element) {
|
||||
var st = window.getComputedStyle(element, null);
|
||||
|
||||
var tr = st.getPropertyValue("-webkit-transform") ||
|
||||
st.getPropertyValue("-moz-transform") ||
|
||||
st.getPropertyValue("-ms-transform") ||
|
||||
st.getPropertyValue("-o-transform") ||
|
||||
st.getPropertyValue("transform");
|
||||
|
||||
if (tr.indexOf('none') < 0) {
|
||||
var matrix = tr.split('(')[1];
|
||||
matrix = matrix.split(')')[0];
|
||||
matrix = matrix.split(',');
|
||||
for (var l = 0; l < matrix.length; l++) {
|
||||
matrix[l] = Number(matrix[l]);
|
||||
}
|
||||
|
||||
} else { matrix = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]; }
|
||||
|
||||
return matrix;
|
||||
// matrix[0] = cosine, matrix[1] = sine.
|
||||
// Assuming the element is still orthogonal.
|
||||
}
|
||||
|
||||
$ax.public.fn.vectorMinus = function(vector1, vector2) { return { x: vector1.x - vector2.x, y: vector1.y - vector2.y }; }
|
||||
|
||||
$ax.public.fn.vectorPlus = function (vector1, vector2) { return { x: vector1.x + vector2.x, y: vector1.y + vector2.y }; }
|
||||
|
||||
$ax.public.fn.vectorMidpoint = function (vector1, vector2) { return { x: (vector1.x + vector2.x) / 2.0, y: (vector1.y + vector2.y) / 2.0 }; }
|
||||
|
||||
$ax.public.fn.fourCornersToBasis = function (fourCorners) {
|
||||
return {
|
||||
widthVector: $ax.public.fn.vectorMinus(fourCorners.widgetTopRight, fourCorners.widgetTopLeft),
|
||||
heightVector: $ax.public.fn.vectorMinus(fourCorners.widgetBottomLeft, fourCorners.widgetTopLeft)
|
||||
};
|
||||
}
|
||||
|
||||
$ax.public.fn.matrixString = function(m11, m21, m12, m22, tx, ty) {
|
||||
return "Matrix(" + m11 + "," + m21 + "," + m12 + "," + m22 + ", " + tx + ", " + ty + ")";
|
||||
}
|
||||
|
||||
$ax.public.fn.getWidgetBoundingRect = function (widgetId) {
|
||||
var emptyRect = { left: 0, top: 0, centerPoint: { x: 0, y: 0 }, width: 0, height: 0 };
|
||||
var element = document.getElementById(widgetId);
|
||||
if (!element) return emptyRect;
|
||||
|
||||
var object = $obj(widgetId);
|
||||
if (object && object.type && $ax.public.fn.IsLayer(object.type)) {
|
||||
var layerChildren = _getLayerChildrenDeep(widgetId);
|
||||
if (!layerChildren) return emptyRect;
|
||||
else return _getBoundingRectForMultipleWidgets(layerChildren);
|
||||
}
|
||||
return _getBoundingRectForSingleWidget(widgetId);
|
||||
};
|
||||
|
||||
var _getLayerChildrenDeep = $ax.public.fn.getLayerChildrenDeep = function (layerId, includeLayers, includeHidden) {
|
||||
var deep = [];
|
||||
var children = $ax('#' + layerId).getChildren()[0].children;
|
||||
for (var index = 0; index < children.length; index++) {
|
||||
var childId = children[index];
|
||||
if(!includeHidden && !$ax.visibility.IsIdVisible(childId)) continue;
|
||||
if ($ax.public.fn.IsLayer($obj(childId).type)) {
|
||||
if (includeLayers) deep.push(childId);
|
||||
var recursiveChildren = _getLayerChildrenDeep(childId, includeLayers, includeHidden);
|
||||
for (var j = 0; j < recursiveChildren.length; j++) deep.push(recursiveChildren[j]);
|
||||
} else deep.push(childId);
|
||||
}
|
||||
return deep;
|
||||
};
|
||||
|
||||
var _getBoundingRectForMultipleWidgets = function (widgetsIdArray, relativeToPage) {
|
||||
if (!widgetsIdArray || widgetsIdArray.constructor !== Array) return undefined;
|
||||
if (widgetsIdArray.length == 0) return { left: 0, top: 0, centerPoint: { x: 0, y: 0 }, width: 0, height: 0 };
|
||||
var widgetRect = _getBoundingRectForSingleWidget(widgetsIdArray[0], relativeToPage, true);
|
||||
var boundingRect = { left: widgetRect.left, right: widgetRect.right, top: widgetRect.top, bottom: widgetRect.bottom };
|
||||
|
||||
for (var index = 1; index < widgetsIdArray.length; index++) {
|
||||
widgetRect = _getBoundingRectForSingleWidget(widgetsIdArray[index], relativeToPage);
|
||||
boundingRect.left = Math.min(boundingRect.left, widgetRect.left);
|
||||
boundingRect.top = Math.min(boundingRect.top, widgetRect.top);
|
||||
boundingRect.right = Math.max(boundingRect.right, widgetRect.right);
|
||||
boundingRect.bottom = Math.max(boundingRect.bottom, widgetRect.bottom);
|
||||
}
|
||||
|
||||
boundingRect.centerPoint = { x: (boundingRect.right + boundingRect.left) / 2.0, y: (boundingRect.bottom + boundingRect.top) / 2.0 };
|
||||
boundingRect.width = boundingRect.right - boundingRect.left;
|
||||
boundingRect.height = boundingRect.bottom - boundingRect.top;
|
||||
return boundingRect;
|
||||
};
|
||||
|
||||
var _getBoundingRectForSingleWidget = function (widgetId, relativeToPage, justSides) {
|
||||
var element = document.getElementById(widgetId);
|
||||
var boundingRect, tempBoundingRect, position;
|
||||
var displayChanged = _displayHackStart(element);
|
||||
|
||||
if (_isCompoundVectorHtml(element)) {
|
||||
//tempBoundingRect = _getCompoundImageBoundingClientSize(widgetId);
|
||||
//position = { left: tempBoundingRect.left, top: tempBoundingRect.top };
|
||||
position = $(element).position();
|
||||
tempBoundingRect = {};
|
||||
tempBoundingRect.left = position.left; //= _getCompoundImageBoundingClientSize(widgetId);
|
||||
tempBoundingRect.top = position.top;
|
||||
tempBoundingRect.width = Number(element.getAttribute('WidgetWidth'));
|
||||
tempBoundingRect.height = Number(element.getAttribute('WidgetHeight'));
|
||||
} else {
|
||||
tempBoundingRect = element.getBoundingClientRect();
|
||||
position = $(element).position();
|
||||
}
|
||||
|
||||
var layers = $ax('#' + widgetId).getParents(true, ['layer'])[0];
|
||||
var flip = '';
|
||||
var mirrorWidth = 0;
|
||||
var mirrorHeight = 0;
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
|
||||
//should always be 0,0
|
||||
var layerPos = $jobj(layers[i]).position();
|
||||
position.left += layerPos.left;
|
||||
position.top += layerPos.top;
|
||||
|
||||
var outer = $ax.visibility.applyWidgetContainer(layers[i], true, true);
|
||||
if (outer.length) {
|
||||
var outerPos = outer.position();
|
||||
position.left += outerPos.left;
|
||||
position.top += outerPos.top;
|
||||
}
|
||||
|
||||
//when a group is flipped we find the unflipped position
|
||||
var inner = $jobj(layers[i] + '_container_inner');
|
||||
var taggedFlip = inner.data('flip');
|
||||
if (inner.length && taggedFlip) {
|
||||
//only account for flip if transform is applied
|
||||
var matrix = taggedFlip && (inner.css("-webkit-transform") || inner.css("-moz-transform") ||
|
||||
inner.css("-ms-transform") || inner.css("-o-transform") || inner.css("transform"));
|
||||
if (matrix !== 'none') {
|
||||
flip = taggedFlip;
|
||||
mirrorWidth = $ax.getNumFromPx(inner.css('width'));
|
||||
mirrorHeight = $ax.getNumFromPx(inner.css('height'));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Now account for flip
|
||||
if (flip == 'x') position.top = mirrorHeight - position.top - element.getBoundingClientRect().height;
|
||||
else if (flip == 'y') position.left = mirrorWidth - position.left - element.getBoundingClientRect().width;
|
||||
|
||||
boundingRect = {
|
||||
left: position.left,
|
||||
right: position.left + tempBoundingRect.width,
|
||||
top: position.top,
|
||||
bottom: position.top + tempBoundingRect.height
|
||||
};
|
||||
|
||||
_displayHackEnd(displayChanged);
|
||||
if (justSides) return boundingRect;
|
||||
|
||||
boundingRect.width = boundingRect.right - boundingRect.left;
|
||||
boundingRect.height = boundingRect.bottom - boundingRect.top;
|
||||
|
||||
boundingRect.centerPoint = {
|
||||
x: boundingRect.width / 2 + boundingRect.left,
|
||||
y: boundingRect.height / 2 + boundingRect.top
|
||||
};
|
||||
|
||||
return boundingRect;
|
||||
};
|
||||
|
||||
var _getPointAfterRotate = $ax.public.fn.getPointAfterRotate = function (angleInDegrees, pointToRotate, centerPoint) {
|
||||
var displacement = $ax.public.fn.vectorMinus(pointToRotate, centerPoint);
|
||||
var rotationMatrix = $ax.public.fn.rotationMatrix(angleInDegrees);
|
||||
rotationMatrix.tx = centerPoint.x;
|
||||
rotationMatrix.ty = centerPoint.y;
|
||||
return $ax.public.fn.matrixMultiply(rotationMatrix, displacement);
|
||||
};
|
||||
|
||||
$ax.public.fn.getBoundingSizeForRotate = function(width, height, rotation) {
|
||||
// point to rotate around doesn't matter since we just care about size, if location matter we need more args and location matters.
|
||||
|
||||
var origin = { x: 0, y: 0 };
|
||||
|
||||
var corner1 = { x: width, y: 0 };
|
||||
var corner2 = { x: 0, y: height };
|
||||
var corner3 = { x: width, y: height };
|
||||
|
||||
corner1 = _getPointAfterRotate(rotation, corner1, origin);
|
||||
corner2 = _getPointAfterRotate(rotation, corner2, origin);
|
||||
corner3 = _getPointAfterRotate(rotation, corner3, origin);
|
||||
|
||||
var left = Math.min(0, corner1.x, corner2.x, corner3.x);
|
||||
var right = Math.max(0, corner1.x, corner2.x, corner3.x);
|
||||
var top = Math.min(0, corner1.y, corner2.y, corner3.y);
|
||||
var bottom = Math.max(0, corner1.y, corner2.y, corner3.y);
|
||||
|
||||
return { width: right - left, height: bottom - top };
|
||||
}
|
||||
|
||||
$ax.public.fn.getPositionRelativeToParent = function (elementId) {
|
||||
var element = document.getElementById(elementId);
|
||||
var list = _displayHackStart(element);
|
||||
var position = $(element).position();
|
||||
_displayHackEnd(list);
|
||||
return position;
|
||||
};
|
||||
|
||||
var _displayHackStart = $ax.public.fn.displayHackStart = function (element) {
|
||||
// TODO: Options: 1) stop setting display none. Big change for this late in the game. 2) Implement our own bounding.
|
||||
// TODO: 3) Current method is look for any parents that are set to none, and and temporarily unblock. Don't like it, but it works.
|
||||
var parent = element;
|
||||
var displays = [];
|
||||
while (parent) {
|
||||
if (parent.style.display == 'none') {
|
||||
displays.push(parent);
|
||||
//use block to overwrites default hidden objects' display
|
||||
parent.style.display = 'block';
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
|
||||
return displays;
|
||||
};
|
||||
|
||||
var _displayHackEnd = $ax.public.fn.displayHackEnd = function (displayChangedList) {
|
||||
for (var i = 0; i < displayChangedList.length; i++) displayChangedList[i].style.display = 'none';
|
||||
};
|
||||
|
||||
|
||||
var _isCompoundVectorHtml = $ax.public.fn.isCompoundVectorHtml = function(hElement) {
|
||||
return hElement.hasAttribute('compoundmode') && hElement.getAttribute('compoundmode') == "true";
|
||||
}
|
||||
|
||||
$ax.public.fn.removeCompound = function (jobj) { if(_isCompoundVectorHtml(jobj[0])) jobj.removeClass('compound'); }
|
||||
$ax.public.fn.restoreCompound = function (jobj) { if (_isCompoundVectorHtml(jobj[0])) jobj.addClass('compound'); }
|
||||
|
||||
$ax.public.fn.compoundIdFromComponent = function(id) {
|
||||
|
||||
var pPos = id.indexOf('p');
|
||||
var dashPos = id.indexOf('-');
|
||||
if (pPos < 1) return id;
|
||||
else if (dashPos < 0) return id.substring(0, pPos);
|
||||
else return id.substring(0, pPos) + id.substring(dashPos);
|
||||
}
|
||||
|
||||
$ax.public.fn.l2 = function (x, y) { return Math.sqrt(x * x + y * y); }
|
||||
|
||||
$ax.public.fn.convertToSingleImage = function (jobj) {
|
||||
|
||||
var widgetId = jobj[0].id;
|
||||
var object = $obj(widgetId);
|
||||
|
||||
if ($ax.public.fn.IsLayer(object.type)) {
|
||||
var recursiveChildren = _getLayerChildrenDeep(widgetId, true);
|
||||
for (var j = 0; j < recursiveChildren.length; j++)
|
||||
$ax.public.fn.convertToSingleImage($jobj(recursiveChildren[j]));
|
||||
return;
|
||||
}
|
||||
|
||||
//var layer =
|
||||
|
||||
if(!_isCompoundVectorHtml(jobj[0])) return;
|
||||
|
||||
|
||||
$('#' + widgetId).removeClass("compound");
|
||||
$('#' + widgetId + '_img').removeClass("singleImg");
|
||||
jobj[0].setAttribute('compoundmode', 'false');
|
||||
|
||||
var components = object.compoundChildren;
|
||||
delete object.generateCompound;
|
||||
for (var i = 0; i < components.length; i++) {
|
||||
var componentJobj = $jobj($ax.public.fn.getComponentId(widgetId, components[i]));
|
||||
componentJobj.css('display', 'none');
|
||||
componentJobj.css('visibility', 'hidden');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ax.public.fn.getContainerDimensions = function(query) {
|
||||
// returns undefined if no containers found.
|
||||
var containerDimensions;
|
||||
for (var i = 0; i < query[0].children.length; i++) {
|
||||
var node = query[0].children[i];
|
||||
if (node.id.indexOf(query[0].id) >= 0 && node.id.indexOf('container') >= 0) {
|
||||
containerDimensions = node.style;
|
||||
}
|
||||
}
|
||||
return containerDimensions;
|
||||
}
|
||||
|
||||
|
||||
$ax.public.fn.rotationMatrix = function (angleInDegrees) {
|
||||
var angleInRadians = angleInDegrees * (Math.PI / 180);
|
||||
var cosTheta = Math.cos(angleInRadians);
|
||||
var sinTheta = Math.sin(angleInRadians);
|
||||
|
||||
return { m11: cosTheta, m12: -sinTheta, m21: sinTheta, m22: cosTheta, tx: 0.0, ty: 0.0 };
|
||||
}
|
||||
|
||||
$ax.public.fn.GetFieldFromStyle = function (query, field) {
|
||||
var raw = query[0].style[field];
|
||||
if (!raw) raw = query.css(field);
|
||||
return Number(raw.replace('px', ''));
|
||||
}
|
||||
|
||||
|
||||
$ax.public.fn.setTransformHowever = function (transformString) {
|
||||
return {
|
||||
'-webkit-transform': transformString,
|
||||
'-moz-transform': transformString,
|
||||
'-ms-transform': transformString,
|
||||
'-o-transform': transformString,
|
||||
'transform': transformString
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
// ******* Object Model ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var _implementations = {};
|
||||
|
||||
var _initializeObject = function(type, obj) {
|
||||
$.extend(obj, _implementations[type]);
|
||||
};
|
||||
$ax.initializeObject = _initializeObject;
|
||||
|
||||
var _model = $ax.model = {};
|
||||
|
||||
_model.idsInRdo = function(rdoId, scriptIds) {
|
||||
var rdoScriptId = $ax.repeater.getScriptIdFromElementId(rdoId);
|
||||
var path = $ax.getPathFromScriptId(rdoScriptId);
|
||||
var rdoRepeater = $ax.getParentRepeaterFromScriptId(rdoScriptId);
|
||||
|
||||
if(!scriptIds) scriptIds = [];
|
||||
$ax('*').each(function(obj, elementId) {
|
||||
// Make sure in same rdo
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(elementId);
|
||||
var elementPath = $ax.getPathFromScriptId(scriptId);
|
||||
// This is because last part of path is for the obj itself.
|
||||
elementPath.pop();
|
||||
if(elementPath.length != path.length) return;
|
||||
for(var i = 0; i < path.length; i++) if(elementPath[i] != path[i]) return;
|
||||
|
||||
// If object is in a panel, the panel will be hidden, so the obj doesn't have to be.
|
||||
if(obj.parentDynamicPanel) return;
|
||||
|
||||
var repeater = $ax.getParentRepeaterFromScriptId(scriptId);
|
||||
if(repeater != rdoRepeater) return;
|
||||
|
||||
if($ax.public.fn.IsReferenceDiagramObject(obj.type)) _model.idsInRdo(scriptId, scriptIds);
|
||||
else if(scriptIds.indexOf(scriptId) != -1) return;
|
||||
// Kind of complicated, but returning for isContained objects, hyperlinks, tabel cell, non-root tree nodes, and images in the tree.
|
||||
else if (obj.isContained || obj.type == 'hyperlink' || $ax.public.fn.IsTableCell(obj.type) ||
|
||||
($ax.public.fn.IsTreeNodeObject(obj.type) && !$jobj(elementId).hasClass('treeroot')) ||
|
||||
($ax.public.fn.IsImageBox(obj.type) && $ax.public.fn.IsTreeNodeObject(obj.parent.type))) return;
|
||||
else scriptIds.push(scriptId);
|
||||
});
|
||||
return scriptIds;
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,410 @@
|
||||
$axure.internal(function($ax) {
|
||||
var _move = {};
|
||||
$ax.move = _move;
|
||||
|
||||
var widgetMoveInfo = {};
|
||||
var _getMoveInfo = $ax.move.RegisterMoveInfo = function (id, x, y, to, options, jobj) {
|
||||
var fixedInfo = jobj ? {} : $ax.dynamicPanelManager.getFixedInfo(id);
|
||||
|
||||
var widget = $jobj(id);
|
||||
var query = $ax('#' + id);
|
||||
var isLayer = $ax.getTypeFromElementId(id) == $ax.constants.LAYER_TYPE;
|
||||
var rootLayer = _move.getRootLayer(id);
|
||||
|
||||
if(rootLayer) {
|
||||
$ax.visibility.pushContainer(rootLayer, false);
|
||||
if(isLayer) widget = $ax.visibility.applyWidgetContainer(id, true);
|
||||
}
|
||||
if (!jobj) jobj = widget;
|
||||
|
||||
var horzProp = 'left';
|
||||
var vertProp = 'top';
|
||||
var horzX = to ? x - query.locRelativeIgnoreLayer(false) : x;
|
||||
var vertY = to ? y - query.locRelativeIgnoreLayer(true) : y;
|
||||
|
||||
if (fixedInfo.horizontal == 'right') {
|
||||
horzProp = 'right';
|
||||
horzX = to ? $(window).width() - x - Number(jobj.css('right').replace('px', '')) - query.width() : -x;
|
||||
} else if(fixedInfo.horizontal == 'center') {
|
||||
horzProp = 'margin-left';
|
||||
if (to) horzX = x - $(window).width() / 2;
|
||||
}
|
||||
|
||||
if (fixedInfo.vertical == 'bottom') {
|
||||
vertProp = 'bottom';
|
||||
vertY = to ? $(window).height() - y - Number(jobj.css('bottom').replace('px', '')) - query.height() : -y;
|
||||
} else if (fixedInfo.vertical == 'middle') {
|
||||
vertProp = 'margin-top';
|
||||
if (to) vertY = y - $(window).height() / 2;
|
||||
}
|
||||
|
||||
//todo currently this always save the info, which is not needed for compound vector children and maybe some other cases
|
||||
//let's optimize it later, only register if registerid is valid..
|
||||
widgetMoveInfo[id] = {
|
||||
x: horzX,
|
||||
y: vertY,
|
||||
options: options
|
||||
};
|
||||
|
||||
return {
|
||||
horzX: horzX,
|
||||
vertY: vertY,
|
||||
horzProp: horzProp,
|
||||
vertProp: vertProp,
|
||||
rootLayer: rootLayer,
|
||||
jobj: jobj
|
||||
};
|
||||
};
|
||||
$ax.move.GetWidgetMoveInfo = function() {
|
||||
return $.extend({}, widgetMoveInfo);
|
||||
};
|
||||
|
||||
_move.getRootLayer = function (id) {
|
||||
var isLayer = $ax.getTypeFromElementId(id) == $ax.constants.LAYER_TYPE;
|
||||
var rootLayer = isLayer ? id : '';
|
||||
|
||||
var parentIds = $ax('#' + id).getParents(true, '*')[0];
|
||||
for(var i = 0; i < parentIds.length; i++) {
|
||||
var parentId = parentIds[i];
|
||||
// Keep climbing up layers until you hit a non-layer. At that point you have your root layer
|
||||
if($ax.public.fn.IsLayer($ax.getTypeFromElementId(parentId))) rootLayer = parentId;
|
||||
else break;
|
||||
}
|
||||
|
||||
return rootLayer;
|
||||
};
|
||||
|
||||
$ax.move.MoveWidget = function (id, x, y, options, to, animationCompleteCallback, shouldFire, jobj, moveInfo) {
|
||||
$ax.drag.LogMovedWidgetForDrag(id, options.dragInfo);
|
||||
|
||||
if(!moveInfo) moveInfo = _getMoveInfo(id, x, y, to, options, jobj);
|
||||
|
||||
jobj = moveInfo.jobj;
|
||||
|
||||
_moveElement(id, options, animationCompleteCallback, shouldFire, jobj, moveInfo);
|
||||
|
||||
$ax.event.raiseSyntheticEvent(id, "onMove");
|
||||
var object = $obj(id);
|
||||
if(object && $ax.public.fn.IsLayer(object.type)) {
|
||||
var childrenIds = $ax.public.fn.getLayerChildrenDeep(id, true);
|
||||
for(var i = 0; i < childrenIds.length; i++) $ax.event.raiseSyntheticEvent(childrenIds[i], 'onMove');
|
||||
}
|
||||
};
|
||||
|
||||
var _moveElement = function (id, options, animationCompleteCallback, shouldFire, jobj, moveInfo){
|
||||
var cssStyles = {};
|
||||
|
||||
if(!$ax.dynamicPanelManager.isPercentWidthPanel($obj(id))) cssStyles[moveInfo.horzProp] = '+=' + moveInfo.horzX;
|
||||
cssStyles[moveInfo.vertProp] = '+=' + moveInfo.vertY;
|
||||
|
||||
// I don't think root layer is necessary anymore after changes to layer container structure.
|
||||
// Wait to try removing it until more stable.
|
||||
var rootLayer = moveInfo.rootLayer;
|
||||
|
||||
var query = $addAll(jobj, id);
|
||||
if(options.easing == 'none') {
|
||||
query.animate(cssStyles, { duration: 0, queue: false });
|
||||
|
||||
if(animationCompleteCallback) animationCompleteCallback();
|
||||
if(rootLayer) $ax.visibility.popContainer(rootLayer, false);
|
||||
//if this widget is inside a layer, we should just remove the layer from the queue
|
||||
if(shouldFire) $ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.move);
|
||||
} else {
|
||||
var completeCount = query.length;
|
||||
query.animate(cssStyles, {
|
||||
duration: options.duration, easing: options.easing, queue: false, complete: function () {
|
||||
if (animationCompleteCallback) animationCompleteCallback();
|
||||
completeCount--;
|
||||
if(completeCount == 0 && rootLayer) $ax.visibility.popContainer(rootLayer, false);
|
||||
if(shouldFire) $ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.move);
|
||||
}});
|
||||
}
|
||||
|
||||
// //moveinfo is used for moving 'with this'
|
||||
// var moveInfo = new Object();
|
||||
// moveInfo.x = horzX;
|
||||
// moveInfo.y = vertY;
|
||||
// moveInfo.options = options;
|
||||
// widgetMoveInfo[id] = moveInfo;
|
||||
|
||||
|
||||
};
|
||||
|
||||
_move.nopMove = function(id) {
|
||||
var moveInfo = new Object();
|
||||
moveInfo.x = 0;
|
||||
moveInfo.y = 0;
|
||||
moveInfo.options = {};
|
||||
moveInfo.options.easing = 'none';
|
||||
moveInfo.options.duration = 0;
|
||||
widgetMoveInfo[id] = moveInfo;
|
||||
$ax.event.raiseSyntheticEvent(id, "onMove");
|
||||
};
|
||||
|
||||
//rotationDegree: total degree to rotate
|
||||
//centerPoint: the center of the circular path
|
||||
|
||||
|
||||
var _noRotateOnlyMove = function (id, moveDelta, rotatableMove, fireAnimationQueue, easing, duration, completionCallback) {
|
||||
moveDelta.x += rotatableMove.x;
|
||||
moveDelta.y += rotatableMove.y;
|
||||
if (moveDelta.x == 0 && moveDelta.y == 0) {
|
||||
if(fireAnimationQueue) {
|
||||
$ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.rotate);
|
||||
$ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.move);
|
||||
}
|
||||
} else {
|
||||
$jobj(id).animate({ top: '+=' + moveDelta.y, left: '+=' + moveDelta.x }, {
|
||||
duration: duration,
|
||||
easing: easing,
|
||||
queue: false,
|
||||
complete: function () {
|
||||
if(fireAnimationQueue) {
|
||||
$ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.move);
|
||||
$ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.rotate);
|
||||
}
|
||||
if (completionCallback) completionCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_move.circularMove = function (id, degreeDelta, centerPoint, moveDelta, rotatableMove, resizeOffset, options, fireAnimationQueue, completionCallback) {
|
||||
var elem = $jobj(id);
|
||||
var moveInfo = $ax.move.RegisterMoveInfo(id, moveDelta.x, moveDelta.y, false, options);
|
||||
// If not rotating, still need to check moveDelta and may need to handle that.
|
||||
if (degreeDelta === 0) {
|
||||
_noRotateOnlyMove(id, moveDelta, rotatableMove, fireAnimationQueue, options.easing, options.duration, completionCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
var stepFunc = function(newDegree) {
|
||||
var deg = newDegree - rotation.degree;
|
||||
var widgetCenter = $ax.public.fn.getWidgetBoundingRect(id).centerPoint;
|
||||
//console.log("widget center of " + id + " x " + widgetCenter.x + " y " + widgetCenter.y);
|
||||
var widgetNewCenter = $axure.fn.getPointAfterRotate(deg, widgetCenter, centerPoint);
|
||||
|
||||
// Start by getting the move not related to rotation, and make sure to update center point to move with it.
|
||||
var ratio = deg / degreeDelta;
|
||||
|
||||
var xdelta = (moveDelta.x + rotatableMove.x) * ratio;
|
||||
var ydelta = (moveDelta.y + rotatableMove.y) * ratio;
|
||||
if(resizeOffset) {
|
||||
var resizeShift = {};
|
||||
resizeShift.x = resizeOffset.x * ratio;
|
||||
resizeShift.y = resizeOffset.y * ratio;
|
||||
$axure.fn.getPointAfterRotate(rotation.degree, resizeShift, { x: 0, y: 0 });
|
||||
xdelta += resizeShift.x;
|
||||
ydelta += resizeShift.y;
|
||||
}
|
||||
centerPoint.x += xdelta;
|
||||
centerPoint.y += ydelta;
|
||||
|
||||
// Now for the move that is rotatable, it must be rotated
|
||||
rotatableMove = $axure.fn.getPointAfterRotate(deg, rotatableMove, { x: 0, y: 0 });
|
||||
|
||||
// Now add in circular move to the mix.
|
||||
xdelta += widgetNewCenter.x - widgetCenter.x;
|
||||
ydelta += widgetNewCenter.y - widgetCenter.y;
|
||||
|
||||
if(xdelta < 0) elem.css('left', '-=' + -xdelta);
|
||||
else if(xdelta > 0) elem.css('left', '+=' + xdelta);
|
||||
|
||||
if(ydelta < 0) elem.css('top', '-=' + -ydelta);
|
||||
else if(ydelta > 0) elem.css('top', '+=' + ydelta);
|
||||
};
|
||||
|
||||
var onComplete = function() {
|
||||
if(fireAnimationQueue) $ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.move);
|
||||
if(completionCallback) completionCallback();
|
||||
if(moveInfo.rootLayer) $ax.visibility.popContainer(moveInfo.rootLayer, false);
|
||||
};
|
||||
|
||||
var rotation = { degree: 0 };
|
||||
|
||||
if(!options.easing || options.easing === 'none' || options.duration <= 0) {
|
||||
stepFunc(degreeDelta);
|
||||
onComplete();
|
||||
} else {
|
||||
$(rotation).animate({ degree: degreeDelta }, {
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
queue: false,
|
||||
step: stepFunc,
|
||||
complete: onComplete
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//rotate a widget by degree, center is 50% 50%
|
||||
_move.rotate = function (id, degree, easing, duration, to, shouldFire, completionCallback) {
|
||||
var currentDegree = _getRotationDegree(id);
|
||||
if(to) degree = degree - currentDegree;
|
||||
|
||||
if(degree === 0) {
|
||||
if (shouldFire) $ax.action.fireAnimationFromQueue(id, $ax.action.queueTypes.rotate);
|
||||
return;
|
||||
}
|
||||
|
||||
var query = $jobj(id).add($jobj(id + '_ann')).add($jobj(id + '_ref'));
|
||||
|
||||
var stepFunc = function(now) {
|
||||
var degreeDelta = now - rotation.degree;
|
||||
var newDegree = currentDegree + degreeDelta;
|
||||
query.css($ax.public.fn.setTransformHowever("rotate(" + newDegree + "deg)"));
|
||||
currentDegree = newDegree;
|
||||
};
|
||||
|
||||
var onComplete = function() {
|
||||
if(shouldFire) {
|
||||
$ax.action.fireAnimationFromQueue($ax.public.fn.compoundIdFromComponent(id), $ax.action.queueTypes.rotate);
|
||||
}
|
||||
if(completionCallback) completionCallback();
|
||||
};
|
||||
|
||||
var rotation = { degree: 0 };
|
||||
|
||||
|
||||
//if no animation, setting duration to 1, to prevent RangeError in rotation loops without animation
|
||||
if(!easing || easing === 'none' || duration <= 0) {
|
||||
stepFunc(degree);
|
||||
onComplete();
|
||||
} else {
|
||||
$(rotation).animate({ degree: degree }, {
|
||||
duration: duration,
|
||||
easing: easing,
|
||||
queue: false,
|
||||
step: stepFunc,
|
||||
complete: onComplete
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_move.compoundRotateAround = function (id, degreeDelta, centerPoint, moveDelta, rotatableMove, resizeOffset, easing, duration, fireAnimationQueue, completionCallback) {
|
||||
if (degreeDelta === 0) {
|
||||
_noRotateOnlyMove($ax.public.fn.compoundIdFromComponent(id), moveDelta, rotatableMove, fireAnimationQueue, easing, duration, completionCallback, $ax.action.queueTypes.rotate);
|
||||
return;
|
||||
}
|
||||
var elem = $jobj(id);
|
||||
var rotation = { degree: 0 };
|
||||
|
||||
if (!easing || easing === 'none' || duration <= 0) {
|
||||
duration = 1;
|
||||
easing = 'linear'; //it doesn't matter anymore here...
|
||||
}
|
||||
|
||||
var originalWidth = Number(elem.css('width').replace('px', ''));
|
||||
var originalHeight = Number(elem.css('height').replace('px', ''));
|
||||
var originalLeft = Number(elem.css('left').replace('px', ''));
|
||||
var originalTop = Number(elem.css('top').replace('px', ''));
|
||||
|
||||
$(rotation).animate({ degree: degreeDelta }, {
|
||||
duration: duration,
|
||||
easing: easing,
|
||||
queue: false,
|
||||
step: function (newDegree) {
|
||||
var transform = $ax.public.fn.transformFromElement(elem[0]);
|
||||
var originalCenter = { x: originalLeft + 0.5 * originalWidth, y: originalTop + 0.5 * originalHeight};
|
||||
var componentCenter = { x: originalCenter.x + transform[4], y: originalCenter.y + transform[5] };
|
||||
var deg = newDegree - rotation.degree;
|
||||
var ratio = deg / degreeDelta;
|
||||
var xdelta = (moveDelta.x + rotatableMove.x) * ratio;
|
||||
var ydelta = (moveDelta.y + rotatableMove.y) * ratio;
|
||||
if (resizeOffset) {
|
||||
var resizeShift = {};
|
||||
resizeShift.x = resizeOffset.x * ratio;
|
||||
resizeShift.y = resizeOffset.y * ratio;
|
||||
$axure.fn.getPointAfterRotate(rotation.degree, resizeShift, { x: 0, y: 0 });
|
||||
xdelta += resizeShift.x;
|
||||
ydelta += resizeShift.y;
|
||||
}
|
||||
|
||||
var rotationMatrix = $ax.public.fn.rotationMatrix(deg);
|
||||
var compositionTransform = $ax.public.fn.matrixMultiplyMatrix(rotationMatrix,
|
||||
{ m11: transform[0], m21: transform[1], m12: transform[2], m22: transform[3] });
|
||||
|
||||
//console.log("widget center of " + id + " x " + widgetCenter.x + " y " + widgetCenter.y);
|
||||
var widgetNewCenter = $axure.fn.getPointAfterRotate(deg, componentCenter, centerPoint);
|
||||
var newMatrix = $ax.public.fn.matrixString(compositionTransform.m11, compositionTransform.m21, compositionTransform.m12, compositionTransform.m22,
|
||||
widgetNewCenter.x - originalCenter.x + xdelta, widgetNewCenter.y - originalCenter.y + ydelta);
|
||||
elem.css($ax.public.fn.setTransformHowever(newMatrix));
|
||||
},
|
||||
complete: function () {
|
||||
if (fireAnimationQueue) {
|
||||
$ax.action.fireAnimationFromQueue(elem.parent()[0].id, $ax.action.queueTypes.rotate);
|
||||
}
|
||||
|
||||
if(completionCallback) completionCallback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var _getRotationDegree = _move.getRotationDegree = function(elementId) {
|
||||
if($ax.public.fn.IsLayer($obj(elementId).type)) {
|
||||
return $jobj(elementId).data('layerDegree');
|
||||
}
|
||||
|
||||
var element = document.getElementById(elementId);
|
||||
if(element == null) return NaN;
|
||||
//var transformString = element.style.transform ||
|
||||
// element.style.OTransform ||
|
||||
// element.style.msTransform ||
|
||||
// element.style.MozTransform ||
|
||||
// element.style.webkitTransform;
|
||||
|
||||
var transformString = element.style['transform'] ||
|
||||
element.style['-o-transform'] ||
|
||||
element.style['-ms-transform'] ||
|
||||
element.style['-moz-transform'] ||
|
||||
element.style['-webkit-transform'];
|
||||
|
||||
if(transformString) {
|
||||
var rotateRegex = /rotate\(([-?0-9]+)deg\)/;
|
||||
var degreeMatch = rotateRegex.exec(transformString);
|
||||
if(degreeMatch && degreeMatch[1]) return parseFloat(degreeMatch[1]);
|
||||
}
|
||||
|
||||
if(window.getComputedStyle) {
|
||||
var st = window.getComputedStyle(element, null);
|
||||
} else {
|
||||
console.log('rotation is not supported for ie 8 and below in this version of axure rp');
|
||||
return 0;
|
||||
}
|
||||
|
||||
var tr = st.getPropertyValue("transform") ||
|
||||
st.getPropertyValue("-o-transform") ||
|
||||
st.getPropertyValue("-ms-transform") ||
|
||||
st.getPropertyValue("-moz-transform") ||
|
||||
st.getPropertyValue("-webkit-transform");
|
||||
|
||||
|
||||
if(!tr || tr === 'none') return 0;
|
||||
var values = tr.split('(')[1];
|
||||
values = values.split(')')[0],
|
||||
values = values.split(',');
|
||||
|
||||
var a = values[0];
|
||||
var b = values[1];
|
||||
|
||||
var radians = Math.atan2(b, a);
|
||||
if(radians < 0) {
|
||||
radians += (2 * Math.PI);
|
||||
}
|
||||
|
||||
var angle = Math.round(radians * (180 / Math.PI));
|
||||
|
||||
return angle;
|
||||
};
|
||||
|
||||
// var generateFilter = function(deg) {
|
||||
// var rot, cos, sin, matrix;
|
||||
//
|
||||
// rot=deg>=0 ? Math.PI*deg/180 : Math.PI*(360+deg)/180;
|
||||
// cos=Math.cos(rot);
|
||||
// sin=Math.sin(rot);
|
||||
// matrix='M11='+cos+',M12='+(-sin)+',M21='+sin+',M22='+cos+',SizingMethod="auto expand"';
|
||||
// return 'progid:DXImageTransform.Microsoft.Matrix('+matrix+')';
|
||||
// }
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
// ******* Recording MANAGER ******** //
|
||||
|
||||
$axure.internal(function($ax) {
|
||||
var _recording = $ax.recording = {};
|
||||
|
||||
$ax.recording.recordEvent = function(element, eventInfo, axEventObject, timeStamp) {
|
||||
|
||||
var elementHtml = $jobj(element);
|
||||
var className = elementHtml.attr('class');
|
||||
var inputValue;
|
||||
|
||||
if(className === 'ax_checkbox') {
|
||||
inputValue = elementHtml.find('#' + element + '_input')[0].checked;
|
||||
eventInfo.inputType = className;
|
||||
eventInfo.inputValue = inputValue;
|
||||
}
|
||||
|
||||
if(className === 'ax_text_field') {
|
||||
inputValue = elementHtml.find('#' + element + '_input').val();
|
||||
eventInfo.inputType = className;
|
||||
eventInfo.inputValue = inputValue;
|
||||
}
|
||||
|
||||
|
||||
var scriptId = $ax.repeater.getScriptIdFromElementId(element);
|
||||
var diagramObjectPath = $ax.getPathFromScriptId(scriptId);
|
||||
var form = {
|
||||
recordingId: $ax.recording.recordingId,
|
||||
elementID: element,
|
||||
eventType: axEventObject.description,
|
||||
'eventInfo': eventInfo,
|
||||
// eventObject: axEventObject,
|
||||
'timeStamp': timeStamp,
|
||||
'path': diagramObjectPath
|
||||
// ,
|
||||
// 'trigger': function() {
|
||||
// $ax.event.handleEvent(element, eventInfo, axEventObject);
|
||||
// return false;
|
||||
// }
|
||||
};
|
||||
|
||||
$ax.messageCenter.postMessage('logEvent', form);
|
||||
};
|
||||
|
||||
|
||||
$ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
|
||||
};
|
||||
|
||||
|
||||
$ax.recording.recordingId = "";
|
||||
$ax.recording.recordingName = "";
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
if(message === 'startRecording') {
|
||||
$ax.recording.maybeRecordEvent = $ax.recording.recordEvent;
|
||||
$ax.recording.recordingId = data.recordingId;
|
||||
$ax.recording.recordingName = data.recordingName;
|
||||
} else if(message === 'stopRecording') {
|
||||
$ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
|
||||
};
|
||||
|
||||
}
|
||||
else if(message === 'playEvent') {
|
||||
|
||||
var eventType = makeFirstLetterLower(data.eventType);
|
||||
var inputElement;
|
||||
|
||||
var dObj = data.element === '' ? $ax.pageData.page : $ax.getObjectFromElementId(data.element);
|
||||
if(!data.axEventObject) {
|
||||
data.axEventObject = dObj && dObj.interactionMap && dObj.interactionMap[eventType];
|
||||
}
|
||||
|
||||
data.eventInfo.thiswidget = $ax.getWidgetInfo(data.element);
|
||||
data.eventInfo.item = $ax.getItemInfo(data.element);
|
||||
|
||||
if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_checkbox') {
|
||||
inputElement = $jobj(data.element + '_input');
|
||||
inputElement[0].checked = data.eventInfo.inputValue;
|
||||
}
|
||||
|
||||
if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_text_field') {
|
||||
inputElement = $jobj(data.element + '_input');
|
||||
inputElement.val(data.eventInfo.inputValue);
|
||||
}
|
||||
|
||||
$ax.event.handleEvent(data.element, data.eventInfo, data.axEventObject, false, true);
|
||||
}
|
||||
});
|
||||
|
||||
var makeFirstLetterLower = function(eventName) {
|
||||
return eventName.substr(0, 1).toLowerCase() + eventName.substr(1);
|
||||
};
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,230 @@
|
||||
|
||||
$axure.internal(function($ax) {
|
||||
var funcs = {};
|
||||
|
||||
var weekday = new Array(7);
|
||||
weekday[0] = "Sunday";
|
||||
weekday[1] = "Monday";
|
||||
weekday[2] = "Tuesday";
|
||||
weekday[3] = "Wednesday";
|
||||
weekday[4] = "Thursday";
|
||||
weekday[5] = "Friday";
|
||||
weekday[6] = "Saturday";
|
||||
|
||||
funcs.getDayOfWeek = function() {
|
||||
return _getDayOfWeek(this.getDay());
|
||||
};
|
||||
|
||||
var _getDayOfWeek = $ax.getDayOfWeek = function(day) {
|
||||
return weekday[day];
|
||||
};
|
||||
|
||||
var month = new Array(12);
|
||||
month[0] = "January";
|
||||
month[1] = "February";
|
||||
month[2] = "March";
|
||||
month[3] = "April";
|
||||
month[4] = "May";
|
||||
month[5] = "June";
|
||||
month[6] = "July";
|
||||
month[7] = "August";
|
||||
month[8] = "September";
|
||||
month[9] = "October";
|
||||
month[10] = "November";
|
||||
month[11] = "December";
|
||||
|
||||
funcs.getMonthName = function() {
|
||||
return _getMonthName(this.getMonth());
|
||||
};
|
||||
|
||||
var _getMonthName = $ax.getMonthName = function(monthNum) {
|
||||
return month[monthNum];
|
||||
};
|
||||
|
||||
funcs.getMonth = function() {
|
||||
return this.getMonth() + 1;
|
||||
};
|
||||
|
||||
funcs.addYears = function(years) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setFullYear(this.getFullYear() + Number(years));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addMonths = function(months) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setMonth(this.getMonth() + Number(months));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addDays = function(days) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setDate(this.getDate() + Number(days));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addHours = function(hours) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setHours(this.getHours() + Number(hours));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addMinutes = function(minutes) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setMinutes(this.getMinutes() + Number(minutes));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addSeconds = function(seconds) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setSeconds(this.getSeconds() + Number(seconds));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
funcs.addMilliseconds = function(milliseconds) {
|
||||
var retVal = new Date(this.valueOf());
|
||||
retVal.setMilliseconds(this.getMilliseconds() + Number(milliseconds));
|
||||
return retVal;
|
||||
};
|
||||
|
||||
var _stoHandlers = {};
|
||||
|
||||
_stoHandlers.literal = function(sto, scope, eventInfo) {
|
||||
return sto.value;
|
||||
};
|
||||
|
||||
//need angle bracket syntax because var is a reserved word
|
||||
_stoHandlers['var'] = function(sto, scope, eventInfo) {
|
||||
// Can't us 'A || B' here, because the first value can be false, true, or empty string and still be valid.
|
||||
var retVal = scope.hasOwnProperty(sto.name) ? scope[sto.name] : $ax.globalVariableProvider.getVariableValue(sto.name, eventInfo);
|
||||
// Handle desired type here?
|
||||
|
||||
if(retVal && retVal.exprType) {
|
||||
retVal = $ax.expr.evaluateExpr(retVal, eventInfo);
|
||||
}
|
||||
|
||||
if((sto.desiredType == 'int' || sto.desiredType == 'float')) {
|
||||
var num = new Number(retVal);
|
||||
retVal = isNaN(num.valueOf()) ? retVal : num;
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
};
|
||||
|
||||
//TODO: Perhaps repeaterId can be detirmined at generation, and stored in the sto info.
|
||||
_stoHandlers.item = function(sto, scope, eventInfo, prop) {
|
||||
prop = prop || (eventInfo.data ? 'data' : eventInfo.link ? 'url' : eventInfo.image ? 'img' : 'text');
|
||||
var id = sto.isTarget || !$ax.repeater.hasData(eventInfo.srcElement, sto.name) ? eventInfo.targetElement : eventInfo.srcElement;
|
||||
return getData(eventInfo, id, sto.name, prop);
|
||||
};
|
||||
|
||||
var getData = function(eventInfo, id, name, prop) {
|
||||
var repeaterId = $ax.getParentRepeaterFromScriptId($ax.repeater.getScriptIdFromElementId(id));
|
||||
var itemId = $ax.repeater.getItemIdFromElementId(id);
|
||||
return $ax.repeater.getData(eventInfo, repeaterId, itemId, name, prop);
|
||||
};
|
||||
|
||||
_stoHandlers.paren = function(sto, scope, eventInfo) {
|
||||
return _evaluateSTO(sto.innerSTO, scope, eventInfo);
|
||||
};
|
||||
|
||||
_stoHandlers.fCall = function(sto, scope, eventInfo) {
|
||||
//TODO: [mas] handle required type
|
||||
var thisObj = _evaluateSTO(sto.thisSTO, scope, eventInfo);
|
||||
if(sto.thisSTO.desiredType == 'string' && sto.thisSTO.computedType != 'string') thisObj = thisObj.toString();
|
||||
|
||||
var args = [];
|
||||
for(var i = 0; i < sto.arguments.length; i++) {
|
||||
args[i] = _evaluateSTO(sto.arguments[i], scope, eventInfo);
|
||||
}
|
||||
var fn = (funcs.hasOwnProperty(sto.func) && funcs[sto.func]) || thisObj[sto.func];
|
||||
return fn.apply(thisObj, args);
|
||||
};
|
||||
|
||||
_stoHandlers.propCall = function(sto, scope, eventInfo) {
|
||||
//TODO: [mas] handle required type
|
||||
if((sto.prop == 'url' || sto.prop == 'img') && sto.thisSTO.sto == 'item') return _stoHandlers.item(sto.thisSTO, scope, eventInfo, sto.prop);
|
||||
var thisObj = _evaluateSTO(sto.thisSTO, scope, eventInfo);
|
||||
return thisObj[sto.prop];
|
||||
};
|
||||
|
||||
var _binOps = {};
|
||||
_binOps['+'] = function(left, right) {
|
||||
if(left instanceof Date) return addDayToDate(left, right);
|
||||
if(right instanceof Date) return addDayToDate(right, left);
|
||||
|
||||
var num = Number(left) + Number(right);
|
||||
return isNaN(num) ? (String(left) + String(right)) : num;
|
||||
};
|
||||
_binOps['-'] = function(left, right) {
|
||||
if(left instanceof Date) return addDayToDate(left, -right);
|
||||
return left - right;
|
||||
};
|
||||
_binOps['*'] = function(left, right) { return Number(left) * Number(right); };
|
||||
_binOps['/'] = function(left, right) { return Number(left) / Number(right); };
|
||||
_binOps['%'] = function(left, right) { return Number(left) % Number(right); };
|
||||
_binOps['=='] = function(left, right) { return _getBool(left) == _getBool(right); };
|
||||
_binOps['!='] = function(left, right) { return _getBool(left) != _getBool(right); };
|
||||
_binOps['<'] = function(left, right) { return Number(left) < Number(right); };
|
||||
_binOps['<='] = function(left, right) { return Number(left) <= Number(right); };
|
||||
_binOps['>'] = function(left, right) { return Number(left) > Number(right); };
|
||||
_binOps['>='] = function(left, right) { return Number(left) >= Number(right); };
|
||||
_binOps['&&'] = function(left, right) { return _getBool(left) && _getBool(right); };
|
||||
_binOps['||'] = function(left, right) { return _getBool(left) || _getBool(right); };
|
||||
|
||||
// TODO: Move this to generic place to be used.
|
||||
var addDayToDate = function(date, days) {
|
||||
var retVal = new Date(date.valueOf());
|
||||
retVal.setDate(date.getDate() + days);
|
||||
return retVal;
|
||||
};
|
||||
|
||||
var _unOps = {};
|
||||
_unOps['+'] = function(arg) { return +arg; };
|
||||
_unOps['-'] = function(arg) { return -arg; };
|
||||
_unOps['!'] = function(arg) { return !_getBool(arg); };
|
||||
|
||||
_stoHandlers.binOp = function(sto, scope, eventInfo) {
|
||||
var left = _evaluateSTO(sto.leftSTO, scope, eventInfo);
|
||||
var right = _evaluateSTO(sto.rightSTO, scope, eventInfo);
|
||||
return _binOps[sto.op](left, right);
|
||||
};
|
||||
|
||||
_stoHandlers.unOp = function(sto, scope, eventInfo) {
|
||||
var input = _evaluateSTO(sto.inputSTO, scope, eventInfo);
|
||||
return _unOps[sto.op](input);
|
||||
};
|
||||
|
||||
var _getBool = function(val) {
|
||||
var lowerVal = val.toLowerCase ? val.toLowerCase() : val;
|
||||
return lowerVal == "false" ? false : lowerVal == "true" ? true : val;
|
||||
};
|
||||
$ax.getBool = _getBool;
|
||||
|
||||
var _evaluateSTO = function(sto, scope, eventInfo) {
|
||||
if(sto.sto == 'error') return undefined;
|
||||
return _tryEscapeRichText(castSto(_stoHandlers[sto.sto](sto, scope, eventInfo), sto), eventInfo);
|
||||
};
|
||||
$ax.evaluateSTO = _evaluateSTO;
|
||||
|
||||
var castSto = function(val, sto) {
|
||||
var type = sto.computedType || sto.desiredType;
|
||||
if(type == 'string') val = String(val);
|
||||
else if(type == 'date' && !(val instanceof Date)) val = new Date(val);
|
||||
else if(type == 'int' || type == 'float') val = Number(val);
|
||||
else if(type == 'bool') val = Boolean(val);
|
||||
|
||||
return val;
|
||||
};
|
||||
|
||||
var _tryEscapeRichText = function(text, eventInfo) {
|
||||
return eventInfo.htmlLiteral ? _escapeRichText(text) : text;
|
||||
};
|
||||
|
||||
var _escapeRichText = function(text) {
|
||||
if(typeof (text) != 'string') return text;
|
||||
|
||||
return text.replace('<', '<');
|
||||
};
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,186 @@
|
||||
// This is actually for BOTH trees and menus
|
||||
$axure.internal(function($ax) {
|
||||
var _tree = $ax.tree = {};
|
||||
var _menu = $ax.menu = {};
|
||||
|
||||
$ax.menu.InitializeSubmenu = function(subMenuId, cellId) {
|
||||
var $submenudiv = $('#' + subMenuId);
|
||||
|
||||
//mouseenter and leave for parent table cell
|
||||
$('#' + cellId).mouseenter(function(e) {
|
||||
//show current submenu
|
||||
// var submenuElement = document.getElementById(subMenuId);
|
||||
// if($ax.visibility.IsVisible(submenuElement) && submenuElement.style.display !== 'none') return;
|
||||
$ax.visibility.SetIdVisible(subMenuId, true);
|
||||
$ax.legacy.BringToFront(subMenuId);
|
||||
_fireEventForSubmenu(subMenuId, "onShow");
|
||||
|
||||
}).mouseleave(function (e) {
|
||||
var offset = $submenudiv.offset();
|
||||
var subcontwidth = $submenudiv.width();
|
||||
var subcontheight = $submenudiv.height();
|
||||
//If mouse is not within the submenu (added 3 pixel margin to top and left calculations), then close the submenu...
|
||||
if(e.pageX + 3 < offset.left || e.pageX > offset.left + subcontwidth || e.pageY + 3 < offset.top || e.pageY > offset.top + subcontheight) {
|
||||
$submenudiv.find('.sub_menu').andSelf().each(function () {
|
||||
// if(!$ax.visibility.IsVisible(this)) return;
|
||||
$ax.visibility.SetVisible(this, false);
|
||||
_fireEventForSubmenu(subMenuId, "onHide");
|
||||
});
|
||||
$ax.style.SetWidgetHover(cellId, false);
|
||||
}
|
||||
});
|
||||
|
||||
$submenudiv.css('display', 'none');
|
||||
|
||||
//mouseleave for submenu
|
||||
$submenudiv.mouseleave(function(e) {
|
||||
//close this menu and all menus below it
|
||||
$(this).find('.sub_menu').andSelf().css({ 'visibility': 'hidden', 'display': 'none' }).each(function () {
|
||||
// if(!$ax.visibility.IsVisible(this)) return;
|
||||
_fireEventForSubmenu(this.id, "onHide");
|
||||
});
|
||||
$ax.style.SetWidgetHover(cellId, false);
|
||||
});
|
||||
};
|
||||
|
||||
var _fireEventForSubmenu = function(targetId, eventName) {
|
||||
var diagramObject = $ax.getObjectFromElementId(targetId);
|
||||
var event = diagramObject.interactionMap && diagramObject.interactionMap[eventName];
|
||||
if(event) {
|
||||
var eventInfo = $ax.getEventInfoFromEvent($ax.getjBrowserEvent(), false, targetId);
|
||||
$ax.event.handleEvent(targetId, eventInfo, event, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
function IsNodeVisible(nodeId) {
|
||||
var current = window.document.getElementById(nodeId);
|
||||
var parent = current.parentNode;
|
||||
|
||||
//move all the parent's children that are below the node and their annotations
|
||||
while(!$(current).hasClass("treeroot")) {
|
||||
if(!$ax.visibility.IsVisible(parent)) return false;
|
||||
current = parent;
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$ax.tree.ExpandNode = function(nodeId, childContainerId, plusMinusId) {
|
||||
var container = window.document.getElementById(childContainerId);
|
||||
if(!container || $ax.visibility.IsVisible(container)) return;
|
||||
$ax.visibility.SetVisible(container, true);
|
||||
|
||||
if(plusMinusId != '') $ax.style.SetWidgetSelected(plusMinusId, true);
|
||||
|
||||
var delta = _getExpandCollapseDelta(nodeId, childContainerId);
|
||||
|
||||
var isVisible = IsNodeVisible(nodeId);
|
||||
var current = window.document.getElementById(nodeId);
|
||||
var parent = current.parentNode;
|
||||
|
||||
//move all the parent's children that are below the node and their annotations
|
||||
while(!$(current).hasClass("treeroot")) {
|
||||
var after = false;
|
||||
var i = 0;
|
||||
for(i = 0; i < parent.childNodes.length; i++) {
|
||||
var child = parent.childNodes[i];
|
||||
if(after && child.id && $(child).hasClass("treenode")) {
|
||||
var elementId = child.id;
|
||||
child.style.top = Number($(child).css('top').replace("px", "")) + delta + 'px';
|
||||
var ann = window.document.getElementById(elementId + "_ann");
|
||||
if(ann) ann.style.top = Number($(ann).css('top').replace("px", "")) + delta + 'px';
|
||||
}
|
||||
if(child == current) after = true;
|
||||
}
|
||||
current = parent;
|
||||
parent = parent.parentNode;
|
||||
if(!isVisible && $ax.visibility.IsVisible(parent)) break;
|
||||
}
|
||||
};
|
||||
|
||||
$ax.tree.CollapseNode = function(nodeId, childContainerId, plusMinusId) {
|
||||
var container = window.document.getElementById(childContainerId);
|
||||
if(!container || !$ax.visibility.IsVisible(container)) return;
|
||||
|
||||
if(plusMinusId != '') $ax.style.SetWidgetSelected(plusMinusId, false);
|
||||
|
||||
var delta = _getExpandCollapseDelta(nodeId, childContainerId);
|
||||
|
||||
//hide it after getting the delta, otherwise the delta can't be calculated (offsetParent is null)
|
||||
$ax.visibility.SetVisible(container, false);
|
||||
|
||||
var isVisible = IsNodeVisible(nodeId);
|
||||
var current = window.document.getElementById(nodeId);
|
||||
var parent = current.parentNode;
|
||||
|
||||
//move all the parent's children that are below the node and their annotations
|
||||
while(!$(current).hasClass("treeroot")) {
|
||||
var after = false;
|
||||
var i = 0;
|
||||
for(i = 0; i < parent.childNodes.length; i++) {
|
||||
var child = parent.childNodes[i];
|
||||
if(after && child.id && $(child).hasClass("treenode")) {
|
||||
var elementId = child.id;
|
||||
child.style.top = Number($(child).css('top').replace("px", "")) - delta + 'px';
|
||||
var ann = window.document.getElementById(elementId + "_ann");
|
||||
if(ann) ann.style.top = Number($(ann).css('top').replace("px", "")) - delta + 'px';
|
||||
}
|
||||
if(child == current) after = true;
|
||||
}
|
||||
current = parent;
|
||||
parent = current.parentNode;
|
||||
if(!isVisible && $ax.visibility.IsVisible(parent)) break;
|
||||
}
|
||||
};
|
||||
|
||||
var _getExpandCollapseDelta = function(nodeId, childContainerId) {
|
||||
return _getChildContainerHeightHelper(childContainerId);
|
||||
};
|
||||
|
||||
var _getChildContainerHeightHelper = function(childContainerId) {
|
||||
var height = 0;
|
||||
$('#' + childContainerId).children().each(function() {
|
||||
if($(this).hasClass("treenode")) {
|
||||
height += $(this).height();
|
||||
var subContainer = window.document.getElementById(this.id + '_children');
|
||||
if(subContainer && $ax.visibility.IsVisible(subContainer)) {
|
||||
height += _getChildContainerHeightHelper(subContainer.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
return height;
|
||||
};
|
||||
|
||||
$ax.tree.InitializeTreeNode = function(nodeId, plusminusid, childContainerId, selectText) {
|
||||
var childContainer = window.document.getElementById(childContainerId);
|
||||
if(childContainer) {
|
||||
//relying on the html generator to put this inline so we know to collapse by default
|
||||
var isCollapsed = childContainer.style.visibility == "hidden";
|
||||
if(isCollapsed) $ax.visibility.SetVisible(childContainer, false);
|
||||
|
||||
if(!isCollapsed && plusminusid != '') $ax.style.SetWidgetSelected(plusminusid, true);
|
||||
}
|
||||
|
||||
if(plusminusid != '') {
|
||||
$jobj(plusminusid).click(function() {
|
||||
var visibleSet = $ax.visibility.IsIdVisible(childContainerId);
|
||||
|
||||
if(visibleSet) $ax.tree.CollapseNode(nodeId, childContainerId, plusminusid);
|
||||
else $ax.tree.ExpandNode(nodeId, childContainerId, plusminusid);
|
||||
$ax.tree.SelectTreeNode(nodeId, true);
|
||||
|
||||
return false;
|
||||
}).css('cursor', 'default');
|
||||
}
|
||||
};
|
||||
|
||||
var _getButtonShapeId = function(id) {
|
||||
var obj = $obj(id);
|
||||
return $ax.public.fn.IsTreeNodeObject(obj.type) ? $ax.getElementIdFromPath([obj.buttonShapeId], { relativeTo: id }) : id;
|
||||
};
|
||||
|
||||
$ax.tree.SelectTreeNode = function(id, selected) {
|
||||
$ax.style.SetWidgetSelected(_getButtonShapeId(id), selected);
|
||||
};
|
||||
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
// ******* Deep Copy ******** //
|
||||
$axure.internal(function($ax) {
|
||||
// TODO: [ben] Ah, infinite loops cause major issues here. Tried saving objects we've already hit, but that didn't seem to work (at least at my first shot).
|
||||
var _deepCopy = function(original, trackCopies) {
|
||||
if(trackCopies) {
|
||||
var index = _getCopyIndex(original);
|
||||
if(index != -1) return _originalToCopy[index][1];
|
||||
}
|
||||
var isArray = original instanceof Array;
|
||||
var isObject = !(original instanceof Function) && !(original instanceof Date) && (original instanceof Object);
|
||||
if(!isArray && !isObject) return original;
|
||||
var copy = isArray ? [] : { };
|
||||
if(trackCopies) _originalToCopy.push([original, copy]);
|
||||
isArray ? deepCopyArray(original, trackCopies, copy) : deepCopyObject(original, trackCopies, copy);
|
||||
return copy;
|
||||
};
|
||||
$ax.deepCopy = _deepCopy;
|
||||
|
||||
// Hacky way to copy event info. Copying dragInfo causes major issues due to infinite loops
|
||||
// Hashmap doesn't map objects well. It just toStrings them, making them all the same key. This has to be slow...
|
||||
var _originalToCopy = [];
|
||||
var _getCopyIndex = function(original) {
|
||||
for(var i = 0; i < _originalToCopy.length; i++) if(original === _originalToCopy[i][0]) return i;
|
||||
return -1;
|
||||
};
|
||||
|
||||
$ax.eventCopy = function(eventInfo) {
|
||||
var dragInfo = eventInfo.dragInfo;
|
||||
delete eventInfo.dragInfo;
|
||||
var copy = _deepCopy(eventInfo, true);
|
||||
copy.dragInfo = dragInfo;
|
||||
eventInfo.dragInfo = dragInfo;
|
||||
// reset the map.
|
||||
_originalToCopy = [];
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
var deepCopyArray = function(original, trackCopies, copy) {
|
||||
for(var i = 0; i < original.length; i++) {
|
||||
copy[i] = _deepCopy(original[i], trackCopies);
|
||||
}
|
||||
};
|
||||
|
||||
var deepCopyObject = function(original, trackCopies, copy) {
|
||||
for(var key in original) {
|
||||
if(!original.hasOwnProperty(key)) continue;
|
||||
copy[key] = _deepCopy(original[key], trackCopies);
|
||||
}
|
||||
};
|
||||
|
||||
// Our implementation of splice because it is broken in IE8...
|
||||
$ax.splice = function(array, startIndex, count) {
|
||||
var retval = [];
|
||||
if(startIndex >= array.length || startIndex < 0 || count == 0) return retval;
|
||||
if(!count || startIndex + count > array.length) count = array.length - startIndex;
|
||||
for(var i = 0; i < count; i++) retval[i] = array[startIndex + i];
|
||||
for(i = startIndex + count; i < array.length; i++) array[i - count] = array[i];
|
||||
for(i = 0; i < count; i++) array.pop();
|
||||
return retval;
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
// ******* Flow Shape Links ******** //
|
||||
$axure.internal(function($ax) {
|
||||
|
||||
if(!$ax.document.configuration.linkFlowsToPages && !$ax.document.configuration.linkFlowsToPagesNewWindow) return;
|
||||
|
||||
$(window.document).ready(function() {
|
||||
$ax(function (dObj) { return ($ax.public.fn.IsVector(dObj.type) || $ax.public.fn.IsSnapshot(dObj.type)) && dObj.referencePageUrl; }).each(function (dObj, elementId) {
|
||||
|
||||
var elementIdQuery = $('#' + elementId);
|
||||
|
||||
if($ax.document.configuration.linkFlowsToPages && !$ax.event.HasClick(dObj)) {
|
||||
elementIdQuery.css("cursor", "pointer");
|
||||
elementIdQuery.click(function() {
|
||||
$ax.navigate({
|
||||
url: dObj.referencePageUrl,
|
||||
target: "current",
|
||||
includeVariables: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if($ax.document.configuration.linkFlowsToPagesNewWindow) {
|
||||
$('#' + elementId + "_ref").append("<div id='" + elementId + "PagePopup' class='refpageimage'></div>");
|
||||
$('#' + elementId + "PagePopup").click(function() {
|
||||
$ax.navigate({
|
||||
url: dObj.referencePageUrl,
|
||||
target: "new",
|
||||
includeVariables: true
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,151 @@
|
||||
// ******* GLOBAL VARIABLE PROVIDER ******** //
|
||||
$axure.internal(function($ax) {
|
||||
var _globalVariableValues = {};
|
||||
|
||||
var _globalVariableProvider = {};
|
||||
$ax.globalVariableProvider = _globalVariableProvider;
|
||||
|
||||
var setVariableValue = function(variable, value, suppressBroadcast) {
|
||||
if(!(value instanceof Object)) value = value.toString();
|
||||
|
||||
variable = variable.toLowerCase();
|
||||
_globalVariableValues[variable] = value;
|
||||
|
||||
if(suppressBroadcast !== true) {
|
||||
var varData = {
|
||||
globalVarName: variable,
|
||||
globalVarValue: value.toString()
|
||||
};
|
||||
|
||||
$axure.messageCenter.postMessage('setGlobalVar', varData);
|
||||
}
|
||||
|
||||
//Post global var values only if pageData is loaded (suppresses exception which occurs when page loads)
|
||||
if($ax.pageData) {
|
||||
_postGlobalVarVals();
|
||||
}
|
||||
};
|
||||
_globalVariableProvider.setVariableValue = setVariableValue;
|
||||
|
||||
var getVariableValue = function(variable, eventInfo, ignoreDefaultsForLinkUrl) {
|
||||
variable = variable.toLowerCase();
|
||||
if(_globalVariableValues[variable] !== undefined) {
|
||||
//If this is for the GetLinkUrl function and
|
||||
//the current value of the global variable is the same as the default defined in the document, don't return it
|
||||
if(ignoreDefaultsForLinkUrl == true && $ax.document.globalVariables[variable] == _globalVariableValues[variable]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _globalVariableValues[variable];
|
||||
}
|
||||
if($ax.document.globalVariables[variable] !== undefined) return ignoreDefaultsForLinkUrl == true ? null : $ax.document.globalVariables[variable];
|
||||
switch(variable) {
|
||||
case "pagename": return $ax.pageData.page.name;
|
||||
|
||||
case "now": return eventInfo.now;
|
||||
case "gendate": return $ax.pageData.generationDate;
|
||||
|
||||
case "dragx": return $ax.drag.GetDragX();
|
||||
case "dragy": return $ax.drag.GetDragY();
|
||||
case "totaldragx": return $ax.drag.GetTotalDragX();
|
||||
case "totaldragy": return $ax.drag.GetTotalDragY();
|
||||
case "dragtime": return $ax.drag.GetDragTime();
|
||||
|
||||
case "math": return Math;
|
||||
case "date": return Date;
|
||||
|
||||
case "window": return eventInfo && eventInfo.window;
|
||||
case "this": return eventInfo && eventInfo.srcElement && $ax.getWidgetInfo(eventInfo.srcElement);
|
||||
case "item": return (eventInfo && eventInfo.item && eventInfo.item.valid && eventInfo.item) || getVariableValue('targetitem', eventInfo, ignoreDefaultsForLinkUrl);
|
||||
case "targetitem": return eventInfo && eventInfo.targetElement && $ax.getItemInfo(eventInfo.targetElement);
|
||||
case "repeater": return eventInfo && eventInfo.repeater;
|
||||
case "target": return eventInfo && eventInfo.targetElement && $ax.getWidgetInfo(eventInfo.targetElement);
|
||||
case "cursor": return eventInfo && eventInfo.cursor;
|
||||
default:
|
||||
var gen = variable.substr(0, 3) == "gen";
|
||||
var date = gen ? $ax.pageData.generationDate : new Date();
|
||||
var prop = gen ? variable.substr(3) : variable;
|
||||
switch(prop) {
|
||||
case "day": return date.getDate();
|
||||
case "month": return date.getMonth() + 1;
|
||||
case "monthname": return $ax.getMonthName(date.getMonth());
|
||||
case "dayofweek": return $ax.getDayOfWeek(date.getDay());
|
||||
case "year": return date.getFullYear();
|
||||
case "time": return date.toLocaleTimeString();
|
||||
case "hours": return date.getHours();
|
||||
case "minutes": return date.getMinutes();
|
||||
case "seconds": return date.getSeconds();
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
_globalVariableProvider.getVariableValue = getVariableValue;
|
||||
|
||||
var load = function() {
|
||||
var csum = false;
|
||||
|
||||
var query = (window.location.href.split("#")[1] || ''); //hash.substring(1); Firefox decodes this so & in variables breaks
|
||||
if(query.length > 0) {
|
||||
var vars = query.split("&");
|
||||
for(var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split("=");
|
||||
var varName = pair[0];
|
||||
var varValue = pair[1];
|
||||
if(varName) {
|
||||
if(varName == 'CSUM') {
|
||||
csum = true;
|
||||
} else setVariableValue(varName, decodeURIComponent(varValue), true);
|
||||
}
|
||||
}
|
||||
|
||||
if(!csum && query.length > 250) {
|
||||
window.alert('Axure Warning: The variable values were too long to pass to this page.\n\nIf you are using IE, using Chrome or Firefox will support more data.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var getLinkUrl = function(baseUrl) {
|
||||
var toAdd = '';
|
||||
var definedVariables = _getDefinedVariables();
|
||||
for(var i = 0; i < definedVariables.length; i++) {
|
||||
var key = definedVariables[i];
|
||||
var val = getVariableValue(key, undefined, true);
|
||||
if(val != null) {
|
||||
if(toAdd.length > 0) toAdd += '&';
|
||||
toAdd += key + '=' + encodeURIComponent(val);
|
||||
}
|
||||
}
|
||||
return toAdd.length > 0 ? baseUrl + ($axure.shouldSendVarsToServer() ? '?' : '#') + toAdd + "&CSUM=1" : baseUrl;
|
||||
};
|
||||
_globalVariableProvider.getLinkUrl = getLinkUrl;
|
||||
|
||||
var _getDefinedVariables = function() {
|
||||
return $ax.pageData.variables;
|
||||
};
|
||||
_globalVariableProvider.getDefinedVariables = _getDefinedVariables;
|
||||
|
||||
var _postGlobalVarVals = function() {
|
||||
var retVal = {};
|
||||
var definedVariables = _getDefinedVariables();
|
||||
for(var i = 0; i < definedVariables.length; i++) {
|
||||
var key = definedVariables[i];
|
||||
var val = getVariableValue(key);
|
||||
if(val != null) {
|
||||
retVal[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
$ax.messageCenter.postMessage('globalVariableValues', retVal);
|
||||
};
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
if(message == 'getGlobalVariables') {
|
||||
_postGlobalVarVals();
|
||||
} else if(message == 'resetGlobalVariables') {
|
||||
_globalVariableValues = {};
|
||||
_postGlobalVarVals();
|
||||
}
|
||||
});
|
||||
|
||||
load();
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
// ******* SITEMAP TOOLBAR VIEWER ACTIONS ******** //
|
||||
$axure.internal(function ($ax) {
|
||||
var userTriggeredEventNames = ['onClick', 'onDoubleClick', 'onMouseOver', 'onMouseMove', 'onMouseOut', 'onMouseDown', 'onMouseUp',
|
||||
'onKeyDown', 'onKeyUp', 'onFocus', 'onLostFocus', 'onTextChange', 'onSelectionChange', 'onSelectedChange', 'onSelect', 'onUnselect',
|
||||
'onSwipeLeft', 'onSwipeRight', 'onSwipeUp', 'onSwipeDown', 'onDragStart', 'onDrag', 'onDragDrop', 'onScroll', 'onContextMenu', 'onMouseHover', 'onLongClick'];
|
||||
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
//If annotation toggle message received from sitemap, toggle footnotes
|
||||
if(message == 'annotationToggle') {
|
||||
if(data == true) {
|
||||
$('div.annotation').show();
|
||||
$('div.annnotelabel').show();
|
||||
$('div.annnoteimage').show();
|
||||
} else {
|
||||
$('div.annotation').hide();
|
||||
$('div.annnotelabel').hide();
|
||||
$('div.annnoteimage').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var lastSelectedWidgetNote;
|
||||
$ax.messageCenter.addMessageListener(function (message, data) {
|
||||
//If annotation toggle message received from sitemap, toggle footnotes
|
||||
if(message == 'toggleSelectWidgetNote') {
|
||||
if(lastSelectedWidgetNote == data) {
|
||||
$('#' + lastSelectedWidgetNote).removeClass('widgetNoteSelected');
|
||||
lastSelectedWidgetNote = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lastSelectedWidgetNote) $('#' + lastSelectedWidgetNote).removeClass('widgetNoteSelected');
|
||||
$('#' + data).addClass('widgetNoteSelected');
|
||||
lastSelectedWidgetNote = data;
|
||||
}
|
||||
});
|
||||
|
||||
var highlightEnabled = false;
|
||||
$ax.messageCenter.addMessageListener(function(message, data) {
|
||||
if(message == 'highlightInteractive') {
|
||||
highlightEnabled = data == true;
|
||||
_applyHighlight($ax('*'));
|
||||
}
|
||||
});
|
||||
|
||||
var _applyHighlight = $ax.applyHighlight = function(query, ignoreUnset) {
|
||||
if(ignoreUnset && !highlightEnabled) return;
|
||||
|
||||
//Do condition to check if legacy browser (all IE, except 10) and select appropriate pulsate css class name
|
||||
var userAgentString = navigator.userAgent.toLowerCase();
|
||||
|
||||
var isIEpre10 = userAgentString.indexOf('msie 9.') != -1 ||
|
||||
userAgentString.indexOf('msie 8.') != -1 ||
|
||||
userAgentString.indexOf('msie 7.') != -1 ||
|
||||
userAgentString.indexOf('msie 6.') != -1;
|
||||
|
||||
var pulsateClassName = 'legacyPulsateBorder';
|
||||
|
||||
//Find all widgets with a defined userTriggeredEventName specified in the array above
|
||||
var $matchingElements = query.filter(function(obj) {
|
||||
if(obj.interactionMap) {
|
||||
for(var index in userTriggeredEventNames) {
|
||||
if(obj.interactionMap[userTriggeredEventNames[index]]) return true;
|
||||
}
|
||||
} else if ($ax.public.fn.IsVector(obj.type) && obj.referencePageUrl) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}).$();
|
||||
|
||||
var isHighlighted = $matchingElements.is('.' + pulsateClassName);
|
||||
|
||||
//Toggle the pulsate class on the matched elements
|
||||
if(highlightEnabled && !isHighlighted) {
|
||||
$matchingElements.addClass(pulsateClassName);
|
||||
} else if(!highlightEnabled && isHighlighted) {
|
||||
$matchingElements.removeClass(pulsateClassName);
|
||||
}
|
||||
};
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user