PageSourceSearch

https://www.wepe.cn/resources2/scripts/axure/annotation.js

js wepe.cn collected 2026-10-04 01:42:31 UTC 7,179 bytes, 176 lines download raw bytes

1// ******* Annotation MANAGER ******** //
2$axure.internal(function($ax) {
3    var NOTE_SIZE = 10;
4
5    var _annotationManager = $ax.annotation = {};
6
7    var _updateLinkLocations = $ax.annotation.updateLinkLocations = function(textId) {
8        var diagramObject = $ax.getObjectFromElementId(textId);
9        var rotation = (diagramObject && diagramObject.style.rotation);
10        var shapeId = $ax.style.GetShapeIdFromText(textId);
11
12        //we have to do this because webkit reports the post-transform position but when you set
13        //positions it's pre-transform
14        if(WEBKIT && rotation) {
15            //we can dynamiclly rotate a widget now, show need to remember the transform rather than just remove it
16            //here jquery.css will return 'none' if element is display none
17            var oldShapeTransform = document.getElementById(shapeId).style['-webkit-transform'];
18            var oldTextTransform = document.getElementById(textId).style['-webkit-transform'];
19            $('#' + shapeId).css('-webkit-transform', 'scale(1)');
20            $('#' + textId).css('-webkit-transform', 'scale(1)');
21        }
22
23        $('#' + textId).find('span[id$="_ann"]').each(function(index, value) {
24            var elementId = value.id.replace('_ann', '');
25
26            var annPos = $(value).position();
27            var left = annPos.left - NOTE_SIZE;
28            var top = annPos.top;
29
30            $('#' + elementId + 'Note').css('left', left).css('top', top);
31        });
32
33        //undo the transform reset
34        if(WEBKIT && rotation) {
35            $('#' + shapeId).css('-webkit-transform', oldShapeTransform || '');
36            $('#' + textId).css('-webkit-transform', oldTextTransform || '');
37        }
38    };
39
40    var dialogs = {};
41    $ax.annotation.ToggleWorkflow = function(event, id, width, height) {
42
43        if(dialogs[id]) {
44            var $dialog = dialogs[id];
45            // reset the dialog
46            dialogs[id] = undefined;
47            if($dialog.dialog("isOpen")) {
48                $dialog.dialog("close");
49                return;
50            }
51        }
52
53        // we'll need to save the scroll position just for stupid IE which will skip otherwise
54        var win = $(window);
55        var scrollY = win.scrollTop();
56        var scrollX = win.scrollLeft();
57
58        var bufferH = 10;
59        var bufferV = 10;
60        var blnLeft = false;
61        var blnAbove = false;
62        var sourceTop = event.pageY - scrollY;
63        var sourceLeft = event.pageX - scrollX;
64
65        if(sourceLeft > width + bufferH) {
66            blnLeft = true;
67        }
68        if(sourceTop > height + bufferV) {
69            blnAbove = true;
70        }
71
72        var top = 0;
73        var left = 0;
74        if(blnAbove) top = sourceTop - height - 20;
75        else top = sourceTop + 10;
76        if(blnLeft) left = sourceLeft - width - 4;
77        else left = sourceLeft - 6;
78
79        $ax.globals.MaxZIndex = $ax.globals.MaxZIndex + 1;
80        if(IE_10_AND_BELOW) height += 50;
81
82        var dObj = $ax.getObjectFromElementId(id);
83        var ann = dObj.annotation;
84        var $dialog = $('<div></div>')
85            .appendTo('body')
86            .html($ax.legacy.GetAnnotationHtml(ann))
87            .dialog({
88                title: dObj.label,
89                width: width,
90                height: height,
91                minHeight: 150,
92                zIndex: $ax.globals.MaxZIndex,
93                position: [left, top],
94                dialogClass: 'dialogFix',
95                autoOpen: false
96            });
97        $dialog.parent().appendTo('#base');
98        $dialog.dialog('open');
99        dialogs[id] = $dialog;
100
101        // scroll ... just for IE
102        window.scrollTo(scrollX, scrollY);
103    };
104
105    $ax.annotation.InitializeAnnotations = function (query) {
106        if(!$ax.document.configuration.showAnnotations) return;
107
108        query.each(function(dObj, elementId) {
109            if(!dObj.annotation) return;
110
111            if(dObj.type == 'hyperlink') {
112                var textId = $ax.style.GetTextIdFromLink(elementId);
113
114                var elementIdQuery = $('#' + elementId);
115                elementIdQuery.after("<span id='" + elementId + "_ann'>&#8203;</span>");
116
117                if($ax.document.configuration.useLabels) {
118                    var label = $('#' + elementId).attr("data-label");
119                    if(!label || label == "") label = "?";
120                    $('#' + textId).append("<div id='" + elementId + "Note' class='annnotelabel' >" + label + "</div>");
121                } else {
122                    $('#' + textId).append("<div id='" + elementId + "Note' class='annnoteimage' ></div>");
123                }
124                $('#' + elementId + 'Note').click(function(e) {
125                    $ax.annotation.ToggleWorkflow(e, elementId, 300, 200, false);
126                    return false;
127                });
128
129                _updateLinkLocations(textId);
130            } else {
131                if($ax.document.configuration.useLabels) {
132                    var label = $('#' + elementId).attr("data-label");
133                    if(!label || label == "") label = "?";
134                    $('#' + elementId + "_ann").append("<div id='" + elementId + "Note' class='annnotelabel'>" + label + "</div>");
135                } else {
136                    $('#' + elementId + "_ann").append("<div id='" + elementId + "Note' class='annnoteimage'></div>");
137                }
138                $('#' + elementId + 'Note').click(function(e) {
139                    $ax.annotation.ToggleWorkflow(e, elementId, 300, 200, false);
140                    return false;
141                });
142            }
143
144            $('#' + elementId + 'Note.annnoteimage').append("<div class='annnoteline'></div><div class='annnoteline'></div><div class='annnoteline'></div>");
145        });
146    };
147
148    $ax.annotation.jQueryAnn = function(query) {
149        var elementIds = [];
150        query.each(function(diagramObject, elementId) {
151            if(diagramObject.annotation) elementIds[elementIds.length] = elementId;
152        });
153        var elementIdSelectors = jQuery.map(elementIds, function(elementId) { return '#' + elementId + '_ann'; });
154        var jQuerySelectorText = (elementIdSelectors.length > 0) ? elementIdSelectors.join(', ') : '';
155        return $(jQuerySelectorText);
156    };
157
158    $(window.document).ready(function() {
159        $ax.annotation.InitializeAnnotations($ax(function(dObj) { return dObj.annotation; }));
160
161        $ax.messageCenter.addMessageListener(function(message, data) {
162            //If the annotations are being hidden via the Sitemap toggle button, hide any open dialogs
163            if(message == 'annotationToggle') {
164                if(data == false) {
165                    for(var index in dialogs) {
166                        var $dialog = dialogs[index];
167                        if($dialog.dialog("isOpen")) {
168                            $dialog.dialog("close");
169                        }
170                    }
171                }
172            }
173        });
174    });
175
176});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.