X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fweb%2Froot%2Fsrc%2Fmain%2Fresources%2Fjs%2Flib.js;h=c265760b97d28ff95210822e7bb0bf02293af925;hb=3a117f105f127bb255dd44f3cdde28e45d4d389a;hp=811d35e12b6a289a594e52b3b6d23e625db5cffa;hpb=f8cde08779b9a3c13e20c771df8a482e8bc27bb6;p=controller.git diff --git a/opendaylight/web/root/src/main/resources/js/lib.js b/opendaylight/web/root/src/main/resources/js/lib.js index 811d35e12b..c265760b97 100644 --- a/opendaylight/web/root/src/main/resources/js/lib.js +++ b/opendaylight/web/root/src/main/resources/js/lib.js @@ -26,6 +26,17 @@ one.lib.dashlet = { $h4.text(header); return $h4; }, + label : function(name, type) { + var $span = $(document.createElement('span')); + $span.addClass('label'); + if (type !== undefined) { + $span.addClass(type); + } else if (type !== null) { + $span.addClass('label-info'); + } + $span.append(name); + return $span; + }, list : function(list) { var $ul = $(document.createElement('ul')); $(list).each(function(index, value) { @@ -215,7 +226,10 @@ one.lib.modal = { return $clone; }, // populate modal - populate : function($modal, header, $body, footer) { + populate : function($modal, header, $body, footer, ajax) { + if (ajax === undefined && ajax !== false) { + $.getJSON('/web.json'); // session check per modal + } var $h3 = $modal.find("h3"); $h3.text(header); @@ -230,6 +244,9 @@ one.lib.modal = { spawn : function(id, header, $body, footer) { var $modal = one.lib.modal.clone(id); one.lib.modal.populate($modal, header, $body, footer); + $modal.on('hide', function () { + $('.modal-body').scrollTop(0); + }); return $modal; }, // empty modal @@ -354,6 +371,18 @@ one.lib.nav = { } } +one.lib.helper = { + parseInt : function(value) { + return (value != null && value.trim() !== '') ? + parseInt(value) : '' + }, + parseFloat : function(value) { + return (value != null && value.trim() !== '') ? + parseFloat(value) : '' + } +} + + /** ALERT */ one.lib.alert = function(alert) { $("#alert p").text(alert);