1if (!window.$axure) window.$axure = function () { }; 2if (typeof console == 'undefined') console = { 3 log: function () { } 4}; 5if(window._axUtils) $axure.utils = _axUtils; 6 7$axure.loadDocument = function(document) { 8 $axure.document = document; 9}; 10 11function setUpController() { 12 13 //$axure.utils = _axUtils; 14 15 var _page = {}; 16 $axure.page = _page; 17 18 $axure.utils.makeBindable(_page, ['load']); 19 20 var _player = function() { 21 }; 22 $axure.player = _player; 23 24 //----------------------------------------- 25 //Global Var array, getLinkUrl function and setGlobalVar listener are 26 //for use in setting global vars in page url string when clicking a 27 //page in the sitemap 28 //----------------------------------------- 29 var _globalVars = {}; 30 31 //----------------------------------------- 32 //Used by getLinkUrl below to check if local server is running 33 //in order to send back the global variables as a query string 34 //in the page url 35 //----------------------------------------- 36 var _shouldSendVarsToServer = function () { 37 //If exception occurs (due to page in content frame being from a different domain, etc) 38 //then run the check without the url (which will end up checking against sitemap url) 39 try { 40 var mainFrame = document.getElementById("mainFrame"); 41 return $axure.shouldSendVarsToServer(mainFrame.contentWindow.location.href); 42 } catch (e) { 43 return $axure.shouldSendVarsToServer(); 44 } 45 }; 46 47 var _getLinkUrl = function (baseUrl) { 48 var toAdd = ''; 49 for(var globalVarName in _globalVars) { 50 var val = _globalVars[globalVarName]; 51 if(val != null) { 52 if(toAdd.length > 0) toAdd += '&'; 53 toAdd += globalVarName + '=' + encodeURIComponent(val); 54 } 55 } 56 return toAdd.length > 0 ? baseUrl + (_shouldSendVarsToServer() ? '?' : '#') + toAdd + "&CSUM=1" : baseUrl; 57 }; 58 $axure.getLinkUrlWithVars = _getLinkUrl; 59 60 $axure.messageCenter.addMessageListener(function(message, data) { 61 if (message == 'setGlobalVar'){ 62 _globalVars[data.globalVarName] = data.globalVarValue; 63 } 64 }); 65 66 $axure.messageCenter.addStateListener('page.data', function (key, value) { 67 for (var subKey in value) { 68 _page[subKey] = value[subKey]; 69 } 70 $axure.page.triggerEvent('load'); 71 }); 72 73 // --------------------------------------------- 74 // Navigates the main frame (setting the currently visible page). If the link is relative, 75 // this method should test if it is actually a axure rp page being loaded and properly set 76 // up all the controller for the page if it is 77 // --------------------------------------------- 78 _page.navigate = function (url, includeVariables) { 79 var mainFrame = document.getElementById("mainFrame"); 80 //var mainFrame = window.parent.mainFrame; 81 // if this is a relative url... 82 var urlToLoad; 83 if (url.indexOf(':') < 0 || url[0] == '/') { 84 var winHref = window.location.href; 85 var page = winHref.substring(0, winHref.lastIndexOf('/') + 1) + url; 86 urlToLoad = page; 87 } else { 88 urlToLoad = url; 89 } 90 if (!includeVariables) { 91 mainFrame.contentWindow.location.href = urlToLoad; 92 return; 93 } 94 var urlWithVars = $axure.getLinkUrlWithVars(urlToLoad); 95 var currentData = $axure.messageCenter.getState('page.data'); 96 var currentUrl = currentData && currentData.location; 97 if(currentUrl && currentUrl.indexOf('#') != -1) currentUrl = currentUrl.substring(0, currentUrl.indexOf('#')) 98 99 // this is so we can make sure the current frame reloads if the variables have changed 100 // by default, if the location is the same but the hash code is different, the browser will not 101 // trigger a reload 102 mainFrame.contentWindow.location.href = 103 currentUrl && urlToLoad.toLowerCase() != currentUrl.toLowerCase() 104 ? urlWithVars 105 : 'resources/reload.html#' + encodeURI(urlWithVars); 106 107 }; 108 109 var pluginIds = []; 110 var plugins = {}; 111 var currentVisibleHostId = null; 112 // --------------------------------------------- 113 // Adds a tool box frame from a url to the interface. This is useful for loading plugins 114 // settings is an object that supports the following properties: 115 // - id : the id of the element for the plugin 116 // - context : the context to create the plugin host for 117 // - title : the user-visible caption for the plugin 118 // --------------------------------------------- 119 _player.createPluginHost = function (settings) { 120 // right now we only understand an interface context 121 if (!(!settings.context || settings.context === 'interface')) { 122 throw ('unknown context type'); 123 } 124 if (!settings.id) throw ('each plugin host needs an id'); 125 126 var host = $('<div id=' + settings.id + '></div>') 127 .appendTo('#interfaceControlFrameHostContainer'); 128 129 host.hide(); 130 131 var headerLink = $('<a pluginId="' + settings.id + '" >' + settings.title.toUpperCase() + '</a>'); 132 133 headerLink 134 .click($axure.utils.curry(interfaceControlHeaderButton_click, settings.id)).wrap('<li id="' + settings.id + 'Btn">'); 135 136 if((settings.id == 'feedbackHost' || settings.id == 'feedbackContainer') && pluginIds[pluginIds.length - 1] == 'debugHost') headerLink.parent().insertBefore('#debugHostBtn'); 137 else headerLink.parent().appendTo('#interfaceControlFrameHeader'); 138 139 pluginIds[pluginIds.length] = settings.id; 140 plugins[settings.id] = settings; 141 142 $(document).trigger('pluginCreated', [settings.gid]); 143 }; 144 145 // private methods 146 var interfaceControlHeaderButton_click = function (id) { 147 var clickedPlugin = $('#interfaceControlFrameHeader a[pluginId=' + id + ']'); 148 if(clickedPlugin.hasClass('selected')) { 149 clickedPlugin.removeClass('selected'); 150 $('#' + id).hide(); 151 _player.collapseToBar(); 152 153 $(document).trigger('pluginShown',['']); 154 } else { 155 $('#interfaceControlFrameHeader a').removeClass('selected'); 156 clickedPlugin.addClass('selected'); 157 158 $('#' + currentVisibleHostId).hide(); 159 $('#' + id).show(); 160 currentVisibleHostId = id; 161 _player.expandFromBar(); 162 163 $(document).trigger('pluginShown', [plugins[id].gid]); 164 } 165
166 $(document).trigger('ContainerHeightChange'); 167 }; 168 169 $axure.player.showPlugin = function(gid) { 170 for(var id in plugins) { 171 if(plugins[id].gid == gid) { 172 $('a[pluginId="' + id + '"]').click(); 173 break; 174 } 175 } 176 }; 177} 178 179function setUpDocumentStateManager() { 180 var mgr = $axure.prototype.documentStateManager = {}; 181 $axure.utils.makeBindable(mgr, ['globalVariableChanged']); 182 183 mgr.globalVariableValues = {}; 184 185 mgr.setGlobalVariable = function(varname, value, source) { 186 var arg = {}; 187 arg.variableName = varname; 188 arg.newValue = value; 189 arg.oldValue = this.getGlobalVariable(varname); 190 arg.source = source; 191 192 mgr.globalVariableValues[varname] = value; 193 this.triggerEvent('globalVariableChanged', arg); 194 }; 195 196 mgr.getGlobalVariable = function(varname) { 197 return mgr.globalVariableValues[varname]; 198 }; 199} 200 201 202function setUpPageStateManager() { 203 var mgr = $axure.prototype.pageStateManager = {}; 204 205 mgr.panelToStateIds = {}; 206}
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.