From be943727dcc8282f544fac3a96bcec3fc72fd84b Mon Sep 17 00:00:00 2001 From: Will Moore Date: Tue, 8 Jan 2013 22:25:10 +0000 Subject: [PATCH 01/17] Bulk of the code/pieces in place to run script --- .../webclient/base/base_container.html | 1 + .../base/includes/fig_script_launch.html | 63 +++ .../webclient/scripts/split_view_figure.html | 458 ++++++++++++++++++ .../tools/OmeroWeb/omeroweb/webclient/urls.py | 2 + .../OmeroWeb/omeroweb/webclient/views.py | 37 ++ .../static/webgateway/css/ome.header.css | 6 +- 6 files changed, 566 insertions(+), 1 deletion(-) create mode 100644 components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/base/includes/fig_script_launch.html create mode 100644 components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/scripts/split_view_figure.html diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/base/base_container.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/base/base_container.html index fbf0c392694..52b9604716f 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/base/base_container.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/base/base_container.html @@ -118,6 +118,7 @@ {% block middle_header_right %} + {% include "webclient/base/includes/fig_script_launch.html" %} {% include "webstart/includes/webstart_insight_toolbar.html" %} {% include "webclient/base/includes/basket_info.html" %} \ No newline at end of file From 35aaf71f45a0e1789655644f2cbbb1711fec789a Mon Sep 17 00:00:00 2001 From: Will Moore Date: Mon, 14 Jan 2013 23:31:15 +0000 Subject: [PATCH 15/17] Zoom slider for Split_View Fig preview --- .../javascript/ome.split_view_figure.js | 23 +++++++++++++++++++ .../webclient/scripts/split_view_figure.html | 11 +++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js index 0222d079236..184d51e3cfd 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js +++ b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js @@ -243,4 +243,27 @@ $(document).ready(function() { updateMergedChannels(); updateGrey(); + + // Bonus feature - Zoom the preview thumbs with slider + // Make a list of styles (for quick access on zoom) + var img_panel_styles = []; + $(".img_panel").each(function(){ + img_panel_styles.push(this.style); + }); + var setImgSize = function(size) { + var i, l = img_panel_styles.length; + for (i=0; iCreate Split View Figure View Script + +
From 92f3a073196f8607644a7fd762a1dbfd46088105 Mon Sep 17 00:00:00 2001 From: Will Moore Date: Tue, 15 Jan 2013 13:07:55 +0000 Subject: [PATCH 16/17] Disable Figure Scripts if selected objects not suitable --- .../webclient/controller/container.py | 23 +++++++++++++++++++ .../javascript/ome.webclient.actions.js | 6 +++-- .../includes/figure_scripts_menu.html | 9 +++++--- .../OmeroWeb/omeroweb/webclient/views.py | 8 +++++-- .../static/webgateway/css/ome.header.css | 17 ++++++++++++++ 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/components/tools/OmeroWeb/omeroweb/webclient/controller/container.py b/components/tools/OmeroWeb/omeroweb/webclient/controller/container.py index 0c01f5e3930..1d43e8e2760 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/controller/container.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/controller/container.py @@ -177,6 +177,29 @@ def getPlateId(self): elif self.acquisition: return self.acquisition._obj.plate.id.val + + def listFigureScripts(self, objDict=None): + """ + This configures all the Figure Scripts, setting their enabled status given the + currently selected object (self.image etc) or batch objects (uses objDict). + """ + figureScripts = [] + # id is used in url and is mapped to full script path by views.figure_script() + splitView = {'id': 'SplitView', 'name':'Split View Figure', 'enabled': False, + 'tooltip': "Create a figure of images, splitting their channels into separate views"} + # Split View Figure is enabled if we have at least one image with SizeC > 1 + if self.image: + splitView['enabled'] = (self.image.getSizeC() > 1) + elif objDict is not None: + if 'image' in objDict: + for i in objDict['image']: + if i.getSizeC() > 1: + splitView['enabled'] = True + break + figureScripts.append(splitView) + return figureScripts + + def openAstexViewerCompatible(self): """ Is the image suitable to be viewed with the Volume viewer 'Open Astex Viewer' applet? diff --git a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.webclient.actions.js b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.webclient.actions.js index f20d44f517b..c9f346aa98b 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.webclient.actions.js +++ b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.webclient.actions.js @@ -323,11 +323,13 @@ OME.initToolbarDropdowns = function() { // For Figure scripts, we need a popup: $("#figScriptList li a").click(function(event){ - OME.openScriptWindow(event, 800, 600); + if (!$(this).parent().hasClass("disabled")) { + OME.openScriptWindow(event, 800, 600); + } event.preventDefault(); return false; }); -} +}; jQuery.fn.tooltip_init = function() { $(this).tooltip({ diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/figure_scripts_menu.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/figure_scripts_menu.html index 1edcb822330..728670631fa 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/figure_scripts_menu.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/annotations/includes/figure_scripts_menu.html @@ -24,10 +24,13 @@ \ No newline at end of file diff --git a/components/tools/OmeroWeb/omeroweb/webclient/views.py b/components/tools/OmeroWeb/omeroweb/webclient/views.py index 55d418a96d4..751c4a11f26 100755 --- a/components/tools/OmeroWeb/omeroweb/webclient/views.py +++ b/components/tools/OmeroWeb/omeroweb/webclient/views.py @@ -811,6 +811,7 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa if share_id is None: template = "webclient/annotations/metadata_general.html" manager.annotationList() + figScripts = manager.listFigureScripts() form_comment = CommentAnnotationForm(initial=initial) else: template = "webclient/annotations/annotations_share.html" @@ -818,7 +819,8 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa if c_type in ("tag"): context = {'manager':manager} else: - context = {'manager':manager, 'form_comment':form_comment, 'index':index, 'share_id':share_id} + context = {'manager':manager, 'form_comment':form_comment, 'index':index, + 'share_id':share_id, 'figScripts':figScripts} context['template'] = template context['webclient_path'] = request.build_absolute_uri(reverse('webindex')) return context @@ -1083,6 +1085,7 @@ def batch_annotate(request, conn=None, **kwargs): manager = BaseContainer(conn) batchAnns = manager.loadBatchAnnotations(objs) + figScripts = manager.listFigureScripts(objs) obj_ids = [] obj_labels = [] @@ -1094,7 +1097,8 @@ def batch_annotate(request, conn=None, **kwargs): link_string = "|".join(obj_ids).replace("=", "-") context = {'form_comment':form_comment, 'obj_string':obj_string, 'link_string': link_string, - 'obj_labels': obj_labels, 'batchAnns': batchAnns, 'batch_ann':True, 'index': index} + 'obj_labels': obj_labels, 'batchAnns': batchAnns, 'batch_ann':True, 'index': index, + 'figScripts':figScripts} context['template'] = "webclient/annotations/batch_annotate.html" context['webclient_path'] = request.build_absolute_uri(reverse('webindex')) return context diff --git a/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/css/ome.header.css b/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/css/ome.header.css index 48d30f8724d..e8fc03b7541 100644 --- a/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/css/ome.header.css +++ b/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/css/ome.header.css @@ -463,6 +463,13 @@ float:none; position:relative; } + + .dropdown li.disabled { + background: transparent; + } + .dropdown li.disabled a { + color: #999; + } /* The menuItem class is added by js to items with children */ .dropdown > li > a.menuItem { @@ -488,6 +495,12 @@ filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#6B8FB3', endColorstr='#5C7A99',GradientType=0 ); /* IE6-9 */ background:linear-gradient(top, hsl(210,50%,60%) 0%,hsl(210,50%,50%) 100%); /* W3C */ + } + + .dropdown li.disabled:hover { + background: transparent !important; + border-bottom: 1px solid transparent; + border-top: 1px solid transparent; } .dropdown a, #group_user_chooser li strong{ @@ -514,6 +527,10 @@ color:white ; text-shadow:none !important; } + + .dropdown li.disabled:hover a { + color: #999; + } .dropdown li ul li a{ color:#333 !important; From 88f2f3caee8cab55eee2d102da732f452ffef8ee Mon Sep 17 00:00:00 2001 From: Will Moore Date: Thu, 24 Jan 2013 10:05:24 +0000 Subject: [PATCH 17/17] Number fields in script UIs only accept numbers. See #10055 --- .../javascript/ome.split_view_figure.js | 2 + .../webclient/scripts/script_ui.html | 3 ++ .../static/webgateway/js/ome.popup.js | 52 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js index 184d51e3cfd..ab93c82c2cb 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js +++ b/components/tools/OmeroWeb/omeroweb/webclient/static/webclient/javascript/ome.split_view_figure.js @@ -266,4 +266,6 @@ $(document).ready(function() { } }); + // For 'number' fields, only allow numbers input. + $(".number").numbersOnly(); }); \ No newline at end of file diff --git a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/scripts/script_ui.html b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/scripts/script_ui.html index 06d218ed86a..772ee285890 100644 --- a/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/scripts/script_ui.html +++ b/components/tools/OmeroWeb/omeroweb/webclient/templates/webclient/scripts/script_ui.html @@ -170,6 +170,9 @@ $IDs.val(""); } }); + + // For 'number' fields, only allow numbers input. + $(".number").numbersOnly(); }); {% endblock %} diff --git a/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/js/ome.popup.js b/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/js/ome.popup.js index fcbfdd2b132..55a6aa159b4 100644 --- a/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/js/ome.popup.js +++ b/components/tools/OmeroWeb/omeroweb/webgateway/static/webgateway/js/ome.popup.js @@ -34,6 +34,58 @@ jQuery.fn.alternateRowColors = function() { return this; }; + +// Call this on an to only allow numbers. +// I rejects all non-numeric characters but allows paste (then checks value) +// By default it only allows positive ints. +// To allow negative or float values use $(".number").numbersOnly({negative:true, float:true}); +jQuery.fn.numbersOnly = function(options) { + + // First, save the current value (assumed to be valid) + this.each(function() { + $(this).data('numbersOnly', $(this).val()); + }) + .keypress(function(event){ + + // we allow copy, paste, left or right + var allowedChars = [37, 39, 99, 118]; + if (options && options.negative) { + allowedChars.push(45); + } + if (options && options.float) { + allowedChars.push(46); + } + // Reject keypress if not a number and NOT one of our allowed Chars + var charCode = (event.which) ? event.which : event.keyCode; + if (charCode > 31 && (charCode < 48 || charCode > 57) && allowedChars.indexOf(charCode) == -1) { + return false; + } + + // We've allowed keypress (including paste)... + //finally check field value after waiting for keypress to update... + var $this = $(this); + setTimeout(function(){ + var n = $this.val(); + var isNumber = function(n) { + if (n.length === 0) { + return true; // empty strings are allowed + } + return !isNaN(parseFloat(n)) && isFinite(n); + }; + // If so, save to 'data', otherwise revert to 'data' + if (isNumber(n)) { + $this.data('numbersOnly', n); // update + } else { + $this.val( $this.data('numbersOnly') ); + } + }, 10); + + return true; + }); + + return this; +}; + OME.openPopup = function(url) { // IE8 doesn't support arbitrary text for 'name' 2nd arg. #6118 var owindow = window.open(url, '', 'height=600,width=850,left=50,top=50,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');