// use this to isolate the scope (function () { if(!$axure.document.configuration.showPageNotes && !$axure.document.configuration.showAnnotationsSidebar) { return; } $(window.document).ready(function () { $axure.player.createPluginHost({ id: 'pageNotesHost', context: 'interface', title: 'NOTES', gid: 2 }); generatePageNotes(); $(document).on('ContainerHeightChange', function () { updateContainerHeight(); }); $('#footnotesButton').click(footnotes_click).addClass('sitemapToolbarButtonSelected'); $('#notesNextButton').click(notesNext_click); $('#notesPreviousButton').click(notesPrevious_click); // bind to the page load $axure.page.bind('load.page_notes', function () { var hasNotes = false; $('#pageNotesContent').html(""); if($axure.document.configuration.showPageNotes) { //populate the notes var notes = $axure.page.notes; if(notes) { var showNames = $axure.document.configuration.showPageNoteNames; for(var noteName in notes) { var pageNoteUi = "
"; if(showNames) { pageNoteUi += "
" + noteName + "
"; } pageNoteUi += "
" + linkify(notes[noteName]) + "
"; pageNoteUi += "
"; pageNoteUi += "
"; $('#pageNotesContent').append(pageNoteUi); hasNotes = true; } } } if($axure.document.configuration.showAnnotationsSidebar) { var widgetNotes = $axure.page.widgetNotes; if(widgetNotes) { for(var i = 0; i < widgetNotes.length; i++) { var widgetNote = widgetNotes[i]; var widgetNoteUi = "
"; widgetNoteUi += "
"; widgetNoteUi += "
" + widgetNote["label"] + "
"; for(var widgetNoteName in widgetNote) { if(widgetNoteName != "label" && widgetNoteName != "id") { widgetNoteUi += "
" + widgetNoteName + "
"; widgetNoteUi += "
" + linkify(widgetNote[widgetNoteName]) + "
"; widgetNoteUi += "
"; } } widgetNoteUi += "
"; widgetNoteUi += "
"; $('#pageNotesContent').append(widgetNoteUi); hasNotes = true; } $('.widgetNoteContainer').children(':last-child').remove(); $('.widgetNoteFootnote').append("
"); $('.widgetNoteContainer').click(function () { var wasSelected = $(this).hasClass('widgetNoteContainerSelected'); $('.widgetNoteContainerSelected').removeClass('widgetNoteContainerSelected'); if(!wasSelected) $(this).addClass('widgetNoteContainerSelected'); $axure.messageCenter.postMessage('toggleSelectWidgetNote', this.getAttribute('data-id')); }); } } if(hasNotes) $('#pageNotesEmptyState').hide(); else $('#pageNotesEmptyState').show(); //If footnotes enabled for this prototype... if($axure.document.configuration.showAnnotations == true) { //If the fn var is defined and set to 0, hide footnotes //else if hide-footnotes button selected, hide them var fnVal = getHashStringVar(FOOTNOTES_VAR_NAME); if(fnVal.length > 0 && fnVal == 0) { $('#footnotesButton').removeClass('sitemapToolbarButtonSelected'); $axure.messageCenter.postMessage('annotationToggle', false); } else if(!$('#footnotesButton').is('.sitemapToolbarButtonSelected')) { //If the footnotes button isn't selected, hide them on this loaded page $axure.messageCenter.postMessage('annotationToggle', false); } } return false; }); 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 '' + url + ''; }); } }); function updateContainerHeight() { $('#pageNotesScrollContainer').height($('#pageNotesHost').height() - $('#pageNotesHeader').outerHeight()); } $(document).on('sidebarCollapse', function (event, data) { clearSelection(); }); $(document).on('pluginShown', function (event, data) { if(data != 2) { clearSelection(); } }); function clearSelection() { $('.widgetNoteContainerSelected').removeClass('widgetNoteContainerSelected'); $axure.messageCenter.postMessage('toggleSelectWidgetNote', ''); } function footnotes_click(event) { if($('#footnotesButton').is('.sitemapToolbarButtonSelected')) { $('#footnotesButton').removeClass('sitemapToolbarButtonSelected'); $axure.messageCenter.postMessage('annotationToggle', false); //Add 'fn' hash string var so that footnotes stay hidden across reloads setVarInCurrentUrlHash(FOOTNOTES_VAR_NAME, 0); } else { $('#footnotesButton').addClass('sitemapToolbarButtonSelected'); $axure.messageCenter.postMessage('annotationToggle', true); //Delete 'fn' hash string var if it exists since default is visible deleteVarFromCurrentUrlHash(FOOTNOTES_VAR_NAME); } } function notesNext_click(event) { openNextPage(); } function notesPrevious_click(event) { openPreviousPage(); } function generatePageNotes() { var pageNotesUi = "
"; pageNotesUi += "
"; pageNotesUi += "
NOTES
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += ""; pageNotesUi += ""; if($axure.document.configuration.showAnnotations == true) { pageNotesUi += ""; } pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
No notes for this page.
Notes added in Axure RP will appear here.
"; pageNotesUi += ""; pageNotesUi += "
"; $('#pageNotesHost').html(pageNotesUi); updateContainerHeight(); if(!$axure.document.configuration.showAnnotations) { $('#pageNotesHost .pageNameHeader').css('padding-right', '55px'); } } })();