2e31485e003a4f70e08cc6ab70aa655261b75aa2 tdreszer Mon Jan 30 16:02:10 2012 -0800 Use code that shlerps js and css files, and embedded js out of ajax returned html for popup cfg. The same code has been altered to fix getting warnBox contents out of the ajax results and putting them into the current page's warnBox. diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 68d89ce..407c1db 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -2377,69 +2377,44 @@ window.location = "../cgi-bin/hgTracks?" + urlData + "&hgsid=" + getHgsid(); } } } } }, uiDialog: function (response, status) { // Take html from hgTrackUi and put it up as a modal dialog. // make sure all links (e.g. help links) open up in a new window response = response.replace(/<a /ig, "<a target='_blank' "); - // TODO: Shlurp up any javascript files from the response and load them with $.getScript() - // example <script type='text/javascript' SRC='../js/tdreszer/jquery.contextmenu-1296177766.js'></script> var cleanHtml = response; - var shlurpPattern=/\<script type=\'text\/javascript\' SRC\=\'.*\'\>\<\/script\>/gi; - var jsFiles = cleanHtml.match(shlurpPattern); - cleanHtml = cleanHtml.replace(shlurpPattern,""); - shlurpPattern=/\<script type=\'text\/javascript\'>.*\<\/script\>/gi; - var jsEmbeded = cleanHtml.match(shlurpPattern); - cleanHtml = cleanHtml.replace(shlurpPattern,""); - //<LINK rel='STYLESHEET' href='../style/ui.dropdownchecklist-1276528376.css' TYPE='text/css' /> - shlurpPattern=/\<LINK rel=\'STYLESHEET\' href\=\'.*\' TYPE=\'text\/css\' \/\>/gi; - var cssFiles = cleanHtml.match(shlurpPattern); - cleanHtml = cleanHtml.replace(shlurpPattern,""); - + cleanHtml = stripJsFiles(cleanHtml,true); // DEBUG msg with true + cleanHtml = stripCssFiles(cleanHtml,true); // DEBUG msg with true + cleanHtml = stripJsEmbedded(cleanHtml,true);// DEBUG msg with true $('#hgTrackUiDialog').html("<div id='pop' style='font-size:.9em;'>"+ cleanHtml +"</div>"); // Strategy for poups with js: // - jsFiles and CSS should not be included in html. Here they are shluped out. // - The resulting files ought to be loadable dynamically (with getScript()), but this was not working nicely with the modal dialog // Therefore include files must be included with hgTracks CGI ! // - embedded js should not be in the popup box. // - Somethings should be in a popup.ready() function, and this is emulated below, as soon as the cleanHtml is added // Since there are many possible popup cfg dialogs, the ready should be all inclusive. - /* //in open ? Will load of css work this way? - $(cssFiles).each(function (i) { - bix = "<LINK rel='STYLESHEET' href='".length; - eix = this.lastIndexOf("' TYPE='text/css' />"); - file = this.substring(bix,eix); - $.getScript(file); // Should protect against already loaded files. - }); */ - /* //in open ? Loads fine, but then dialog gets confused - $(jsFiles).each(function (i) { - bix = "<script type='text/javascript' SRC='".length; - eix = this.lastIndexOf("'></script>"); - file = this.substring(bix,eix); - //$.getScript(file,function(data) { warn(data.substring(0,20) + " loaded")}); - });*/ - if ( ! popUp.trackDescriptionOnly ) { var subtrack = tdbIsSubtrack(hgTracks.trackDb[popUp.trackName]) ? popUp.trackName :""; // If subtrack then vis rules differ popUp.saveAllVars = getAllVars( $('#hgTrackUiDialog'), subtrack ); // Saves the vars that may get changed by the popup cfg. // -- popup.ready() -- Here is the place to do things that might otherwise go into a $('#pop').ready() routine! } // Searching for some selblance of size suitability var popMaxHeight = ($(window).height() - 40); var popMaxWidth = ($(window).width() - 40); var popWidth = 740; if (popWidth > popMaxWidth) popWidth > popMaxWidth; $('#hgTrackUiDialog').dialog({