commit/galaxy-central: guerler: UI: Translate masthead mako code into js
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5828950834e3/ Changeset: 5828950834e3 User: guerler Date: 2013-11-05 18:34:42 Summary: UI: Translate masthead mako code into js Affected #: 14 files diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/galaxy.frame.js --- a/static/scripts/galaxy.frame.js +++ b/static/scripts/galaxy.frame.js @@ -1,5 +1,5 @@ /* - galaxy frames v2.0 + galaxy frames */ // dependencies @@ -9,7 +9,7 @@ var GalaxyFrameManager = Backbone.View.extend( { // base element - el_main: '#everything', + el_main: 'body', // defaults inputs options: @@ -46,7 +46,7 @@ // scroll/element top top: 0, - // maximum viewport + // viewport scrolling state top_max: 0, // frame z-index @@ -87,7 +87,7 @@ { icon : 'fa-th', tooltip : 'Enable/Disable Scratchbook', - on_click : function(e) { self.event_panel_active(e) }, + on_click : function(e) { self._event_panel_active(e) }, on_unload : function() { if (self.frame_counter > 0) return "You opened " + self.frame_counter + " frame(s) which will be lost."; @@ -102,7 +102,7 @@ { icon : 'fa-eye', tooltip : 'Show/Hide Scratchbook', - on_click : function(e) { self.event_panel_load(e) }, + on_click : function(e) { self._event_panel_load(e) }, with_number : true }); @@ -117,13 +117,13 @@ this.top = this.top_max = this.options.top_min; // create - this.setElement(this.template()); + this.setElement(this._template()); // load background - $(this.el).append(this.template_background()); + $(this.el).append(this._template_background()); // load menu buttons - $(this.el).append(this.template_menu()); + $(this.el).append(this._template_menu()); // load to main frame $(this.el_main).append($(this.el)); @@ -134,7 +134,7 @@ var id_shadow = '#frame-shadow'; // add shadow template - $(this.el).append(this.template_shadow(id_shadow.substring(1))); + $(this.el).append(this._template_shadow(id_shadow.substring(1))); // initialize frame this.frame_shadow = { @@ -146,23 +146,142 @@ }; // initialize size - this.frame_resize(this.frame_shadow, {width: 0, height: 0}); + this._frame_resize(this.frame_shadow, {width: 0, height: 0}); // add shadow to frame list this.frame_list[id_shadow] = this.frame_shadow; // initialize panel - this.panel_refresh(); + this._panel_refresh(); // catch window resize event var self = this; $(window).resize(function () { if (self.visible) - self.panel_refresh(); + self._panel_refresh(); }); }, + // adds and displays a new frame/window + frame_new: function(options) + { + // frame default options + var frameOptions = + { + title: '', + content: null, + target: '', + type: null, + scratchbook: false + } + + // read in defaults + if (options) + options = _.defaults(options, frameOptions); + else + options = frameOptions; + + // check for content + if(!options.content) + return; + + // open new tab + if (options.target == '_blank') + { + window.open(options.content); + return; + } + + // reload entire window + if (options.target == '_top' || options.target == '_parent' || options.target == '_self') + { + window.location = options.content; + return; + } + + // validate + if (!this.active) + { + // fix url if main frame is unavailable + var $galaxy_main = $(window.parent.document).find('#galaxy_main'); + if (options.target == 'galaxy_main' || options.target == 'center') + { + if ($galaxy_main.length == 0) + { + var href = options.content; + if (href.indexOf('?') == -1) + href += '?'; + else + href += '&'; + href += 'use_panels=True'; + window.location = href; + } else { + $galaxy_main.attr('src', options.content); + } + } else + window.location = options.content; + + // stop + return; + } + + // check for number of frames + if (this.frame_counter >= this.options.frame_max) + { + alert("You have reached the maximum number of allowed frames (" + this.options.frame_max + ")."); + return; + } + + // generate frame identifier + var frame_id = '#frame-' + (this.frame_counter_id++); + + // check if frame exists + if ($(frame_id).length !== 0) + { + alert("This frame already exists. This page might contain multiple frame managers."); + return; + } + + // reset top + this.top = this.options.top_min; + + // append + $(this.el).append(this._template_frame(frame_id.substring(1), options.title, options.type, options.content)); + + // construct a new frame + var frame = { + id : frame_id, + screen_location : {}, + grid_location : {}, + grid_rank : null, + grid_lock : false + }; + + // set dimensions + options.width = this._to_pixel_coord('width', this.options.frame.cols); + options.height = this._to_pixel_coord('height', this.options.frame.rows); + + // default z-index + this.frame_z = parseInt($(frame.id).css('z-index')); + + // add to frame list + this.frame_list[frame_id] = frame; + + // increase frame counter + this.frame_counter++; + + // resize + this._frame_resize(frame, {width: options.width, height: options.height}); + + // place frame + this._frame_insert(frame, {top: 0, left: 0}, true); + + // show frames if hidden + if (!this.visible) + this._panel_show_hide(); + }, + /* EVENT HANDLING */ @@ -179,23 +298,23 @@ events: { // global frame events - 'mousemove' : 'event_frame_mouse_move', - 'mouseup' : 'event_frame_mouse_up', - 'mouseleave' : 'event_frame_mouse_up', - 'mousewheel' : 'event_panel_scroll', - 'DOMMouseScroll' : 'event_panel_scroll', + 'mousemove' : '_event_frame_mouse_move', + 'mouseup' : '_event_frame_mouse_up', + 'mouseleave' : '_event_frame_mouse_up', + 'mousewheel' : '_event_panel_scroll', + 'DOMMouseScroll' : '_event_panel_scroll', // events fixed to elements - 'mousedown .frame' : 'event_frame_mouse_down', - 'mousedown .frame-background' : 'event_panel_load', - 'mousedown .frame-scroll-up' : 'event_panel_scroll_up', - 'mousedown .frame-scroll-down' : 'event_panel_scroll_down', - 'mousedown .f-close' : 'event_frame_close', - 'mousedown .f-pin' : 'event_frame_lock' + 'mousedown .frame' : '_event_frame_mouse_down', + 'mousedown .frame-background' : '_event_panel_load', + 'mousedown .frame-scroll-up' : '_event_panel_scroll_up', + 'mousedown .frame-scroll-down' : '_event_panel_scroll_down', + 'mousedown .f-close' : '_event_frame_close', + 'mousedown .f-pin' : '_event_frame_lock' }, // drag start - event_frame_mouse_down: function (e) + _event_frame_mouse_down: function (e) { // skip if event is already active if (this.event.type !== null) @@ -218,7 +337,7 @@ e.preventDefault(); // identify frame - this.event.target = this.event_get_frame(e.target); + this.event.target = this._frame_identify(e.target); // check if frame is locked if (this.event.target.grid_lock) @@ -231,11 +350,11 @@ this.event.xy = {x: e.originalEvent.pageX, y: e.originalEvent.pageY}; // prepare drag/resize - this.frame_drag_start(this.event.target); + this._frame_drag_start(this.event.target); }, // mouse move event - event_frame_mouse_move: function (e) + _event_frame_mouse_move: function (e) { // check if (this.event.type != 'drag' && this.event.type != 'resize') @@ -255,7 +374,7 @@ this.event.xy = event_xy_new; // object position / size - var p = this.frame_screen (this.event.target); + var p = this._frame_screen (this.event.target); // resize event if (this.event.type == 'resize') @@ -270,23 +389,23 @@ p.height = Math.max(p.height, min_dim); // apply resize to frame - this.frame_resize(this.event.target, p); + this._frame_resize(this.event.target, p); // break down to grid coordinates - p.width = this.to_grid_coord('width', p.width) + 1; - p.height = this.to_grid_coord('height', p.height) + 1; + p.width = this._to_grid_coord('width', p.width) + 1; + p.height = this._to_grid_coord('height', p.height) + 1; // transfer back to pixels - p.width = this.to_pixel_coord('width', p.width); - p.height = this.to_pixel_coord('height', p.height); + p.width = this._to_pixel_coord('width', p.width); + p.height = this._to_pixel_coord('height', p.height); // apply - this.frame_resize(this.frame_shadow, p); + this._frame_resize(this.frame_shadow, p); // fix position - this.frame_insert(this.frame_shadow, { - top : this.to_grid_coord('top', p.top), - left : this.to_grid_coord('left', p.left) + this._frame_insert(this.frame_shadow, { + top : this._to_grid_coord('top', p.top), + left : this._to_grid_coord('left', p.left) }); } @@ -298,12 +417,12 @@ p.top += event_xy_delta.y; // apply - this.frame_offset(this.event.target, p); + this._frame_offset(this.event.target, p); // get location of shadow var l = { - top : this.to_grid_coord('top', p.top), - left : this.to_grid_coord('left', p.left) + top : this._to_grid_coord('top', p.top), + left : this._to_grid_coord('left', p.left) }; // increase priority of current frame @@ -311,26 +430,26 @@ l.left++; // fix position - this.frame_insert(this.frame_shadow, l); + this._frame_insert(this.frame_shadow, l); } }, // mouse up - event_frame_mouse_up: function (e) + _event_frame_mouse_up: function (e) { // check if (this.event.type != 'drag' && this.event.type != 'resize') return; // stop - this.frame_drag_stop(this.event.target); + this._frame_drag_stop(this.event.target); // reset event this.event.type = null; }, // drag start - event_frame_close: function (e) + _event_frame_close: function (e) { // check if (this.event.type !== null) @@ -340,7 +459,7 @@ e.preventDefault(); // get frame - var frame = this.event_get_frame(e.target); + var frame = this._frame_identify(e.target); var self = this; // fade out @@ -356,19 +475,19 @@ self.frame_counter--; // reload - self.panel_refresh(true); + self._panel_refresh(true); // refresh scroll state once all animations completed - self.panel_animation_complete(); + self._panel_animation_complete(); // hide if no frames left if (self.visible && self.frame_counter == 0) - self.panel_show_hide(); + self._panel_show_hide(); }); }, // drag start - event_frame_lock: function (e) + _event_frame_lock: function (e) { // check if (this.event.type !== null) @@ -378,7 +497,7 @@ e.preventDefault(); // get frame - var frame = this.event_get_frame(e.target); + var frame = this._frame_identify(e.target); // check if (frame.grid_lock) @@ -406,29 +525,29 @@ }, // show/hide panel - event_panel_load: function (e) + _event_panel_load: function (e) { // check if (this.event.type !== null) return; // load panel - this.panel_show_hide(); + this._panel_show_hide(); }, // activate/disable panel - event_panel_active: function (e) + _event_panel_active: function (e) { // check if (this.event.type !== null) return; // load panel - this.panel_active_disable(); + this._panel_active_disable(); }, // scroll - event_panel_scroll: function(e) + _event_panel_scroll: function(e) { // check if (this.event.type !== null || !this.visible) @@ -441,11 +560,11 @@ var delta = e.originalEvent.detail ? e.originalEvent.detail : e.originalEvent.wheelDelta / -3; // refresh panel - this.panel_scroll(delta); + this._panel_scroll(delta); }, // scroll up - event_panel_scroll_up: function(e) + _event_panel_scroll_up: function(e) { // check if (this.event.type !== null) @@ -455,11 +574,11 @@ e.preventDefault(); // scroll up - this.panel_scroll(-this.options.scroll); + this._panel_scroll(-this.options.scroll); }, // scroll down - event_panel_scroll_down: function(e) + _event_panel_scroll_down: function(e) { // check if (this.event.type !== null) @@ -469,31 +588,31 @@ e.preventDefault(); // scroll down - this.panel_scroll(this.options.scroll); + this._panel_scroll(this.options.scroll); }, + /* + FRAME EVENTS SUPPORT + */ + // identify - event_get_frame: function(target) + _frame_identify: function(target) { return this.frame_list['#' + $(target).closest('.frame').attr('id')]; }, - - /* - FRAME EVENTS START/STOP - */ - + // drag start - frame_drag_start : function (frame) + _frame_drag_start : function (frame) { // set focus - this.frame_focus(frame, true); + this._frame_focus(frame, true); // get current dimensions - var p = this.frame_screen (frame); + var p = this._frame_screen (frame); // initialize shadow - this.frame_resize(this.frame_shadow, p); - this.frame_grid(this.frame_shadow, frame.grid_location); + this._frame_resize(this.frame_shadow, p); + this._frame_grid(this.frame_shadow, frame.grid_location); // reset location frame.grid_location = null; @@ -506,17 +625,17 @@ }, // drag stop - frame_drag_stop : function (frame) + _frame_drag_stop : function (frame) { // remove focus - this.frame_focus(frame, false); + this._frame_focus(frame, false); // get new dimensions - var p = this.frame_screen(this.frame_shadow); + var p = this._frame_screen(this.frame_shadow); // update frame - this.frame_resize(frame, p); - this.frame_grid(frame, this.frame_shadow.grid_location, true); + this._frame_resize(frame, p); + this._frame_grid(frame, this.frame_shadow.grid_location, true); // reset location of shadow this.frame_shadow.grid_location = null; @@ -528,7 +647,7 @@ $('.f-cover').hide(); // refresh scroll state once all animations completed - this.panel_animation_complete(); + this._panel_animation_complete(); }, /* @@ -536,7 +655,7 @@ */ // converts a pixel coordinate to grids - to_grid_coord: function (type, px) + _to_grid_coord: function (type, px) { // determine sign var sign = (type == 'width' || type == 'height') ? 1 : -1; @@ -548,7 +667,7 @@ }, // converts a grid coordinate to pixels - to_pixel_coord: function (type, g) + _to_pixel_coord: function (type, g) { // determine sign var sign = (type == 'width' || type == 'height') ? 1 : -1; @@ -562,25 +681,25 @@ }, // get grid coordinates - to_grid: function (px) + _to_grid: function (px) { // full set return { - top : this.to_grid_coord('top', px.top), - left : this.to_grid_coord('left', px.left), - width : this.to_grid_coord('width', px.width), - height : this.to_grid_coord('height', px.height) + top : this._to_grid_coord('top', px.top), + left : this._to_grid_coord('left', px.left), + width : this._to_grid_coord('width', px.width), + height : this._to_grid_coord('height', px.height) }; }, // get pixel coordinates - to_pixel: function(g) + _to_pixel: function(g) { return { - top : this.to_pixel_coord('top', g.top), - left : this.to_pixel_coord('left', g.left), - width : this.to_pixel_coord('width', g.width), - height : this.to_pixel_coord('height', g.height) + top : this._to_pixel_coord('top', g.top), + left : this._to_pixel_coord('left', g.left), + width : this._to_pixel_coord('width', g.width), + height : this._to_pixel_coord('height', g.height) }; }, @@ -589,7 +708,7 @@ */ // check collision - is_collision: function(g) + _is_collision: function(g) { // is collision pair function is_collision_pair (a, b) @@ -618,7 +737,7 @@ }, // location/grid rank - location_rank: function(loc) + _location_rank: function(loc) { return (loc.top * this.cols) + loc.left; }, @@ -628,7 +747,7 @@ */ // update frame counter - menu_refresh: function() + _menu_refresh: function() { // update on screen counter this.button_load.number(this.frame_counter); @@ -657,24 +776,24 @@ */ // panel on animation complete / frames not moving - panel_animation_complete: function() + _panel_animation_complete: function() { var self = this; - $(".frame").promise().done(function() {self.panel_scroll(0, true)}); + $(".frame").promise().done(function() {self._panel_scroll(0, true)}); }, // refresh panel - panel_refresh: function(animate) + _panel_refresh: function(animate) { // get current size this.cols = parseInt($(window).width() / this.options.cell, 10) + 1; // recalculate frame positions - this.frame_insert(null, null, animate); + this._frame_insert(null, null, animate); }, // update scroll - panel_scroll: function(delta, animate) + _panel_scroll: function(delta, animate) { // new top value var top_new = this.top - this.options.scroll * delta; @@ -699,7 +818,7 @@ top : frame.screen_location.top - (this.top - top_new), left : frame.screen_location.left } - this.frame_offset(frame, screen_location, animate); + this._frame_offset(frame, screen_location, animate); } } @@ -708,11 +827,11 @@ } // refresh - this.menu_refresh(); + this._menu_refresh(); }, // show or hide panel - panel_show_hide: function() + _panel_show_hide: function() { // check if (this.visible) @@ -750,12 +869,12 @@ $(".frame-background").show(); // show panel - this.panel_refresh(); + this._panel_refresh(); } }, // show or hide panel - panel_active_disable: function() + _panel_active_disable: function() { // check if (this.active) @@ -768,7 +887,7 @@ // hide panel if (this.visible) - this.panel_show_hide(); + this._panel_show_hide(); } else { // activate this.active = true; @@ -781,82 +900,9 @@ /* FRAME FUNCTIONS */ - // adds and displays a new frame/window - frame_new: function(options) - { - // validate - if (!this.active) - { - // load frame in main window - if (options.location == 'center') - { - var galaxy_main = $( window.parent.document ).find( 'iframe#galaxy_main' ); - galaxy_main.attr( 'src', options.content ); - } else - window.location = options.content; - - // stop - return; - } - - // check for number of frames - if (this.frame_counter >= this.options.frame_max) - { - alert("You have reached the maximum number of allowed frames (" + this.options.frame_max + ")."); - return; - } - - // generate frame identifier - var frame_id = '#frame-' + (this.frame_counter_id++); - - // check if frame exists - if ($(frame_id).length !== 0) - { - alert("This frame already exists. This page might contain multiple frame managers."); - return; - } - - // reset top - this.top = this.options.top_min; - - // append - $(this.el).append(this.template_frame(frame_id.substring(1), options.title, options.type, options.content)); - - // construct a new frame - var frame = { - id : frame_id, - screen_location : {}, - grid_location : {}, - grid_rank : null, - grid_lock : false - }; - - // set dimensions - options.width = this.to_pixel_coord('width', this.options.frame.cols); - options.height = this.to_pixel_coord('height', this.options.frame.rows); - - // default z-index - this.frame_z = parseInt($(frame.id).css('z-index')); - - // add to frame list - this.frame_list[frame_id] = frame; - - // increase frame counter - this.frame_counter++; - - // resize - this.frame_resize(frame, {width: options.width, height: options.height}); - - // place frame - this.frame_insert(frame, {top: 0, left: 0}, true); - - // show frames if hidden - if (!this.visible) - this.panel_show_hide(); - }, // frame insert at given location - frame_insert: function(frame, new_loc, animate) + _frame_insert: function(frame, new_loc, animate) { // define var place_list = []; @@ -868,7 +914,7 @@ frame.grid_location = null; // set first one to be placed - place_list.push([frame, this.location_rank(new_loc)]); + place_list.push([frame, this._location_rank(new_loc)]); } // search @@ -899,7 +945,7 @@ // place for (i = 0; i < place_list.length; i++) - this.frame_place(place_list[i][0], animate); + this._frame_place(place_list[i][0], animate); // identify maximum viewport size this.top_max = 0; @@ -920,17 +966,17 @@ this.top_max = Math.min(this.top_max, this.options.top_min); // panel menu - this.menu_refresh(); + this._menu_refresh(); }, // naive frame place - frame_place: function(frame, animate) + _frame_place: function(frame, animate) { // reset grid location frame.grid_location = null; // grid coordinates of new frame - var g = this.to_grid(this.frame_screen(frame)); + var g = this._to_grid(this._frame_screen(frame)); // try grid coordinates var done = false; @@ -944,7 +990,7 @@ g.left = j; // no collision - if (!this.is_collision(g)) + if (!this._is_collision(g)) { done = true; break; @@ -958,13 +1004,13 @@ // check if valid spot was found if (done) - this.frame_grid(frame, g, animate); + this._frame_grid(frame, g, animate); else console.log("Grid dimensions exceeded."); }, // focus - frame_focus: function(frame, has_focus) + _frame_focus: function(frame, has_focus) { // get new z-value var z = this.frame_z + (has_focus ? 1 : 0); @@ -974,7 +1020,7 @@ }, // new left/top position frame - frame_offset: function(frame, p, animate) + _frame_offset: function(frame, p, animate) { // update screen location frame.screen_location.left = p.left; @@ -984,7 +1030,7 @@ if (animate) { // set focus on animated - this.frame_focus(frame, true); + this._frame_focus(frame, true); // prepare for callback var self = this; @@ -993,7 +1039,7 @@ $(frame.id).animate({top: p.top, left: p.left}, 'fast', function() { // remove focus - self.frame_focus(frame, false); + self._frame_focus(frame, false); }); } else // update css @@ -1001,7 +1047,7 @@ }, // resize frame - frame_resize: function(frame, p) + _frame_resize: function(frame, p) { // update css $(frame.id).css({width: p.width, height: p.height}); @@ -1012,20 +1058,20 @@ }, // new grid location - frame_grid: function (frame, l, animate) + _frame_grid: function (frame, l, animate) { // update grid location frame.grid_location = l; // place frame - this.frame_offset(frame, this.to_pixel(l), animate); + this._frame_offset(frame, this._to_pixel(l), animate); // update grid rank - frame.grid_rank = this.location_rank(l); + frame.grid_rank = this._location_rank(l); }, // get frame dimensions - frame_screen: function(frame) + _frame_screen: function(frame) { var p = frame.screen_location; return {top: p.top, left: p.left, width: p.width, height: p.height}; @@ -1036,13 +1082,13 @@ */ // main element - template: function() + _template: function() { - return '<div class="galaxy-frame"></div>'; + return '<div class="galaxy-frame"></div>'; }, // fill regular frame template - template_frame: function(id, title, type, content) + _template_frame: function(id, title, type, content) { // check title if (!title) @@ -1067,19 +1113,19 @@ }, // fill shadow template - template_shadow: function(id) + _template_shadow: function(id) { return '<div id="' + id + '" class="frame-shadow corner"></div>'; }, // fill background template in order to cover underlying iframes - template_background: function() + _template_background: function() { return '<div class="frame-background"></div>'; }, // fill menu button template - template_menu: function() + _template_menu: function() { return '<div class="frame-scroll-up frame-menu fa fa-chevron-up fa-2x"></div>' + '<div class="frame-scroll-down frame-menu fa fa-chevron-down fa-2x"></div>'; diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/galaxy.master.js --- a/static/scripts/galaxy.master.js +++ b/static/scripts/galaxy.master.js @@ -3,27 +3,53 @@ */ // dependencies -define(["libs/backbone/backbone-relational"], function() { +define(["utils/galaxy.utils", "libs/backbone/backbone-relational"], function(mod_utils) { // master var GalaxyMaster = Backbone.View.extend( { // base element - el_master: '#masthead', + el_master: '#everything', + + // options + options : null, // item list - list : [], + list : {}, + + // keeps track of the last element + itemLast: null, + + // counter + itemCounter: 0, + + // background + $background: null, + + // flag indicating visibility of background + backgroundVisible: false, // initialize initialize : function(options) { + // update options + this.options = options; + + // HACK: due to body events defined in galaxy.panels.js + $("body").off(); + // define this element - this.setElement($(this.template())); + this.setElement($(this._template(options))); // append to master $(this.el_master).append($(this.el)); + // assign background + this.$background = $(this.el).find('#master-background'); + // loop through item specific unload functions + // and collect all there warning messages, regarding + // the user's attempt to unload the page var self = this; window.onbeforeunload = function() { @@ -39,38 +65,133 @@ }; }, - // prevent default + // configure events events: { - 'mousedown' : function(e) {e.preventDefault()} + 'click' : '_eventRefresh', + 'mousedown' : function(e) { e.preventDefault() } }, // adds a new item to the master append : function(item) { - $(this.el).append($(item.el)); - this.list.push(item); + return this._add(item, true); }, // adds a new item to the master prepend : function(item) { - $(this.el).prepend($(item.el)); - this.list.push(item); + return this._add(item, false); + }, + + // adds a new item to the master + _add : function(item, append) + { + var $loc = $(this.el).find('#' + item.masterLocation); + if ($loc) + { + // create frame for new item + var itemId = 'master-item-' + this.itemCounter++; + var $itemNew = $(item.el); + + // configure id and class in order to mark new items + $itemNew.attr('id', itemId); + $itemNew.addClass('master-item'); + + // append to master + if (append) + $loc.append($itemNew); + else + $loc.prepend($itemNew); + + // add to list + this.list[itemId] = item; + + // return item id + return itemId; + } + + // location not found + return null; + }, + + // handle click event + _eventRefresh: function(e) + { + // identify current item + var itemCurrent = $(e.target).closest('.master-item'); + + // get identifier + if (itemCurrent.length) + itemCurrent = itemCurrent.attr('id'); + + // check last item + if (this.itemLast && this.itemLast != itemCurrent) + { + var it = this.list[this.itemLast]; + if (it) + if (it.masterReset) + it.masterReset(); + } + + // check if current item is in active state + var useBackground = false; + if (itemCurrent) + { + var it = this.list[itemCurrent]; + if (it) + if (it.masterReset) + { + if (this.itemLast == itemCurrent) + useBackground = this.backgroundVisible ? false : true; + else + useBackground = true; + } + } + + // decide wether to show/hide background + if (useBackground) + this.$background.show(); + else + this.$background.hide(); + + // backup + this.backgroundVisible = useBackground; + this.itemLast = itemCurrent; }, /* HTML TEMPLATES */ + + // template item + _templateItem: function(id) + { + return '<div id="' + id + '" class="master-item"></div>'; + }, - // fill regular modal template - template: function() + // fill template + _template: function(options) { - return '<div class="iconbar"></div>'; + return '<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse">' + + '<div style="position: relative; right: -50%; float: left;">' + + '<div id="navbar" style="display: block; position: relative; right: 50%;"></div>' + + '</div>' + + '<div class="navbar-brand">' + + '<a href="' + options.logo_url + '">' + + '<img border="0" src="' + galaxy_config.root + 'static/images/galaxyIcon_noText.png">' + + '<span id="brand"> Galaxy ' + options.brand + '</span>' + + '</a>' + + '</div>' + + '<div class="quota-meter-container"></div>' + + '<div id="iconbar" class="iconbar"></div>' + + '</div>' + + '<div id="master-background" style="display: none; position: absolute; top: 33px; width: 100%; height: 100%; z-index: 1010"></div>' + + '</div>'; } }); -// frame manager +// icon var GalaxyMasterIcon = Backbone.View.extend( { // icon options @@ -85,6 +206,9 @@ visible : true }, + // location identifier for master class + masterLocation: 'iconbar', + // initialize initialize: function (options) { @@ -93,12 +217,12 @@ this.options = _.defaults(options, this.options); // add template for icon - this.setElement($(this.template(this.options))); + this.setElement($(this._template(this.options))); // configure icon var self = this; $(this.el).find('.icon').tooltip({title: this.options.tooltip}) - .on('click', self.options.on_click); + .on('mouseup', self.options.on_click); // visiblity if (!this.options.visible) @@ -147,7 +271,7 @@ }, // fill template icon - template: function (options) + _template: function (options) { var tmpl = '<div id=' + options.id + ' class="symbol">' + '<div class="icon fa fa-2x ' + options.icon + '"></div>'; @@ -160,10 +284,210 @@ } }); +// tab +var GalaxyMasterTab = Backbone.View.extend( +{ + // main options + options: + { + id : '', + title : 'Title', + target : '_parent', + content : '', + type : 'url', + scratchbook : false, + on_unload : null, + visible : true + }, + + // location + masterLocation: 'navbar', + + // optional sub menu + $menu: null, + + // flag if menu is visible + menuVisible: false, + + // events + events: + { + 'click .head' : '_eventClickHead' + }, + + // initialize + initialize: function (options) + { + // read in defaults + if (options) + this.options = _.defaults(options, this.options); + + // update url + if (this.options.content && this.options.content.indexOf('//') === -1) + this.options.content = galaxy_config.root + this.options.content; + + // add template for tab + this.setElement($(this._template(this.options))); + + // visiblity + if (!this.options.visible) + this.hide(); + }, + + // show + show: function() + { + $(this.el).css({visibility : 'visible'}); + }, + + // show + hide: function() + { + $(this.el).css({visibility : 'hidden'}); + }, + + // add menu item + addMenu: function (options) + { + // menu option defaults + var menuOptions = { + title : 'Title', + content : '', + type : 'url', + target : '_parent', + scratchbook : false, + divider : false + } + + // read in defaults + if (options) + menuOptions = _.defaults(options, menuOptions); + + // update url + if (menuOptions.content && menuOptions.content.indexOf('//') === -1) + menuOptions.content = galaxy_config.root + menuOptions.content; + + // check if submenu element is available + if (!this.$menu) + { + // insert submenu element into root + $(this.el).find('.root').append(this._templateMenu()); + + // show caret + $(this.el).find('.symbol').addClass('caret'); + + // update element link + this.$menu = $(this.el).find('.menu'); + } + + // create + var $item = $(this._templateMenuItem(menuOptions)); + + // append menu + this.$menu.append($item); + + // add events + var self = this; + $item.on('click', function(e) + { + // prevent default + e.preventDefault(); + + // check for menu options + self._hideMenu(); + + // no modifications if new tab is requested + if (self.options.target === '_blank') + return true; + + // load into frame + Galaxy.frame_manager.frame_new(options); + }); + + // append divider + if (menuOptions.divider) + this.$menu.append($(this._templateDivider())); + }, + + // add reset function called by master + masterReset: function() + { + this._hideMenu(); + }, + + // hide menu + _hideMenu: function() + { + if (this.$menu && this.menuVisible) + { + this.$menu.hide(); + this.menuVisible = false; + } + }, + + // show menu on header click + _eventClickHead: function(e) + { + // prevent default + e.preventDefault(); + + // check for menu options + if (this.$menu) + { + // show/hide menu + if (!this.menuVisible) + { + this.$menu.show(); + this.menuVisible = true; + } else { + this.$menu.hide(); + this.menuVisible = false; + } + } else { + // open new frame + Galaxy.frame_manager.frame_new(this.options); + } + }, + + // fill template header + _templateMenuItem: function (options) + { + return '<li><a href="' + options.content + '" target="' + options.target + '">' + options.title + '</a></li>'; + }, + + // fill template header + _templateMenu: function () + { + return '<ul class="menu dropdown-menu"></ul>'; + }, + + _templateDivider: function() + { + return '<li class="divider"></li>'; + }, + + // fill template + _template: function (options) + { + // start template + var tmpl = '<ul class="nav navbar-nav" border="0" cellspacing="0">' + + '<li class="root dropdown" style="">' + + '<a class="head dropdown-toggle" data-toggle="dropdown" target="' + options.target + '" href="' + options.content + '">' + + options.title + '<b class="symbol"></b>' + + '</a>' + + '</li>' + + '</ul>'; + + // return template + return tmpl; + } +}); + // return return { GalaxyMaster: GalaxyMaster, - GalaxyMasterIcon : GalaxyMasterIcon + GalaxyMasterTab: GalaxyMasterTab, + GalaxyMasterIcon: GalaxyMasterIcon }; }); diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/galaxy.menu.js --- /dev/null +++ b/static/scripts/galaxy.menu.js @@ -0,0 +1,330 @@ +/* + galaxy menu +*/ + +// dependencies +define(["galaxy.master", "libs/backbone/backbone-relational"], function(mod_master) { + +// frame manager +var GalaxyMenu = Backbone.Model.extend( +{ + // options + options: null, + + // link master class + master: null, + + // initialize + initialize: function(options) + { + this.options = options.config; + this.master = options.master; + this.create(); + }, + + // default menu + create: function() + { + // + // Analyze data tab. + // + var tab_analysis = new mod_master.GalaxyMasterTab({ + title : "Analyze Data", + content : "root/index" + }); + this.master.append(tab_analysis); + + // + // Workflow tab. + // + var tab_workflow = new mod_master.GalaxyMasterTab({ + title : "Workflow", + content : "workflow" + + }); + this.master.append(tab_workflow); + + // + // 'Shared Items' or Libraries tab. + // + var tab_shared = new mod_master.GalaxyMasterTab({ + title : "Shared Data", + content : "library/index" + }); + + tab_shared.addMenu({ + title : "Data Libraries", + content : "library/index", + divider : true + }); + + tab_shared.addMenu({ + title : "Published Histories", + content : "history/list_published" + }); + + tab_shared.addMenu({ + title : "Published Workflows", + content : "workflow/list_published" + + }); + + tab_shared.addMenu({ + title : "Published Visualizations", + content : "visualization/list_published" + }); + + tab_shared.addMenu({ + title : "Published Pages", + content : "page/list_published" + }); + + this.master.append(tab_shared); + + // + // Lab menu. + // + if (this.options.user.requests) + { + var tab_lab = new mod_master.GalaxyMasterTab({ + title : "Lab" + }); + tab_lab.addMenu({ + title : "Sequencing Requests", + content : "requests/index" + }); + tab_lab.addMenu({ + title : "Find Samples", + content : "requests/find_samples_index" + }); + tab_lab.addMenu({ + title : "Help", + content : this.options.lims_doc_url + }); + this.master.append(tab_lab); + } + + // + // Visualization tab. + // + var tab_visualization = new mod_master.GalaxyMasterTab({ + + title : "Visualization", + content : "visualization/list" + }); + tab_visualization.addMenu({ + title : "New Track Browser", + content : "visualization/trackster", + target : "_frame" + }); + tab_visualization.addMenu({ + title : "Saved Visualizations", + content : "visualization/list", + target : "_frame" + }); + this.master.append(tab_visualization); + + // + // Cloud menu. + // + if (this.options.enable_cloud_launch) + { + var tab_cloud = new mod_master.GalaxyMasterTab({ + title : "Cloud", + content : "cloudlaunch/index" + }); + tab_cloud.addMenu({ + title : "New Cloud Cluster", + content : "cloudlaunch/index" + }); + this.master.append(tab_cloud); + } + + // + // Admin. + // + if (this.options.is_admin_user) + { + var tab_admin = new mod_master.GalaxyMasterTab({ + title : "Admin", + content : "admin/index", + extra_class : "admin-only" + }); + this.master.append(tab_admin); + } + + // + // Help tab. + // + var tab_help = new mod_master.GalaxyMasterTab({ + title : "Help" + }); + if (this.options.biostar_url) + { + tab_help.addMenu({ + title : "Galaxy Q&A Site", + content : this.options.biostar_url_redirect, + target : "_blank" + }); + tab_help.addMenu({ + title : "Ask a question", + content : "biostar/biostar_question_redirect", + target : "_blank" + }); + } + tab_help.addMenu({ + title : "Support", + content : this.options.support_url, + target : "_blank" + }); + tab_help.addMenu({ + title : "Search", + content : this.options.search_url, + target : "_blank" + }); + tab_help.addMenu({ + title : "Mailing Lists", + content : this.options.mailing_lists, + target : "_blank" + }); + tab_help.addMenu({ + title : "Videos", + content : this.options.screencasts_url, + target : "_blank" + }); + tab_help.addMenu({ + title : "Wiki", + content : this.options.wiki_url, + target : "_blank" + }); + tab_help.addMenu({ + title : "How to Cite Galaxy", + content : this.options.citation_url, + target : "_blank" + }); + if (!this.options.terms_url) + { + tab_help.addMenu({ + title : "Terms and Conditions", + content : this.options.terms_url, + target : "_blank" + }); + } + this.master.append(tab_help); + + // + // User tab. + // + if (!this.options.user.valid) + { + var tab_user = new mod_master.GalaxyMasterTab({ + title : "User", + extra_class : "loggedout-only" + }); + + // login + if (this.options.allow_user_creation) + { + tab_user.addMenu({ + title : "Login", + content : "user/login", + target : "galaxy_main" + }); + } + + // register + if (this.options.allow_user_creation) + { + tab_user.addMenu({ + title : "Register", + content : "user/create", + target : "galaxy_main" + }); + } + + // add to master + this.master.append(tab_user); + } else { + var tab_user = new mod_master.GalaxyMasterTab({ + title : "User", + extra_class : "loggedin-only" + }); + + // show user logged in info + tab_user.addMenu({ + title : "Logged in as " + this.options.user.email + }); + + // remote user + if (this.options.use_remote_user && this.options.remote_user_logout_href) + { + tab_user.addMenu({ + title : "Logout", + content : this.options.remote_user_logout_href, + target : "_top" + }); + } else { + tab_user.addMenu({ + title : "Preferences", + content : "user?cntrller=user", + target : "galaxy_main" + }); + + tab_user.addMenu({ + title : "Custom Builds", + content : "user/dbkeys", + target : "galaxy_main" + }); + + tab_user.addMenu({ + title : "Logout", + content : "user/logout", + target : "_top", + divider : true + }); + } + + // default tabs + tab_user.addMenu({ + title : "Saved Histories", + content : "history/list", + target : "galaxy_main" + }); + tab_user.addMenu({ + title : "Saved Datasets", + content : "dataset/list", + target : "galaxy_main" + }); + tab_user.addMenu({ + title : "Saved Pages", + content : "page/list", + target : "_top" + }); + + tab_user.addMenu({ + title : "API Keys", + content : "user/api_keys?cntrller=user", + target : "galaxy_main" + }); + + if (this.options.use_remote_user) + { + tab_user.addMenu({ + title : "Public Name", + content : "user/edit_username?cntrller=user", + target : "galaxy_main" + }); + } + + // add to master + this.master.append(tab_user); + } + } +}); + +// return +return { + GalaxyMenu: GalaxyMenu +}; + +}); diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/mvc/dataset/hda-base.js --- a/static/scripts/mvc/dataset/hda-base.js +++ b/static/scripts/mvc/dataset/hda-base.js @@ -173,10 +173,10 @@ var self = this; displayBtnData.onclick = function(){ Galaxy.frame_manager.frame_new({ - title : "Data Viewer: " + self.model.get('name'), - type : "url", - location: "center", - content : self.urls.display + title : "Data Viewer: " + self.model.get('name'), + type : "url", + target : "galaxy_main", + content : self.urls.display }); }; } diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/mvc/dataset/hda-edit.js --- a/static/scripts/mvc/dataset/hda-edit.js +++ b/static/scripts/mvc/dataset/hda-edit.js @@ -232,9 +232,9 @@ return function(){// add widget Galaxy.frame_manager.frame_new( { - title : "Visualization", - type : "url", - content : visualization_url + '/' + visualization + '?' + $.param( params ) + title : "Visualization", + type : "url", + content : visualization_url + '/' + visualization + '?' + $.param( params ) }); }; } @@ -491,10 +491,11 @@ // add widget Galaxy.frame_manager.frame_new( { - title : "Scatterplot", - type : "url", - content : url + '/scatterplot?' + $.param(params), - location : 'center' + title : "Scatterplot", + type : "url", + content : url + '/scatterplot?' + $.param(params), + target : 'galaxy_main', + scratchbook : true }); //TODO: this needs to go away @@ -553,9 +554,10 @@ // add widget parent.Galaxy.frame_manager.frame_new({ - title : "Trackster", - type : "url", - content : vis_url + "/trackster?" + $.param(dataset_params) + title : "Trackster", + type : "url", + content : vis_url + "/trackster?" + $.param(dataset_params), + scratchbook : true }); }); } @@ -570,9 +572,10 @@ // add widget parent.Galaxy.frame_manager.frame_new({ - title : "Trackster", - type : "url", - content : url + title : "Trackster", + type : "url", + content : url, + scratchbook : true }); } } diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/packed/galaxy.frame.js --- a/static/scripts/packed/galaxy.frame.js +++ b/static/scripts/packed/galaxy.frame.js @@ -1,1 +1,1 @@ -define(["galaxy.master","libs/backbone/backbone-relational"],function(b){var a=Backbone.View.extend({el_main:"#everything",options:{frame:{cols:6,rows:3},rows:1000,cell:130,margin:5,scroll:5,top_min:40,frame_max:9},cols:0,top:0,top_max:0,frame_z:0,frame_counter:0,frame_counter_id:0,frame_list:[],frame_shadow:null,visible:false,active:false,button_active:null,button_load:null,initialize:function(d){var c=this;this.button_active=new b.GalaxyMasterIcon({icon:"fa-th",tooltip:"Enable/Disable Scratchbook",on_click:function(f){c.event_panel_active(f)},on_unload:function(){if(c.frame_counter>0){return"You opened "+c.frame_counter+" frame(s) which will be lost."}}});Galaxy.master.append(this.button_active);this.button_load=new b.GalaxyMasterIcon({icon:"fa-eye",tooltip:"Show/Hide Scratchbook",on_click:function(f){c.event_panel_load(f)},with_number:true});Galaxy.master.append(this.button_load);if(d){this.options=_.defaults(d,this.options)}this.top=this.top_max=this.options.top_min;this.setElement(this.template());$(this.el).append(this.template_background());$(this.el).append(this.template_menu());$(this.el_main).append($(this.el));var e="#frame-shadow";$(this.el).append(this.template_shadow(e.substring(1)));this.frame_shadow={id:e,screen_location:{},grid_location:{},grid_rank:null,grid_lock:false};this.frame_resize(this.frame_shadow,{width:0,height:0});this.frame_list[e]=this.frame_shadow;this.panel_refresh();var c=this;$(window).resize(function(){if(c.visible){c.panel_refresh()}})},event:{type:null,target:null,xy:null},events:{mousemove:"event_frame_mouse_move",mouseup:"event_frame_mouse_up",mouseleave:"event_frame_mouse_up",mousewheel:"event_panel_scroll",DOMMouseScroll:"event_panel_scroll","mousedown .frame":"event_frame_mouse_down","mousedown .frame-background":"event_panel_load","mousedown .frame-scroll-up":"event_panel_scroll_up","mousedown .frame-scroll-down":"event_panel_scroll_down","mousedown .f-close":"event_frame_close","mousedown .f-pin":"event_frame_lock"},event_frame_mouse_down:function(c){if(this.event.type!==null){return}if($(c.target).hasClass("f-header")||$(c.target).hasClass("f-title")){this.event.type="drag"}if($(c.target).hasClass("f-resize")){this.event.type="resize"}if(this.event.type===null){return}c.preventDefault();this.event.target=this.event_get_frame(c.target);if(this.event.target.grid_lock){this.event.type=null;return}this.event.xy={x:c.originalEvent.pageX,y:c.originalEvent.pageY};this.frame_drag_start(this.event.target)},event_frame_mouse_move:function(i){if(this.event.type!="drag"&&this.event.type!="resize"){return}var g={x:i.originalEvent.pageX,y:i.originalEvent.pageY};var d={x:g.x-this.event.xy.x,y:g.y-this.event.xy.y};this.event.xy=g;var h=this.frame_screen(this.event.target);if(this.event.type=="resize"){h.width+=d.x;h.height+=d.y;var f=this.options.cell-this.options.margin-1;h.width=Math.max(h.width,f);h.height=Math.max(h.height,f);this.frame_resize(this.event.target,h);h.width=this.to_grid_coord("width",h.width)+1;h.height=this.to_grid_coord("height",h.height)+1;h.width=this.to_pixel_coord("width",h.width);h.height=this.to_pixel_coord("height",h.height);this.frame_resize(this.frame_shadow,h);this.frame_insert(this.frame_shadow,{top:this.to_grid_coord("top",h.top),left:this.to_grid_coord("left",h.left)})}if(this.event.type=="drag"){h.left+=d.x;h.top+=d.y;this.frame_offset(this.event.target,h);var c={top:this.to_grid_coord("top",h.top),left:this.to_grid_coord("left",h.left)};if(c.left!==0){c.left++}this.frame_insert(this.frame_shadow,c)}},event_frame_mouse_up:function(c){if(this.event.type!="drag"&&this.event.type!="resize"){return}this.frame_drag_stop(this.event.target);this.event.type=null},event_frame_close:function(d){if(this.event.type!==null){return}d.preventDefault();var f=this.event_get_frame(d.target);var c=this;$(f.id).fadeOut("fast",function(){$(f.id).remove();delete c.frame_list[f.id];c.frame_counter--;c.panel_refresh(true);c.panel_animation_complete();if(c.visible&&c.frame_counter==0){c.panel_show_hide()}})},event_frame_lock:function(c){if(this.event.type!==null){return}c.preventDefault();var d=this.event_get_frame(c.target);if(d.grid_lock){d.grid_lock=false;$(d.id).find(".f-pin").removeClass("toggle");$(d.id).find(".f-header").removeClass("f-not-allowed");$(d.id).find(".f-title").removeClass("f-not-allowed");$(d.id).find(".f-resize").show();$(d.id).find(".f-close").show()}else{d.grid_lock=true;$(d.id).find(".f-pin").addClass("toggle");$(d.id).find(".f-header").addClass("f-not-allowed");$(d.id).find(".f-title").addClass("f-not-allowed");$(d.id).find(".f-resize").hide();$(d.id).find(".f-close").hide()}},event_panel_load:function(c){if(this.event.type!==null){return}this.panel_show_hide()},event_panel_active:function(c){if(this.event.type!==null){return}this.panel_active_disable()},event_panel_scroll:function(c){if(this.event.type!==null||!this.visible){return}c.preventDefault();var d=c.originalEvent.detail?c.originalEvent.detail:c.originalEvent.wheelDelta/-3;this.panel_scroll(d)},event_panel_scroll_up:function(c){if(this.event.type!==null){return}c.preventDefault();this.panel_scroll(-this.options.scroll)},event_panel_scroll_down:function(c){if(this.event.type!==null){return}c.preventDefault();this.panel_scroll(this.options.scroll)},event_get_frame:function(c){return this.frame_list["#"+$(c).closest(".frame").attr("id")]},frame_drag_start:function(d){this.frame_focus(d,true);var c=this.frame_screen(d);this.frame_resize(this.frame_shadow,c);this.frame_grid(this.frame_shadow,d.grid_location);d.grid_location=null;$(this.frame_shadow.id).show();$(".f-cover").show()},frame_drag_stop:function(d){this.frame_focus(d,false);var c=this.frame_screen(this.frame_shadow);this.frame_resize(d,c);this.frame_grid(d,this.frame_shadow.grid_location,true);this.frame_shadow.grid_location=null;$(this.frame_shadow.id).hide();$(".f-cover").hide();this.panel_animation_complete()},to_grid_coord:function(e,d){var c=(e=="width"||e=="height")?1:-1;if(e=="top"){d-=this.top}return parseInt((d+c*this.options.margin)/this.options.cell,10)},to_pixel_coord:function(e,f){var c=(e=="width"||e=="height")?1:-1;var d=(f*this.options.cell)-c*this.options.margin;if(e=="top"){d+=this.top}return d},to_grid:function(c){return{top:this.to_grid_coord("top",c.top),left:this.to_grid_coord("left",c.left),width:this.to_grid_coord("width",c.width),height:this.to_grid_coord("height",c.height)}},to_pixel:function(c){return{top:this.to_pixel_coord("top",c.top),left:this.to_pixel_coord("left",c.left),width:this.to_pixel_coord("width",c.width),height:this.to_pixel_coord("height",c.height)}},is_collision:function(e){function c(h,g){return !(h.left>g.left+g.width-1||h.left+h.width-1<g.left||h.top>g.top+g.height-1||h.top+h.height-1<g.top)}for(var d in this.frame_list){var f=this.frame_list[d];if(f.grid_location===null){continue}if(c(e,f.grid_location)){return true}}return false},location_rank:function(c){return(c.top*this.cols)+c.left},menu_refresh:function(){this.button_load.number(this.frame_counter);if(this.frame_counter==0){this.button_load.hide()}else{this.button_load.show()}if(this.top==this.options.top_min){$(".frame-scroll-up").hide()}else{$(".frame-scroll-up").show()}if(this.top==this.top_max){$(".frame-scroll-down").hide()}else{$(".frame-scroll-down").show()}},panel_animation_complete:function(){var c=this;$(".frame").promise().done(function(){c.panel_scroll(0,true)})},panel_refresh:function(c){this.cols=parseInt($(window).width()/this.options.cell,10)+1;this.frame_insert(null,null,c)},panel_scroll:function(h,c){var e=this.top-this.options.scroll*h;e=Math.max(e,this.top_max);e=Math.min(e,this.options.top_min);if(this.top!=e){for(var d in this.frame_list){var g=this.frame_list[d];if(g.grid_location!==null){var f={top:g.screen_location.top-(this.top-e),left:g.screen_location.left};this.frame_offset(g,f,c)}}this.top=e}this.menu_refresh()},panel_show_hide:function(){if(this.visible){this.visible=false;$(".frame").fadeOut("fast");this.button_load.icon("fa-eye-slash");this.button_load.untoggle();$(".frame-background").hide();$(".frame-menu").hide()}else{this.visible=true;$(".frame").fadeIn("fast");this.button_load.icon("fa-eye");this.button_load.toggle();$(this.frame_shadow.id).hide();$(".frame-background").show();this.panel_refresh()}},panel_active_disable:function(){if(this.active){this.active=false;this.button_active.untoggle();if(this.visible){this.panel_show_hide()}}else{this.active=true;this.button_active.toggle()}},frame_new:function(d){if(!this.active){if(d.location=="center"){var c=$(window.parent.document).find("iframe#galaxy_main");c.attr("src",d.content)}else{window.location=d.content}return}if(this.frame_counter>=this.options.frame_max){alert("You have reached the maximum number of allowed frames ("+this.options.frame_max+").");return}var e="#frame-"+(this.frame_counter_id++);if($(e).length!==0){alert("This frame already exists. This page might contain multiple frame managers.");return}this.top=this.options.top_min;$(this.el).append(this.template_frame(e.substring(1),d.title,d.type,d.content));var f={id:e,screen_location:{},grid_location:{},grid_rank:null,grid_lock:false};d.width=this.to_pixel_coord("width",this.options.frame.cols);d.height=this.to_pixel_coord("height",this.options.frame.rows);this.frame_z=parseInt($(f.id).css("z-index"));this.frame_list[e]=f;this.frame_counter++;this.frame_resize(f,{width:d.width,height:d.height});this.frame_insert(f,{top:0,left:0},true);if(!this.visible){this.panel_show_hide()}},frame_insert:function(j,c,e){var d=[];if(j){j.grid_location=null;d.push([j,this.location_rank(c)])}var g=null;for(g in this.frame_list){var h=this.frame_list[g];if(h.grid_location!==null&&!h.grid_lock){h.grid_location=null;d.push([h,h.grid_rank])}}d.sort(function(k,f){var m=k[1];var l=f[1];return m<l?-1:(m>l?1:0)});for(g=0;g<d.length;g++){this.frame_place(d[g][0],e)}this.top_max=0;for(var g in this.frame_list){var j=this.frame_list[g];if(j.grid_location!==null){this.top_max=Math.max(this.top_max,j.grid_location.top+j.grid_location.height)}}this.top_max=$(window).height()-this.top_max*this.options.cell-2*this.options.margin;this.top_max=Math.min(this.top_max,this.options.top_min);this.menu_refresh()},frame_place:function(k,d){k.grid_location=null;var h=this.to_grid(this.frame_screen(k));var c=false;for(var f=0;f<this.options.rows;f++){for(var e=0;e<Math.max(1,this.cols-h.width);e++){h.top=f;h.left=e;if(!this.is_collision(h)){c=true;break}}if(c){break}}if(c){this.frame_grid(k,h,d)}else{console.log("Grid dimensions exceeded.")}},frame_focus:function(e,c){var d=this.frame_z+(c?1:0);$(e.id).css("z-index",d)},frame_offset:function(f,e,d){f.screen_location.left=e.left;f.screen_location.top=e.top;if(d){this.frame_focus(f,true);var c=this;$(f.id).animate({top:e.top,left:e.left},"fast",function(){c.frame_focus(f,false)})}else{$(f.id).css({top:e.top,left:e.left})}},frame_resize:function(d,c){$(d.id).css({width:c.width,height:c.height});d.screen_location.width=c.width;d.screen_location.height=c.height},frame_grid:function(e,c,d){e.grid_location=c;this.frame_offset(e,this.to_pixel(c),d);e.grid_rank=this.location_rank(c)},frame_screen:function(d){var c=d.screen_location;return{top:c.top,left:c.left,width:c.width,height:c.height}},template:function(){return'<div class="galaxy-frame"></div>'},template_frame:function(f,e,c,d){if(!e){e=""}if(c=="url"){d='<iframe scrolling="auto" class="f-iframe" src="'+d+'"></iframe>'}return'<div id="'+f+'" class="frame corner"><div class="f-header corner"><span class="f-title">'+e+'</span><span class="f-icon f-pin fa fa-thumb-tack"></span><span class="f-icon f-close fa fa-trash-o"></span></div><div class="f-content">'+d+'<div class="f-cover"></div></div><span class="f-resize f-icon corner fa fa-resize-full"></span></div>'},template_shadow:function(c){return'<div id="'+c+'" class="frame-shadow corner"></div>'},template_background:function(){return'<div class="frame-background"></div>'},template_menu:function(){return'<div class="frame-scroll-up frame-menu fa fa-chevron-up fa-2x"></div><div class="frame-scroll-down frame-menu fa fa-chevron-down fa-2x"></div>'}});return{GalaxyFrameManager:a}}); \ No newline at end of file +define(["galaxy.master","libs/backbone/backbone-relational"],function(b){var a=Backbone.View.extend({el_main:"body",options:{frame:{cols:6,rows:3},rows:1000,cell:130,margin:5,scroll:5,top_min:40,frame_max:9},cols:0,top:0,top_max:0,frame_z:0,frame_counter:0,frame_counter_id:0,frame_list:[],frame_shadow:null,visible:false,active:false,button_active:null,button_load:null,initialize:function(d){var c=this;this.button_active=new b.GalaxyMasterIcon({icon:"fa-th",tooltip:"Enable/Disable Scratchbook",on_click:function(f){c._event_panel_active(f)},on_unload:function(){if(c.frame_counter>0){return"You opened "+c.frame_counter+" frame(s) which will be lost."}}});Galaxy.master.append(this.button_active);this.button_load=new b.GalaxyMasterIcon({icon:"fa-eye",tooltip:"Show/Hide Scratchbook",on_click:function(f){c._event_panel_load(f)},with_number:true});Galaxy.master.append(this.button_load);if(d){this.options=_.defaults(d,this.options)}this.top=this.top_max=this.options.top_min;this.setElement(this._template());$(this.el).append(this._template_background());$(this.el).append(this._template_menu());$(this.el_main).append($(this.el));var e="#frame-shadow";$(this.el).append(this._template_shadow(e.substring(1)));this.frame_shadow={id:e,screen_location:{},grid_location:{},grid_rank:null,grid_lock:false};this._frame_resize(this.frame_shadow,{width:0,height:0});this.frame_list[e]=this.frame_shadow;this._panel_refresh();var c=this;$(window).resize(function(){if(c.visible){c._panel_refresh()}})},frame_new:function(d){var g={title:"",content:null,target:"",type:null,scratchbook:false};if(d){d=_.defaults(d,g)}else{d=g}if(!d.content){return}if(d.target=="_blank"){window.open(d.content);return}if(d.target=="_top"||d.target=="_parent"||d.target=="_self"){window.location=d.content;return}if(!this.active){var f=$(window.parent.document).find("#galaxy_main");if(d.target=="galaxy_main"||d.target=="center"){if(f.length==0){var c=d.content;if(c.indexOf("?")==-1){c+="?"}else{c+="&"}c+="use_panels=True";window.location=c}else{f.attr("src",d.content)}}else{window.location=d.content}return}if(this.frame_counter>=this.options.frame_max){alert("You have reached the maximum number of allowed frames ("+this.options.frame_max+").");return}var e="#frame-"+(this.frame_counter_id++);if($(e).length!==0){alert("This frame already exists. This page might contain multiple frame managers.");return}this.top=this.options.top_min;$(this.el).append(this._template_frame(e.substring(1),d.title,d.type,d.content));var h={id:e,screen_location:{},grid_location:{},grid_rank:null,grid_lock:false};d.width=this._to_pixel_coord("width",this.options.frame.cols);d.height=this._to_pixel_coord("height",this.options.frame.rows);this.frame_z=parseInt($(h.id).css("z-index"));this.frame_list[e]=h;this.frame_counter++;this._frame_resize(h,{width:d.width,height:d.height});this._frame_insert(h,{top:0,left:0},true);if(!this.visible){this._panel_show_hide()}},event:{type:null,target:null,xy:null},events:{mousemove:"_event_frame_mouse_move",mouseup:"_event_frame_mouse_up",mouseleave:"_event_frame_mouse_up",mousewheel:"_event_panel_scroll",DOMMouseScroll:"_event_panel_scroll","mousedown .frame":"_event_frame_mouse_down","mousedown .frame-background":"_event_panel_load","mousedown .frame-scroll-up":"_event_panel_scroll_up","mousedown .frame-scroll-down":"_event_panel_scroll_down","mousedown .f-close":"_event_frame_close","mousedown .f-pin":"_event_frame_lock"},_event_frame_mouse_down:function(c){if(this.event.type!==null){return}if($(c.target).hasClass("f-header")||$(c.target).hasClass("f-title")){this.event.type="drag"}if($(c.target).hasClass("f-resize")){this.event.type="resize"}if(this.event.type===null){return}c.preventDefault();this.event.target=this._frame_identify(c.target);if(this.event.target.grid_lock){this.event.type=null;return}this.event.xy={x:c.originalEvent.pageX,y:c.originalEvent.pageY};this._frame_drag_start(this.event.target)},_event_frame_mouse_move:function(i){if(this.event.type!="drag"&&this.event.type!="resize"){return}var g={x:i.originalEvent.pageX,y:i.originalEvent.pageY};var d={x:g.x-this.event.xy.x,y:g.y-this.event.xy.y};this.event.xy=g;var h=this._frame_screen(this.event.target);if(this.event.type=="resize"){h.width+=d.x;h.height+=d.y;var f=this.options.cell-this.options.margin-1;h.width=Math.max(h.width,f);h.height=Math.max(h.height,f);this._frame_resize(this.event.target,h);h.width=this._to_grid_coord("width",h.width)+1;h.height=this._to_grid_coord("height",h.height)+1;h.width=this._to_pixel_coord("width",h.width);h.height=this._to_pixel_coord("height",h.height);this._frame_resize(this.frame_shadow,h);this._frame_insert(this.frame_shadow,{top:this._to_grid_coord("top",h.top),left:this._to_grid_coord("left",h.left)})}if(this.event.type=="drag"){h.left+=d.x;h.top+=d.y;this._frame_offset(this.event.target,h);var c={top:this._to_grid_coord("top",h.top),left:this._to_grid_coord("left",h.left)};if(c.left!==0){c.left++}this._frame_insert(this.frame_shadow,c)}},_event_frame_mouse_up:function(c){if(this.event.type!="drag"&&this.event.type!="resize"){return}this._frame_drag_stop(this.event.target);this.event.type=null},_event_frame_close:function(d){if(this.event.type!==null){return}d.preventDefault();var f=this._frame_identify(d.target);var c=this;$(f.id).fadeOut("fast",function(){$(f.id).remove();delete c.frame_list[f.id];c.frame_counter--;c._panel_refresh(true);c._panel_animation_complete();if(c.visible&&c.frame_counter==0){c._panel_show_hide()}})},_event_frame_lock:function(c){if(this.event.type!==null){return}c.preventDefault();var d=this._frame_identify(c.target);if(d.grid_lock){d.grid_lock=false;$(d.id).find(".f-pin").removeClass("toggle");$(d.id).find(".f-header").removeClass("f-not-allowed");$(d.id).find(".f-title").removeClass("f-not-allowed");$(d.id).find(".f-resize").show();$(d.id).find(".f-close").show()}else{d.grid_lock=true;$(d.id).find(".f-pin").addClass("toggle");$(d.id).find(".f-header").addClass("f-not-allowed");$(d.id).find(".f-title").addClass("f-not-allowed");$(d.id).find(".f-resize").hide();$(d.id).find(".f-close").hide()}},_event_panel_load:function(c){if(this.event.type!==null){return}this._panel_show_hide()},_event_panel_active:function(c){if(this.event.type!==null){return}this._panel_active_disable()},_event_panel_scroll:function(c){if(this.event.type!==null||!this.visible){return}c.preventDefault();var d=c.originalEvent.detail?c.originalEvent.detail:c.originalEvent.wheelDelta/-3;this._panel_scroll(d)},_event_panel_scroll_up:function(c){if(this.event.type!==null){return}c.preventDefault();this._panel_scroll(-this.options.scroll)},_event_panel_scroll_down:function(c){if(this.event.type!==null){return}c.preventDefault();this._panel_scroll(this.options.scroll)},_frame_identify:function(c){return this.frame_list["#"+$(c).closest(".frame").attr("id")]},_frame_drag_start:function(d){this._frame_focus(d,true);var c=this._frame_screen(d);this._frame_resize(this.frame_shadow,c);this._frame_grid(this.frame_shadow,d.grid_location);d.grid_location=null;$(this.frame_shadow.id).show();$(".f-cover").show()},_frame_drag_stop:function(d){this._frame_focus(d,false);var c=this._frame_screen(this.frame_shadow);this._frame_resize(d,c);this._frame_grid(d,this.frame_shadow.grid_location,true);this.frame_shadow.grid_location=null;$(this.frame_shadow.id).hide();$(".f-cover").hide();this._panel_animation_complete()},_to_grid_coord:function(e,d){var c=(e=="width"||e=="height")?1:-1;if(e=="top"){d-=this.top}return parseInt((d+c*this.options.margin)/this.options.cell,10)},_to_pixel_coord:function(e,f){var c=(e=="width"||e=="height")?1:-1;var d=(f*this.options.cell)-c*this.options.margin;if(e=="top"){d+=this.top}return d},_to_grid:function(c){return{top:this._to_grid_coord("top",c.top),left:this._to_grid_coord("left",c.left),width:this._to_grid_coord("width",c.width),height:this._to_grid_coord("height",c.height)}},_to_pixel:function(c){return{top:this._to_pixel_coord("top",c.top),left:this._to_pixel_coord("left",c.left),width:this._to_pixel_coord("width",c.width),height:this._to_pixel_coord("height",c.height)}},_is_collision:function(e){function c(h,g){return !(h.left>g.left+g.width-1||h.left+h.width-1<g.left||h.top>g.top+g.height-1||h.top+h.height-1<g.top)}for(var d in this.frame_list){var f=this.frame_list[d];if(f.grid_location===null){continue}if(c(e,f.grid_location)){return true}}return false},_location_rank:function(c){return(c.top*this.cols)+c.left},_menu_refresh:function(){this.button_load.number(this.frame_counter);if(this.frame_counter==0){this.button_load.hide()}else{this.button_load.show()}if(this.top==this.options.top_min){$(".frame-scroll-up").hide()}else{$(".frame-scroll-up").show()}if(this.top==this.top_max){$(".frame-scroll-down").hide()}else{$(".frame-scroll-down").show()}},_panel_animation_complete:function(){var c=this;$(".frame").promise().done(function(){c._panel_scroll(0,true)})},_panel_refresh:function(c){this.cols=parseInt($(window).width()/this.options.cell,10)+1;this._frame_insert(null,null,c)},_panel_scroll:function(h,c){var e=this.top-this.options.scroll*h;e=Math.max(e,this.top_max);e=Math.min(e,this.options.top_min);if(this.top!=e){for(var d in this.frame_list){var g=this.frame_list[d];if(g.grid_location!==null){var f={top:g.screen_location.top-(this.top-e),left:g.screen_location.left};this._frame_offset(g,f,c)}}this.top=e}this._menu_refresh()},_panel_show_hide:function(){if(this.visible){this.visible=false;$(".frame").fadeOut("fast");this.button_load.icon("fa-eye-slash");this.button_load.untoggle();$(".frame-background").hide();$(".frame-menu").hide()}else{this.visible=true;$(".frame").fadeIn("fast");this.button_load.icon("fa-eye");this.button_load.toggle();$(this.frame_shadow.id).hide();$(".frame-background").show();this._panel_refresh()}},_panel_active_disable:function(){if(this.active){this.active=false;this.button_active.untoggle();if(this.visible){this._panel_show_hide()}}else{this.active=true;this.button_active.toggle()}},_frame_insert:function(j,c,e){var d=[];if(j){j.grid_location=null;d.push([j,this._location_rank(c)])}var g=null;for(g in this.frame_list){var h=this.frame_list[g];if(h.grid_location!==null&&!h.grid_lock){h.grid_location=null;d.push([h,h.grid_rank])}}d.sort(function(k,f){var m=k[1];var l=f[1];return m<l?-1:(m>l?1:0)});for(g=0;g<d.length;g++){this._frame_place(d[g][0],e)}this.top_max=0;for(var g in this.frame_list){var j=this.frame_list[g];if(j.grid_location!==null){this.top_max=Math.max(this.top_max,j.grid_location.top+j.grid_location.height)}}this.top_max=$(window).height()-this.top_max*this.options.cell-2*this.options.margin;this.top_max=Math.min(this.top_max,this.options.top_min);this._menu_refresh()},_frame_place:function(k,d){k.grid_location=null;var h=this._to_grid(this._frame_screen(k));var c=false;for(var f=0;f<this.options.rows;f++){for(var e=0;e<Math.max(1,this.cols-h.width);e++){h.top=f;h.left=e;if(!this._is_collision(h)){c=true;break}}if(c){break}}if(c){this._frame_grid(k,h,d)}else{console.log("Grid dimensions exceeded.")}},_frame_focus:function(e,c){var d=this.frame_z+(c?1:0);$(e.id).css("z-index",d)},_frame_offset:function(f,e,d){f.screen_location.left=e.left;f.screen_location.top=e.top;if(d){this._frame_focus(f,true);var c=this;$(f.id).animate({top:e.top,left:e.left},"fast",function(){c._frame_focus(f,false)})}else{$(f.id).css({top:e.top,left:e.left})}},_frame_resize:function(d,c){$(d.id).css({width:c.width,height:c.height});d.screen_location.width=c.width;d.screen_location.height=c.height},_frame_grid:function(e,c,d){e.grid_location=c;this._frame_offset(e,this._to_pixel(c),d);e.grid_rank=this._location_rank(c)},_frame_screen:function(d){var c=d.screen_location;return{top:c.top,left:c.left,width:c.width,height:c.height}},_template:function(){return'<div class="galaxy-frame"></div>'},_template_frame:function(f,e,c,d){if(!e){e=""}if(c=="url"){d='<iframe scrolling="auto" class="f-iframe" src="'+d+'"></iframe>'}return'<div id="'+f+'" class="frame corner"><div class="f-header corner"><span class="f-title">'+e+'</span><span class="f-icon f-pin fa fa-thumb-tack"></span><span class="f-icon f-close fa fa-trash-o"></span></div><div class="f-content">'+d+'<div class="f-cover"></div></div><span class="f-resize f-icon corner fa fa-resize-full"></span></div>'},_template_shadow:function(c){return'<div id="'+c+'" class="frame-shadow corner"></div>'},_template_background:function(){return'<div class="frame-background"></div>'},_template_menu:function(){return'<div class="frame-scroll-up frame-menu fa fa-chevron-up fa-2x"></div><div class="frame-scroll-down frame-menu fa fa-chevron-down fa-2x"></div>'}});return{GalaxyFrameManager:a}}); \ No newline at end of file diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/packed/galaxy.master.js --- a/static/scripts/packed/galaxy.master.js +++ b/static/scripts/packed/galaxy.master.js @@ -1,1 +1,1 @@ -define(["libs/backbone/backbone-relational"],function(){var a=Backbone.View.extend({el_master:"#masthead",list:[],initialize:function(d){this.setElement($(this.template()));$(this.el_master).append($(this.el));var c=this;window.onbeforeunload=function(){var f="";for(key in c.list){if(c.list[key].options.on_unload){var e=c.list[key].options.on_unload();if(e){f+=e+" "}}}if(f!=""){return f}}},events:{mousedown:function(c){c.preventDefault()}},append:function(c){$(this.el).append($(c.el));this.list.push(c)},prepend:function(c){$(this.el).prepend($(c.el));this.list.push(c)},template:function(){return'<div class="iconbar"></div>'}});var b=Backbone.View.extend({options:{id:"galaxy-icon",icon:"fa-cog",tooltip:"galaxy-icon",with_number:false,on_click:function(){alert("clicked")},on_unload:null,visible:true},initialize:function(d){if(d){this.options=_.defaults(d,this.options)}this.setElement($(this.template(this.options)));var c=this;$(this.el).find(".icon").tooltip({title:this.options.tooltip}).on("click",c.options.on_click);if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},icon:function(c){$(this.el).find(".icon").removeClass(this.options.icon).addClass(c);this.options.icon=c},toggle:function(){$(this.el).addClass("toggle")},untoggle:function(){$(this.el).removeClass("toggle")},number:function(c){$(this.el).find(".number").text(c)},template:function(d){var c="<div id="+d.id+' class="symbol"><div class="icon fa fa-2x '+d.icon+'"></div>';if(d.with_number){c+='<div class="number"></div>'}c+="</div>";return c}});return{GalaxyMaster:a,GalaxyMasterIcon:b}}); \ No newline at end of file +define(["utils/galaxy.utils","libs/backbone/backbone-relational"],function(c){var a=Backbone.View.extend({el_master:"#everything",options:null,list:{},itemLast:null,itemCounter:0,$background:null,backgroundVisible:false,initialize:function(f){this.options=f;$("body").off();this.setElement($(this._template(f)));$(this.el_master).append($(this.el));this.$background=$(this.el).find("#master-background");var e=this;window.onbeforeunload=function(){var h="";for(key in e.list){if(e.list[key].options.on_unload){var g=e.list[key].options.on_unload();if(g){h+=g+" "}}}if(h!=""){return h}}},events:{click:"_eventRefresh",mousedown:function(f){f.preventDefault()}},append:function(e){return this._add(e,true)},prepend:function(e){return this._add(e,false)},_add:function(g,f){var e=$(this.el).find("#"+g.masterLocation);if(e){var h="master-item-"+this.itemCounter++;var i=$(g.el);i.attr("id",h);i.addClass("master-item");if(f){e.append(i)}else{e.prepend(i)}this.list[h]=g;return h}return null},_eventRefresh:function(h){var i=$(h.target).closest(".master-item");if(i.length){i=i.attr("id")}if(this.itemLast&&this.itemLast!=i){var g=this.list[this.itemLast];if(g){if(g.masterReset){g.masterReset()}}}var f=false;if(i){var g=this.list[i];if(g){if(g.masterReset){if(this.itemLast==i){f=this.backgroundVisible?false:true}else{f=true}}}}if(f){this.$background.show()}else{this.$background.hide()}this.backgroundVisible=f;this.itemLast=i},_templateItem:function(e){return'<div id="'+e+'" class="master-item"></div>'},_template:function(e){return'<div><div id="masthead" class="navbar navbar-fixed-top navbar-inverse"><div style="position: relative; right: -50%; float: left;"><div id="navbar" style="display: block; position: relative; right: 50%;"></div></div><div class="navbar-brand"><a href="'+e.logo_url+'"><img border="0" src="'+galaxy_config.root+'static/images/galaxyIcon_noText.png"><span id="brand"> Galaxy '+e.brand+'</span></a></div><div class="quota-meter-container"></div><div id="iconbar" class="iconbar"></div></div><div id="master-background" style="display: none; position: absolute; top: 33px; width: 100%; height: 100%; z-index: 1010"></div></div>'}});var d=Backbone.View.extend({options:{id:"galaxy-icon",icon:"fa-cog",tooltip:"galaxy-icon",with_number:false,on_click:function(){alert("clicked")},on_unload:null,visible:true},masterLocation:"iconbar",initialize:function(f){if(f){this.options=_.defaults(f,this.options)}this.setElement($(this._template(this.options)));var e=this;$(this.el).find(".icon").tooltip({title:this.options.tooltip}).on("mouseup",e.options.on_click);if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},icon:function(e){$(this.el).find(".icon").removeClass(this.options.icon).addClass(e);this.options.icon=e},toggle:function(){$(this.el).addClass("toggle")},untoggle:function(){$(this.el).removeClass("toggle")},number:function(e){$(this.el).find(".number").text(e)},_template:function(f){var e="<div id="+f.id+' class="symbol"><div class="icon fa fa-2x '+f.icon+'"></div>';if(f.with_number){e+='<div class="number"></div>'}e+="</div>";return e}});var b=Backbone.View.extend({options:{id:"",title:"Title",target:"_parent",content:"",type:"url",scratchbook:false,on_unload:null,visible:true},masterLocation:"navbar",$menu:null,menuVisible:false,events:{"click .head":"_eventClickHead"},initialize:function(e){if(e){this.options=_.defaults(e,this.options)}if(this.options.content&&this.options.content.indexOf("//")===-1){this.options.content=galaxy_config.root+this.options.content}this.setElement($(this._template(this.options)));if(!this.options.visible){this.hide()}},show:function(){$(this.el).css({visibility:"visible"})},hide:function(){$(this.el).css({visibility:"hidden"})},addMenu:function(g){var h={title:"Title",content:"",type:"url",target:"_parent",scratchbook:false,divider:false};if(g){h=_.defaults(g,h)}if(h.content&&h.content.indexOf("//")===-1){h.content=galaxy_config.root+h.content}if(!this.$menu){$(this.el).find(".root").append(this._templateMenu());$(this.el).find(".symbol").addClass("caret");this.$menu=$(this.el).find(".menu")}var f=$(this._templateMenuItem(h));this.$menu.append(f);var e=this;f.on("click",function(i){i.preventDefault();e._hideMenu();if(e.options.target==="_blank"){return true}Galaxy.frame_manager.frame_new(g)});if(h.divider){this.$menu.append($(this._templateDivider()))}},masterReset:function(){this._hideMenu()},_hideMenu:function(){if(this.$menu&&this.menuVisible){this.$menu.hide();this.menuVisible=false}},_eventClickHead:function(f){f.preventDefault();if(this.$menu){if(!this.menuVisible){this.$menu.show();this.menuVisible=true}else{this.$menu.hide();this.menuVisible=false}}else{Galaxy.frame_manager.frame_new(this.options)}},_templateMenuItem:function(e){return'<li><a href="'+e.content+'" target="'+e.target+'">'+e.title+"</a></li>"},_templateMenu:function(){return'<ul class="menu dropdown-menu"></ul>'},_templateDivider:function(){return'<li class="divider"></li>'},_template:function(f){var e='<ul class="nav navbar-nav" border="0" cellspacing="0"><li class="root dropdown" style=""><a class="head dropdown-toggle" data-toggle="dropdown" target="'+f.target+'" href="'+f.content+'">'+f.title+'<b class="symbol"></b></a></li></ul>';return e}});return{GalaxyMaster:a,GalaxyMasterTab:b,GalaxyMasterIcon:d}}); \ No newline at end of file diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/packed/mvc/dataset/hda-base.js --- a/static/scripts/packed/mvc/dataset/hda-base.js +++ b/static/scripts/packed/mvc/dataset/hda-base.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model"],function(b){var a=Backbone.View.extend(LoggableMixin).extend({tagName:"div",className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(c){if(c.logger){this.logger=this.model.logger=c.logger}this.log(this+".initialize:",c);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.expanded=c.expanded||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(d,c){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(e){e=(e===undefined)?(true):(e);var c=this;this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var d=$(a.templates.skeleton(this.model.toJSON()));d.find(".dataset-primary-actions").append(this._render_titleButtons());d.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(d);if(e){$(c).queue(function(f){this.$el.fadeOut(c.fxSpeed,f)})}$(c).queue(function(f){this.$el.empty().attr("class",c.className).addClass("state-"+c.model.get("state")).append(d.children());f()});if(e){$(c).queue(function(f){this.$el.fadeIn(c.fxSpeed,f)})}$(c).queue(function(f){this.trigger("rendered",c);if(this.model.inReadyState()){this.trigger("rendered:ready",c)}f()});return this},_setUpBehaviors:function(c){c=c||this.$el;make_popup_menus(c);c.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===b.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===b.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===b.HistoryDatasetAssociation.STATES.NEW)||(!this.model.get("accessible"))){return null}var d={icon_class:"display",target:"galaxy_main"};if(this.model.get("purged")){d.disabled=true;d.title=_l("Cannot display datasets removed from disk")}else{if(this.model.get("state")===b.HistoryDatasetAssociation.STATES.UPLOAD){d.disabled=true;d.title=_l("This dataset must finish uploading before it can be viewed")}else{d.title=_l("View data");d.href=this.urls.display;var c=this;d.onclick=function(){Galaxy.frame_manager.frame_new({title:"Data Viewer: "+c.model.get("name"),type:"url",location:"center",content:c.urls.display})}}}d.faIcon="fa-eye";return faIconButton(d)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var d=this.urls,e=this.model.get("meta_files");if(_.isEmpty(e)){return $(['<a href="'+d.download+'" title="'+_l("Download")+'" class="icon-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var f="dataset-"+this.model.get("id")+"-popup",c=['<div popupmenu="'+f+'">','<a href="'+d.download+'">',_l("Download Dataset"),"</a>","<a>"+_l("Additional Files")+"</a>",_.map(e,function(g){return['<a class="action-button" href="',d.meta_download+g.file_type,'">',_l("Download")," ",g.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+d.download+'" title="'+_l("Download")+'" class="icon-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+f+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(c)},_render_showParamsButton:function(){return faIconButton({title:_l("View details"),href:this.urls.show_params,target:"galaxy_main",faIcon:"fa-info-circle"})},_render_body:function(){var d=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),c=this["_render_body_"+this.model.get("state")];if(_.isFunction(c)){d=c.call(this)}if(this.expanded){d.show()}return d},_render_stateBodyHelper:function(c,f){f=f||[];var d=this,e=$(a.templates.body(_.extend(this.model.toJSON(),{body:c})));e.find(".dataset-actions .left").append(_.map(f,function(g){return g.call(d)}));return e},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+_l("This is a new dataset and not all of its data are available yet")+"</div>")},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+_l("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+_l("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+_l("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+_l("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+_l("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+_l("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+_l('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var c=_l("An error occurred with this dataset")+": <i>"+$.trim(this.model.get("misc_info"))+"</i>";if(!this.model.get("purged")){c="<div>"+this.model.get("misc_blurb")+"</div>"+c}return this._render_stateBodyHelper(c,this.defaultPrimaryActionButtonRenderers.concat([this._render_downloadButton]))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+_l("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var c=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(_l("An error occurred setting the metadata for this dataset"))),d=this._render_body_ok();d.prepend(c);return d},_render_body_ok:function(){var c=this,e=$(a.templates.body(this.model.toJSON())),d=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);e.find(".dataset-actions .left").append(_.map(d,function(f){return f.call(c)}));if(this.model.isDeletedOrPurged()){return e}return e},events:{"click .dataset-title-bar":"toggleBodyVisibility"},toggleBodyVisibility:function(d,c){var e=this.$el.find(".dataset-body");c=(c===undefined)?(!e.is(":visible")):(c);if(c){this.expandBody()}else{this.collapseBody()}},expandBody:function(){var c=this;function d(){c.render(false).$el.children(".dataset-body").slideDown(c.fxSpeed,function(){c.expanded=true;c.trigger("body-expanded",c.model.get("id"))})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(e){d()})}else{d()}},collapseBody:function(){var c=this;this.$el.children(".dataset-body").slideUp(c.fxSpeed,function(){c.expanded=false;c.trigger("body-collapsed",c.model.get("id"))})},remove:function(d){var c=this;this.$el.fadeOut(c.fxSpeed,function(){c.$el.remove();c.off();if(d){d()}})},toString:function(){var c=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+c+")"}});a.templates={skeleton:Handlebars.templates["template-hda-skeleton"],body:Handlebars.templates["template-hda-body"]};return{HDABaseView:a}}); \ No newline at end of file +define(["mvc/dataset/hda-model"],function(b){var a=Backbone.View.extend(LoggableMixin).extend({tagName:"div",className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(c){if(c.logger){this.logger=this.model.logger=c.logger}this.log(this+".initialize:",c);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.expanded=c.expanded||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(d,c){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(e){e=(e===undefined)?(true):(e);var c=this;this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var d=$(a.templates.skeleton(this.model.toJSON()));d.find(".dataset-primary-actions").append(this._render_titleButtons());d.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(d);if(e){$(c).queue(function(f){this.$el.fadeOut(c.fxSpeed,f)})}$(c).queue(function(f){this.$el.empty().attr("class",c.className).addClass("state-"+c.model.get("state")).append(d.children());f()});if(e){$(c).queue(function(f){this.$el.fadeIn(c.fxSpeed,f)})}$(c).queue(function(f){this.trigger("rendered",c);if(this.model.inReadyState()){this.trigger("rendered:ready",c)}f()});return this},_setUpBehaviors:function(c){c=c||this.$el;make_popup_menus(c);c.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===b.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===b.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===b.HistoryDatasetAssociation.STATES.NEW)||(!this.model.get("accessible"))){return null}var d={icon_class:"display",target:"galaxy_main"};if(this.model.get("purged")){d.disabled=true;d.title=_l("Cannot display datasets removed from disk")}else{if(this.model.get("state")===b.HistoryDatasetAssociation.STATES.UPLOAD){d.disabled=true;d.title=_l("This dataset must finish uploading before it can be viewed")}else{d.title=_l("View data");d.href=this.urls.display;var c=this;d.onclick=function(){Galaxy.frame_manager.frame_new({title:"Data Viewer: "+c.model.get("name"),type:"url",target:"galaxy_main",content:c.urls.display})}}}d.faIcon="fa-eye";return faIconButton(d)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var d=this.urls,e=this.model.get("meta_files");if(_.isEmpty(e)){return $(['<a href="'+d.download+'" title="'+_l("Download")+'" class="icon-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var f="dataset-"+this.model.get("id")+"-popup",c=['<div popupmenu="'+f+'">','<a href="'+d.download+'">',_l("Download Dataset"),"</a>","<a>"+_l("Additional Files")+"</a>",_.map(e,function(g){return['<a class="action-button" href="',d.meta_download+g.file_type,'">',_l("Download")," ",g.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+d.download+'" title="'+_l("Download")+'" class="icon-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+f+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(c)},_render_showParamsButton:function(){return faIconButton({title:_l("View details"),href:this.urls.show_params,target:"galaxy_main",faIcon:"fa-info-circle"})},_render_body:function(){var d=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),c=this["_render_body_"+this.model.get("state")];if(_.isFunction(c)){d=c.call(this)}if(this.expanded){d.show()}return d},_render_stateBodyHelper:function(c,f){f=f||[];var d=this,e=$(a.templates.body(_.extend(this.model.toJSON(),{body:c})));e.find(".dataset-actions .left").append(_.map(f,function(g){return g.call(d)}));return e},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+_l("This is a new dataset and not all of its data are available yet")+"</div>")},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+_l("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+_l("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+_l("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+_l("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+_l("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+_l("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+_l('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var c=_l("An error occurred with this dataset")+": <i>"+$.trim(this.model.get("misc_info"))+"</i>";if(!this.model.get("purged")){c="<div>"+this.model.get("misc_blurb")+"</div>"+c}return this._render_stateBodyHelper(c,this.defaultPrimaryActionButtonRenderers.concat([this._render_downloadButton]))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+_l("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var c=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(_l("An error occurred setting the metadata for this dataset"))),d=this._render_body_ok();d.prepend(c);return d},_render_body_ok:function(){var c=this,e=$(a.templates.body(this.model.toJSON())),d=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);e.find(".dataset-actions .left").append(_.map(d,function(f){return f.call(c)}));if(this.model.isDeletedOrPurged()){return e}return e},events:{"click .dataset-title-bar":"toggleBodyVisibility"},toggleBodyVisibility:function(d,c){var e=this.$el.find(".dataset-body");c=(c===undefined)?(!e.is(":visible")):(c);if(c){this.expandBody()}else{this.collapseBody()}},expandBody:function(){var c=this;function d(){c.render(false).$el.children(".dataset-body").slideDown(c.fxSpeed,function(){c.expanded=true;c.trigger("body-expanded",c.model.get("id"))})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(e){d()})}else{d()}},collapseBody:function(){var c=this;this.$el.children(".dataset-body").slideUp(c.fxSpeed,function(){c.expanded=false;c.trigger("body-collapsed",c.model.get("id"))})},remove:function(d){var c=this;this.$el.fadeOut(c.fxSpeed,function(){c.$el.remove();c.off();if(d){d()}})},toString:function(){var c=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+c+")"}});a.templates={skeleton:Handlebars.templates["template-hda-skeleton"],body:Handlebars.templates["template-hda-body"]};return{HDABaseView:a}}); \ No newline at end of file diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/scripts/packed/mvc/dataset/hda-edit.js --- a/static/scripts/packed/mvc/dataset/hda-edit.js +++ b/static/scripts/packed/mvc/dataset/hda-edit.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/dataset/hda-base"],function(d,a){var f=a.HDABaseView.extend(LoggableMixin).extend({initialize:function(g){a.HDABaseView.prototype.initialize.call(this,g);this.hasUser=g.hasUser;this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton,this._render_rerunButton]},_render_titleButtons:function(){return a.HDABaseView.prototype._render_titleButtons.call(this).concat([this._render_editButton(),this._render_deleteButton()])},_render_editButton:function(){if((this.model.get("state")===d.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var i=this.model.get("purged"),g=this.model.get("deleted"),h={title:_l("Edit Attributes"),href:this.urls.edit,target:"galaxy_main",icon_class:"edit"};if(g||i){h.enabled=false;if(i){h.title=_l("Cannot edit attributes of datasets removed from disk")}else{if(g){h.title=_l("Undelete dataset to edit attributes")}}}else{if(this.model.get("state")===d.HistoryDatasetAssociation.STATES.UPLOAD){h.disabled=true;h.title=_l("This dataset must finish uploading before it can be edited")}}h.faIcon="fa-pencil";return faIconButton(h)},_render_deleteButton:function(){if((this.model.get("state")===d.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var g=this,h=g.urls["delete"],i={title:_l("Delete"),href:h,icon_class:"delete",onclick:function(){g.$el.find(".menu-button.delete").trigger("mouseout");g.model["delete"]()}};if(this.model.get("deleted")||this.model.get("purged")){i={title:_l("Dataset is already deleted"),icon_class:"delete",enabled:false}}i.faIcon="fa-times";return faIconButton(i)},_render_errButton:function(){if(this.model.get("state")!==d.HistoryDatasetAssociation.STATES.ERROR){return null}return faIconButton({title:_l("View or report this error"),href:this.urls.report_error,target:"galaxy_main",faIcon:"fa-bug"})},_render_rerunButton:function(){return faIconButton({title:_l("Run this job again"),href:this.urls.rerun,target:"galaxy_main",faIcon:"fa-refresh"})},_render_visualizationsButton:function(){var g=this.model.get("visualizations");if((!this.model.hasData())||(_.isEmpty(g))){return null}if(_.isObject(g[0])){return this._render_visualizationsFrameworkButton(g)}if(!this.urls.visualization){return null}var i=this.model.get("dbkey"),l=this.urls.visualization,j={},m={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(i){m.dbkey=i}var h=faIconButton({title:_l("Visualize"),href:this.urls.visualization,faIcon:"fa-bar-chart-o"});function k(n){switch(n){case"trackster":return b(l,m,i);case"scatterplot":return e(l,m);default:return function(){Galaxy.frame_manager.frame_new({title:"Visualization",type:"url",content:l+"/"+n+"?"+$.param(m)})}}}if(g.length===1){h.attr("title",g[0]);h.click(k(g[0]))}else{_.each(g,function(o){var n=o.charAt(0).toUpperCase()+o.slice(1);j[_l(n)]=k(o)});make_popupmenu(h,j)}return h},_render_visualizationsFrameworkButton:function(g){if(!(this.model.hasData())||!(g&&!_.isEmpty(g))){return null}var i=faIconButton({title:_l("Visualize"),faIcon:"fa-bar-chart-o"});i.addClass("visualize-icon");if(_.keys(g).length===1){i.attr("title",_.keys(g)[0]);i.attr("href",_.values(g)[0])}else{var j=[];_.each(g,function(k){j.push(k)});var h=new PopupMenu(i,j)}return i},_render_tagButton:function(){if(!this.hasUser){return null}return faIconButton({title:_l("Edit dataset tags"),classes:"dataset-tag-btn",faIcon:"fa-tags"})},_render_annotateButton:function(){if(!this.hasUser){return null}return faIconButton({title:_l("Edit dataset annotation"),classes:"dataset-annotate-btn",faIcon:"fa-comment"})},_render_body_failed_metadata:function(){var h=$("<a/>").attr({href:this.urls.edit,target:"galaxy_main"}).text(_l("set it manually or retry auto-detection")),g=$("<span/>").text(". "+_l("You may be able to")+" ").append(h),i=a.HDABaseView.prototype._render_body_failed_metadata.call(this);i.find(".warningmessagesmall strong").append(g);return i},_render_body_error:function(){var g=a.HDABaseView.prototype._render_body_error.call(this);g.find(".dataset-actions .left").prepend(this._render_errButton());return g},_render_body_ok:function(){var g=a.HDABaseView.prototype._render_body_ok.call(this);if(this.model.isDeletedOrPurged()){return g}this.makeDbkeyEditLink(g);g.find(".dataset-actions .left").append(this._render_visualizationsButton());g.find(".dataset-actions .right").append([this._render_tagButton(),this._render_annotateButton()]);this.tagsEditor=new TagsEditor({model:this.model,el:g.find(".tags-display")}).render();return g},makeDbkeyEditLink:function(g){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){g.find(".dataset-dbkey .value").replaceWith($('<a target="galaxy_main">?</a>').attr("href",this.urls.edit))}},events:{"click .dataset-title-bar":"toggleBodyVisibility","click .dataset-undelete":function(g){this.model.undelete();return false},"click .dataset-unhide":function(g){this.model.unhide();return false},"click .dataset-purge":"confirmPurge","click .dataset-tag-btn":"displayTags","click .dataset-annotate-btn":"loadAndDisplayAnnotation"},confirmPurge:function c(g){this.model.purge();return false},displayTags:function(g){this.$el.find(".tags-display").slideToggle(this.fxSpeed);return false},loadAndDisplayAnnotation:function(j){this.log(this+".loadAndDisplayAnnotation",j);var i=this,h=this.$el.find(".annotation-display"),g=h.find(".annotation");if(h.is(":hidden")){if(!jQuery.trim(g.html())){var k=$.ajax(this.urls.annotation.get);k.fail(function(n,l,m){i.log("Annotation failed",n,l,m);i.trigger("error",i,n,{},_l("Annotation failed"))});k.done(function(l){l=l||"<em>"+_l("Describe or add notes to dataset")+"</em>";g.html(l);h.find("[title]").tooltip();g.make_text_editable({use_textarea:true,on_finish:function(m){g.text(m);i.model.save({annotation:m},{silent:true}).fail(function(){g.text(i.model.previous("annotation"))})}});h.slideDown(i.fxSpeed)})}else{h.slideDown(i.fxSpeed)}}else{h.slideUp(i.fxSpeed)}return false},toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"HDAView("+g+")"}});function e(g,h){action=function(){Galaxy.frame_manager.frame_new({title:"Scatterplot",type:"url",content:g+"/scatterplot?"+$.param(h),location:"center"});$("div.popmenu-wrapper").remove();return false};return action}function b(g,i,h){return function(){var j={};if(h){j["f-dbkey"]=h}$.ajax({url:g+"/list_tracks?"+$.param(j),dataType:"html",error:function(){alert(("Could not add this dataset to browser")+".")},success:function(k){var l=window.parent;l.Galaxy.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){l.Galaxy.modal.hide()},"View in saved visualization":function(){l.Galaxy.modal.show({title:"Add Data to Saved Visualization",body:k,buttons:{Cancel:function(){l.Galaxy.modal.hide()},"Add to visualization":function(){$(l.document).find("input[name=id]:checked").each(function(){l.Galaxy.modal.hide();var m=$(this).val();i.id=m;l.Galaxy.frame_manager.frame_new({title:"Trackster",type:"url",content:g+"/trackster?"+$.param(i)})})}}})},"View in new visualization":function(){l.Galaxy.modal.hide();var m=g+"/trackster?"+$.param(i);l.Galaxy.frame_manager.frame_new({title:"Trackster",type:"url",content:m})}}})}});return false}}return{HDAEditView:f}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/dataset/hda-base"],function(d,a){var f=a.HDABaseView.extend(LoggableMixin).extend({initialize:function(g){a.HDABaseView.prototype.initialize.call(this,g);this.hasUser=g.hasUser;this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton,this._render_rerunButton]},_render_titleButtons:function(){return a.HDABaseView.prototype._render_titleButtons.call(this).concat([this._render_editButton(),this._render_deleteButton()])},_render_editButton:function(){if((this.model.get("state")===d.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.DISCARDED)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var i=this.model.get("purged"),g=this.model.get("deleted"),h={title:_l("Edit Attributes"),href:this.urls.edit,target:"galaxy_main",icon_class:"edit"};if(g||i){h.enabled=false;if(i){h.title=_l("Cannot edit attributes of datasets removed from disk")}else{if(g){h.title=_l("Undelete dataset to edit attributes")}}}else{if(this.model.get("state")===d.HistoryDatasetAssociation.STATES.UPLOAD){h.disabled=true;h.title=_l("This dataset must finish uploading before it can be edited")}}h.faIcon="fa-pencil";return faIconButton(h)},_render_deleteButton:function(){if((this.model.get("state")===d.HistoryDatasetAssociation.STATES.NEW)||(this.model.get("state")===d.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var g=this,h=g.urls["delete"],i={title:_l("Delete"),href:h,icon_class:"delete",onclick:function(){g.$el.find(".menu-button.delete").trigger("mouseout");g.model["delete"]()}};if(this.model.get("deleted")||this.model.get("purged")){i={title:_l("Dataset is already deleted"),icon_class:"delete",enabled:false}}i.faIcon="fa-times";return faIconButton(i)},_render_errButton:function(){if(this.model.get("state")!==d.HistoryDatasetAssociation.STATES.ERROR){return null}return faIconButton({title:_l("View or report this error"),href:this.urls.report_error,target:"galaxy_main",faIcon:"fa-bug"})},_render_rerunButton:function(){return faIconButton({title:_l("Run this job again"),href:this.urls.rerun,target:"galaxy_main",faIcon:"fa-refresh"})},_render_visualizationsButton:function(){var g=this.model.get("visualizations");if((!this.model.hasData())||(_.isEmpty(g))){return null}if(_.isObject(g[0])){return this._render_visualizationsFrameworkButton(g)}if(!this.urls.visualization){return null}var i=this.model.get("dbkey"),l=this.urls.visualization,j={},m={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(i){m.dbkey=i}var h=faIconButton({title:_l("Visualize"),href:this.urls.visualization,faIcon:"fa-bar-chart-o"});function k(n){switch(n){case"trackster":return b(l,m,i);case"scatterplot":return e(l,m);default:return function(){Galaxy.frame_manager.frame_new({title:"Visualization",type:"url",content:l+"/"+n+"?"+$.param(m)})}}}if(g.length===1){h.attr("title",g[0]);h.click(k(g[0]))}else{_.each(g,function(o){var n=o.charAt(0).toUpperCase()+o.slice(1);j[_l(n)]=k(o)});make_popupmenu(h,j)}return h},_render_visualizationsFrameworkButton:function(g){if(!(this.model.hasData())||!(g&&!_.isEmpty(g))){return null}var i=faIconButton({title:_l("Visualize"),faIcon:"fa-bar-chart-o"});i.addClass("visualize-icon");if(_.keys(g).length===1){i.attr("title",_.keys(g)[0]);i.attr("href",_.values(g)[0])}else{var j=[];_.each(g,function(k){j.push(k)});var h=new PopupMenu(i,j)}return i},_render_tagButton:function(){if(!this.hasUser){return null}return faIconButton({title:_l("Edit dataset tags"),classes:"dataset-tag-btn",faIcon:"fa-tags"})},_render_annotateButton:function(){if(!this.hasUser){return null}return faIconButton({title:_l("Edit dataset annotation"),classes:"dataset-annotate-btn",faIcon:"fa-comment"})},_render_body_failed_metadata:function(){var h=$("<a/>").attr({href:this.urls.edit,target:"galaxy_main"}).text(_l("set it manually or retry auto-detection")),g=$("<span/>").text(". "+_l("You may be able to")+" ").append(h),i=a.HDABaseView.prototype._render_body_failed_metadata.call(this);i.find(".warningmessagesmall strong").append(g);return i},_render_body_error:function(){var g=a.HDABaseView.prototype._render_body_error.call(this);g.find(".dataset-actions .left").prepend(this._render_errButton());return g},_render_body_ok:function(){var g=a.HDABaseView.prototype._render_body_ok.call(this);if(this.model.isDeletedOrPurged()){return g}this.makeDbkeyEditLink(g);g.find(".dataset-actions .left").append(this._render_visualizationsButton());g.find(".dataset-actions .right").append([this._render_tagButton(),this._render_annotateButton()]);this.tagsEditor=new TagsEditor({model:this.model,el:g.find(".tags-display")}).render();return g},makeDbkeyEditLink:function(g){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){g.find(".dataset-dbkey .value").replaceWith($('<a target="galaxy_main">?</a>').attr("href",this.urls.edit))}},events:{"click .dataset-title-bar":"toggleBodyVisibility","click .dataset-undelete":function(g){this.model.undelete();return false},"click .dataset-unhide":function(g){this.model.unhide();return false},"click .dataset-purge":"confirmPurge","click .dataset-tag-btn":"displayTags","click .dataset-annotate-btn":"loadAndDisplayAnnotation"},confirmPurge:function c(g){this.model.purge();return false},displayTags:function(g){this.$el.find(".tags-display").slideToggle(this.fxSpeed);return false},loadAndDisplayAnnotation:function(j){this.log(this+".loadAndDisplayAnnotation",j);var i=this,h=this.$el.find(".annotation-display"),g=h.find(".annotation");if(h.is(":hidden")){if(!jQuery.trim(g.html())){var k=$.ajax(this.urls.annotation.get);k.fail(function(n,l,m){i.log("Annotation failed",n,l,m);i.trigger("error",i,n,{},_l("Annotation failed"))});k.done(function(l){l=l||"<em>"+_l("Describe or add notes to dataset")+"</em>";g.html(l);h.find("[title]").tooltip();g.make_text_editable({use_textarea:true,on_finish:function(m){g.text(m);i.model.save({annotation:m},{silent:true}).fail(function(){g.text(i.model.previous("annotation"))})}});h.slideDown(i.fxSpeed)})}else{h.slideDown(i.fxSpeed)}}else{h.slideUp(i.fxSpeed)}return false},toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"HDAView("+g+")"}});function e(g,h){action=function(){Galaxy.frame_manager.frame_new({title:"Scatterplot",type:"url",content:g+"/scatterplot?"+$.param(h),target:"galaxy_main",scratchbook:true});$("div.popmenu-wrapper").remove();return false};return action}function b(g,i,h){return function(){var j={};if(h){j["f-dbkey"]=h}$.ajax({url:g+"/list_tracks?"+$.param(j),dataType:"html",error:function(){alert(("Could not add this dataset to browser")+".")},success:function(k){var l=window.parent;l.Galaxy.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){l.Galaxy.modal.hide()},"View in saved visualization":function(){l.Galaxy.modal.show({title:"Add Data to Saved Visualization",body:k,buttons:{Cancel:function(){l.Galaxy.modal.hide()},"Add to visualization":function(){$(l.document).find("input[name=id]:checked").each(function(){l.Galaxy.modal.hide();var m=$(this).val();i.id=m;l.Galaxy.frame_manager.frame_new({title:"Trackster",type:"url",content:g+"/trackster?"+$.param(i),scratchbook:true})})}}})},"View in new visualization":function(){l.Galaxy.modal.hide();var m=g+"/trackster?"+$.param(i);l.Galaxy.frame_manager.frame_new({title:"Trackster",type:"url",content:m,scratchbook:true})}}})}});return false}}return{HDAEditView:f}}); \ No newline at end of file diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1312,7 +1312,7 @@ #masthead .navbar-brand{position:absolute;left:0;top:0;font-family:verdana;font-weight:bold;font-size:20px;line-height:1;color:white;padding:5px 20px 12px;margin-left:-15px;z-index:2000}#masthead .navbar-brand img{display:inline;width:26px;vertical-align:top} #masthead .navbar-brand a{color:white;text-decoration:none} #masthead .iconbar{position:absolute;top:5px;right:110px;cursor:pointer;color:#999;overflow:hidden}#masthead .iconbar .symbol{float:left;margin:0px 10px} -#masthead .iconbar .symbol .number{font-weight:bold;font-size:10px;font-family:"Lucida Grande",verdana,arial,helvetica,sans-serif;position:relative;left:23px;top:-16px} +#masthead .iconbar .symbol .number{font-weight:bold;font-size:10px;font-family:"Lucida Grande",verdana,arial,helvetica,sans-serif;position:relative;left:23px;top:-12px} #masthead .iconbar .toggle{color:#BCC800} .quota-meter-container{position:absolute;top:0;right:0;height:32px} .quota-meter{position:absolute;top:8px;right:8px;height:16px;width:100px;background-color:#f5f5f5} diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f static/style/src/less/base.less --- a/static/style/src/less/base.less +++ b/static/style/src/less/base.less @@ -440,7 +440,7 @@ font-family : @font-family-sans-serif; position : relative; left : 23px; - top : -16px; + top : -12px; } .toggle diff -r c67b9518c1e0dc1d04d5dfb78a10b0b7847eb6b6 -r 5828950834e3c888683dbeb567e10bcaf335c94f templates/base/base_panels.mako --- a/templates/base/base_panels.mako +++ b/templates/base/base_panels.mako @@ -93,15 +93,6 @@ "libs/backbone/backbone-relational": ["libs/backbone/backbone"] } }); - - ## load galaxy js-modules - require(['galaxy.master', 'galaxy.frame', 'galaxy.modal', 'galaxy.upload'], function(master, frame, modal, upload) - { - Galaxy.master = new master.GalaxyMaster(); - Galaxy.frame_manager = new frame.GalaxyFrameManager(); - Galaxy.modal = new modal.GalaxyModal(); - ##Galaxy.upload = new upload.GalaxyUpload(); - }); </script></%def> This diff is so big that we needed to truncate the remainder. Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org