@@ -138,11 +138,11 @@ function demo() {
138138 case 's' :
139139 return "Sparse (U)" ;
140140 case 'u' :
141- return "Sparse (¬ ;U)"
141+ return "Sparse (¬ ;U)"
142142 case 'q' :
143143 return "Singleton (U)" ;
144144 case 'c' :
145- return "Singleton (¬ ;U)" ;
145+ return "Singleton (¬ ;U)" ;
146146 default :
147147 return "" ;
148148 }
@@ -185,43 +185,45 @@ function demo() {
185185 listTensorsBody += "<li id=\"" ;
186186 listTensorsBody += id ;
187187 listTensorsBody += "\" class=\"ui-state-default\">" ;
188- listTensorsBody += "<div class=\"mdl-textfield mdl-js-textfield " ;
188+ listTensorsBody += "<div class=\"dropdown mdl-textfield mdl-js-textfield " ;
189189 listTensorsBody += "mdl-textfield--floating-label getmdl-select\" " ;
190190 listTensorsBody += "style=\"cursor: move\">" ;
191191 listTensorsBody += "<input class=\"mdl-textfield__input " ;
192- listTensorsBody += "format-input\" id=\"" ;
192+ listTensorsBody += "format-input\" data-toggle=\"dropdown\" id=\"" ;
193193 listTensorsBody += selectId ;
194194 listTensorsBody += "\" type=\"text\" readonly " ;
195195 listTensorsBody += "value=\"" ;
196196 listTensorsBody += tblFormatsView . getFormatString ( format ) ;
197197 listTensorsBody += "\" data-val=\"" ;
198198 listTensorsBody += format ;
199199 listTensorsBody += "\"/>" ;
200- listTensorsBody += "<label for=\"" ;
201- listTensorsBody += selectId
202- listTensorsBody += "\">" ;
200+ listTensorsBody += "<label>" ;
203201 listTensorsBody += "<i class=\"mdl-icon-toggle__label " ;
204202 listTensorsBody += "material-icons\">keyboard_arrow_down</i>" ;
205203 listTensorsBody += "</label>" ;
206- listTensorsBody += "<label class=\"mdl-textfield__label\" for=\"" ;
207- listTensorsBody += selectId ;
208- listTensorsBody += "\">Dimension " ;
204+ listTensorsBody += "<label class=\"mdl-textfield__label\">Dimension " ;
209205 listTensorsBody += ( dim + 1 ) ;
210206 listTensorsBody += "</label>" ;
211- listTensorsBody += "<ul class=\"mdl-menu mdl-menu--bottom-left " ;
212- listTensorsBody += "mdl-js-menu\" for=\"" ;
207+ listTensorsBody += "<ul class=\"dropdown-menu\" for=\""
213208 listTensorsBody += selectId ;
214- listTensorsBody += "\">" ;
215- listTensorsBody += "<li class=\"mdl-menu__item\" data-val=\"" ;
216- listTensorsBody += "d\">Dense</li>" ;
217- listTensorsBody += "<li class=\"mdl-menu__item\" data-val=\"" ;
218- listTensorsBody += "s\">Sparse (U)</li>" ;
219- listTensorsBody += "<li class=\"mdl-menu__item\" data-val=\"" ;
220- listTensorsBody += "u\">Sparse (¬U)</li>" ;
221- listTensorsBody += "<li class=\"mdl-menu__item\" data-val=\"" ;
222- listTensorsBody += "q\">Singleton (U)</li>" ;
223- listTensorsBody += "<li class=\"mdl-menu__item\" data-val=\"" ;
224- listTensorsBody += "c\">Singleton (¬U) </li>" ;
209+ listTensorsBody += "\"><li class =\"dense\"><a data-val=\""
210+ listTensorsBody += "d\">Dense</a></li>" ;
211+ listTensorsBody += "<li class=\"sparse dropdown-submenu\">" ;
212+ listTensorsBody += "<a>Sparse" ;
213+ listTensorsBody += "<i class=\"material-icons\" style=\"float:right\">" ;
214+ listTensorsBody += "keyboard_arrow_right</i></a>" ;
215+ listTensorsBody += "<ul class=\"dropdown-menu\">" ;
216+ listTensorsBody += "<li><a data-val=\"s\">Unique</a></li>" ;
217+ listTensorsBody += "<li><a data-val=\"u\">Not Unique</a></li>" ;
218+ listTensorsBody += "</ul></li>" ;
219+ listTensorsBody += "<li class=\"singleton dropdown-submenu\">" ;
220+ listTensorsBody += "<a>Singleton" ;
221+ listTensorsBody += "<i class=\"material-icons\" style=\"float:right\">" ;
222+ listTensorsBody += "keyboard_arrow_right</i></a>" ;
223+ listTensorsBody += "<ul class=\"dropdown-menu\">" ;
224+ listTensorsBody += "<li><a data-val=\"q\">Unique</a></li>" ;
225+ listTensorsBody += "<li><a data-val=\"c\">Not Unique</a></li>" ;
226+ listTensorsBody += "</ul></li>" ;
225227 listTensorsBody += "</ul></div></li>" ;
226228 }
227229
@@ -236,32 +238,58 @@ function demo() {
236238 $ ( ".sortable" ) . sortable ( {
237239 update : function ( ev , ui ) {
238240 var listId = ui . item . parent ( ) . attr ( 'id' ) ;
239- var tensor = listId . replace ( "dims" , "" ) ;
240-
241- tblFormatsView . insertCacheEntry ( tensor ,
242- tblFormatsView . createCacheEntry ( listId ) ) ;
243-
244- model . cancelReq ( ) ;
245- model . setOutput ( "" , "" , "" , "" ) ;
246241 }
247242 } ) ;
248- $ ( ".format-input" ) . change ( function ( ) {
249- var listId = $ ( this ) . parent ( ) . parent ( ) . parent ( ) . attr ( 'id' ) ;
243+
244+ function updateCache ( selectParent , val ) {
245+ var selectId = selectParent . attr ( 'for' ) ;
246+ var listId = selectParent . parent ( ) . parent ( ) . parent ( ) . attr ( 'id' ) ;
250247 var tensor = listId . replace ( "dims" , "" ) ;
251248
249+ var format = tblFormatsView . getFormatString ( val ) ;
250+ format = format . replace ( "¬" , $ ( "<div>" ) . html ( "¬" ) . text ( ) ) ;
251+
252+ $ ( "#" + selectId ) . val ( format ) ;
253+ $ ( "#" + selectId ) . attr ( 'data-val' , val ) ;
254+
252255 tblFormatsView . insertCacheEntry ( tensor ,
253256 tblFormatsView . createCacheEntry ( listId ) ) ;
254257
255258 model . cancelReq ( ) ;
256259 model . setOutput ( "" , "" , "" , "" ) ;
257- } ) ;
260+ }
261+
258262 for ( t in model . input . tensorOrders ) {
259263 if ( model . input . tensorOrders [ t ] > 0 ) {
260264 tblFormatsView . insertCacheEntry ( t ,
261265 tblFormatsView . createCacheEntry ( "dims" + t ) ) ;
262266 }
263267 }
264268
269+ $ ( '.dropdown-submenu a' ) . on ( "mouseover" , function ( e ) {
270+ $ ( this ) . next ( 'ul' ) . show ( ) ;
271+ } ) ;
272+
273+ $ ( '.sparse' ) . on ( "mouseleave" , function ( e ) {
274+ $ ( this ) . find ( 'ul' ) . hide ( ) ;
275+ } ) ;
276+
277+ $ ( '.singleton' ) . on ( "mouseleave" , function ( e ) {
278+ $ ( this ) . find ( 'ul' ) . hide ( ) ;
279+ } ) ;
280+
281+ $ ( ".dense a" ) . on ( "click" , function ( e ) {
282+ var selectParent = $ ( this ) . parent ( ) . parent ( ) ;
283+ var val = $ ( this ) . attr ( "data-val" ) ;
284+ updateCache ( selectParent , val ) ;
285+ } ) ;
286+
287+ $ ( '.dropdown-submenu .dropdown-menu a' ) . on ( "click" , function ( e ) {
288+ var selectParent = $ ( this ) . parent ( ) . parent ( ) . parent ( ) . parent ( ) ;
289+ var val = $ ( this ) . attr ( "data-val" ) ;
290+ updateCache ( selectParent , val ) ;
291+ } ) ;
292+
265293 $ ( "#tblFormats" ) . show ( ) ;
266294 } else {
267295 $ ( "#tblFormats" ) . hide ( ) ;
@@ -470,6 +498,4 @@ function demo() {
470498 assemblyGet . responseText ,
471499 fullGet . responseText , "" ) ;
472500 } ) ;
473-
474- hljs . initHighlightingOnLoad ( ) ;
475501}
0 commit comments