diff --git a/lib/galaxy/webapps/reports/base/__init__.py b/lib/galaxy/webapps/reports/base/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/galaxy/webapps/reports/base/controller.py b/lib/galaxy/webapps/reports/base/controller.py deleted file mode 100644 index 33c9151996f..00000000000 --- a/lib/galaxy/webapps/reports/base/controller.py +++ /dev/null @@ -1,12 +0,0 @@ -"""Contains functionality needed in every webapp interface""" -import os, time, logging -# Pieces of Galaxy to make global in every controller -from galaxy import web, util - -log = logging.getLogger( __name__ ) - -class BaseController( object ): - """Base class for Galaxy webapp application controllers.""" - def __init__( self, app ): - """Initialize an interface for application 'app'""" - self.app = app \ No newline at end of file diff --git a/lib/galaxy/webapps/reports/buildapp.py b/lib/galaxy/webapps/reports/buildapp.py index 9bce1a6c5a8..7bdaad9d9c1 100644 --- a/lib/galaxy/webapps/reports/buildapp.py +++ b/lib/galaxy/webapps/reports/buildapp.py @@ -25,7 +25,8 @@ def add_controllers( webapp, app ): Search for controllers in the 'galaxy.webapps.controllers' module and add them to the webapp. """ - from galaxy.webapps.reports.base.controller import BaseController + from galaxy.web.base.controller import BaseController + from galaxy.web.base.controller import ControllerUnavailable import galaxy.webapps.reports.controllers controller_dir = galaxy.webapps.reports.controllers.__path__[0] for fname in os.listdir( controller_dir ): diff --git a/lib/galaxy/webapps/reports/config.py b/lib/galaxy/webapps/reports/config.py index 4c3bf7bd087..a2f81f74243 100644 --- a/lib/galaxy/webapps/reports/config.py +++ b/lib/galaxy/webapps/reports/config.py @@ -29,13 +29,15 @@ class Configuration( object ): self.use_remote_user = string_as_bool( kwargs.get( "use_remote_user", "False" ) ) self.require_login = string_as_bool( kwargs.get( "require_login", "False" ) ) self.template_path = resolve_path( kwargs.get( "template_path", "templates" ), self.root ) - self.template_cache = resolve_path( kwargs.get( "template_cache_path", "database/reports/compiled_templates" ), self.root ) + self.template_cache = resolve_path( kwargs.get( "template_cache_path", "database/compiled_templates/reports" ), self.root ) self.sendmail_path = kwargs.get('sendmail_path',"/usr/sbin/sendmail") + self.log_actions = string_as_bool( kwargs.get( 'log_actions', 'False' ) ) self.brand = kwargs.get( 'brand', None ) - self.wiki_url = kwargs.get( 'wiki_url', "http://g2.trac.bx.psu.edu/" ) - self.bugs_email = kwargs.get( 'bugs_email', "mailto:galaxy-bugs@bx.psu.edu" ) - self.blog_url = kwargs.get( 'blog_url', "http://g2.trac.bx.psu.edu/blog" ) - self.screencasts_url = kwargs.get( 'screencasts_url', "http://g2.trac.bx.psu.edu/wiki/ScreenCasts" ) + self.wiki_url = kwargs.get( 'wiki_url', 'http://bitbucket.org/galaxy/galaxy-central/wiki/Home' ) + self.bugs_email = kwargs.get( 'bugs_email', None ) + self.blog_url = kwargs.get( 'blog_url', None ) + self.screencasts_url = kwargs.get( 'screencasts_url', None ) + self.log_events = False self.cookie_path = kwargs.get( "cookie_path", "/" ) #Parse global_conf global_conf = kwargs.get( 'global_conf', None ) diff --git a/lib/galaxy/webapps/reports/controllers/jobs.py b/lib/galaxy/webapps/reports/controllers/jobs.py index d14b6bfe04d..fef3cdd0611 100644 --- a/lib/galaxy/webapps/reports/controllers/jobs.py +++ b/lib/galaxy/webapps/reports/controllers/jobs.py @@ -1,69 +1,239 @@ -import operator, os, socket +import calendar, operator, os, socket from datetime import * from time import mktime, strftime, localtime -import calendar -from galaxy.webapps.reports.base.controller import * -import galaxy.model +from galaxy.web.base.controller import * +from galaxy import model, util +from galaxy.web.framework.helpers import time_ago, iff, grids +from galaxy.model.orm import * import pkg_resources pkg_resources.require( "SQLAlchemy >= 0.4" ) import sqlalchemy as sa import logging log = logging.getLogger( __name__ ) -class Jobs( BaseController ): - @web.expose - def today_all( self, trans, **kwd ): - params = util.Params( kwd ) - msg = '' - monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' ) - year, month, day = map( int, datetime.utcnow().strftime( "%Y-%m-%d" ).split( "-" ) ) +class SpecifiedDateListGrid( grids.Grid ): + class JobIdColumn( grids.IntegerColumn ): + def get_value( self, trans, grid, job ): + return job.id + class StateColumn( grids.TextColumn ): + def get_value( self, trans, grid, job ): + return job.state + class ToolColumn( grids.TextColumn ): + def get_value( self, trans, grid, job ): + return job.tool_id + class CreateTimeColumn( grids.TextColumn ): + def get_value( self, trans, grid, job ): + return job.create_time + class UserColumn( grids.TextColumn ): + def get_value( self, trans, grid, job ): + if job.history: + if job.history.user: + return job.history.user.email + return 'anonymous' + # TODO: handle libraries... + return 'no history' + # Grid definition + use_async = False + model_class = model.Job + title = "Jobs By Date" + template='/webapps/reports/grid.mako' + default_sort_key = "id" + columns = [ + JobIdColumn( "Id", + key="id", + model_class=model.Job, + link=( lambda item: dict( operation="job_info", id=item.id, webapp="reports" ) ), + attach_popup=False, + filterable="advanced" ), + StateColumn( "State", + key="state", + model_class=model.Job, + attach_popup=False ), + ToolColumn( "Tool Id", + key="tool_id", + model_class=model.Job, + link=( lambda item: dict( operation="tool_per_month", id=item.id, webapp="reports" ) ), + attach_popup=False ), + CreateTimeColumn( "create_time", + key="create_time", + model_class=model.Job, + attach_popup=False ), + UserColumn( "user", + # Can't sort on this column since it is not a column in self.model_class + model_class=model.User, + link=( lambda item: dict( operation="user_per_month", id=item.id, webapp="reports" ) ), + attach_popup=False ), + grids.StateColumn( "All", key="state", model_class=model.Job, visible=False, filterable="advanced" ) + ] + columns.append( grids.MulticolFilterColumn( "Search", + cols_to_filter=[ columns[1], columns[2] ], + key="free-text-search", + visible=False, + filterable="standard" ) ) + standard_filters = [] + default_filter = { 'specified_date' : 'All' } + num_rows_per_page = 50 + preserve_state = False + use_paging = True + def build_initial_query( self, trans, **kwd ): + specified_date = kwd.get( 'specified_date', 'All' ) + if specified_date == 'All': + return trans.sa_session.query( self.model_class ) + year, month, day = map( int, specified_date.split( "-" ) ) start_date = date( year, month, day ) end_date = start_date + timedelta( days=1 ) - day_label = start_date.strftime( "%A" ) - month_label = start_date.strftime( "%B" ) - year_label = start_date.strftime( "%Y" ) - day_of_month = start_date.strftime( "%d" ) - q = sa.select( ( sa.func.date( galaxy.model.Job.table.c.create_time ).label( 'date' ), - sa.func.sum( sa.case( [( galaxy.model.User.table.c.email == monitor_email, 1 )], else_=0 ) ).label( 'monitor_jobs' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = sa.and_( galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ).outerjoin( galaxy.model.User.table ) ], - group_by = [ 'date' ] ) - jobs = [] - for row in q.execute(): - jobs.append( ( row.date.strftime( "%A" ), - row.date, - row.total_jobs - row.monitor_jobs, - row.monitor_jobs, - row.total_jobs, - row.date.strftime( "%d" ) ) ) - return trans.fill_template( 'jobs_today_all.mako', - day_label=day_label, - month_label=month_label, - year_label=year_label, - day_of_month=day_of_month, - month=month, - jobs=jobs, - msg=msg ) + return trans.sa_session.query( self.model_class ).filter( and_( self.model_class.table.c.create_time >= start_date, + self.model_class.table.c.create_time < end_date ) ) + +class SpecifiedDateInErrorListGrid( SpecifiedDateListGrid ): + def build_initial_query( self, trans, **kwd ): + specified_date = kwd.get( 'specified_date', 'All' ) + if specified_date == 'All': + return trans.sa_session.query( self.model_class ).filter( self.model_class.table.c.state == model.Job.states.ERROR ) + year, month, day = map( int, specified_date.split( "-" ) ) + start_date = date( year, month, day ) + end_date = start_date + timedelta( days=1 ) + return trans.sa_session.query( self.model_class ).filter( and_( self.model_class.table.c.state == model.Job.states.ERROR, + self.model_class.table.c.create_time >= start_date, + self.model_class.table.c.create_time < end_date ) ) + +class AllUnfinishedListGrid( SpecifiedDateListGrid ): + def build_initial_query( self, trans, **kwd ): + specified_date = kwd.get( 'specified_date', 'All' ) + if specified_date == 'All': + return trans.sa_session.query( self.model_class ).filter( not_( or_( model.Job.table.c.state == model.Job.states.OK, + model.Job.table.c.state == model.Job.states.ERROR, + model.Job.table.c.state == model.Job.states.DELETED ) ) ) + year, month, day = map( int, specified_date.split( "-" ) ) + start_date = date( year, month, day ) + end_date = start_date + timedelta( days=1 ) + return trans.sa_session.query( self.model_class ).filter( and_( not_( or_( model.Job.table.c.state == model.Job.states.OK, + model.Job.table.c.state == model.Job.states.ERROR, + model.Job.table.c.state == model.Job.states.DELETED ) ), + self.model_class.table.c.create_time >= start_date, + self.model_class.table.c.create_time < end_date ) ) + +class UserForMonthListGrid( SpecifiedDateListGrid ): + def build_initial_query( self, trans, **kwd ): + email = util.restore_text( kwd.get( 'email', '' ) ) + year, month = map( int, kwd.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) + start_date = date( year, month, 1 ) + end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) + return trans.sa_session.query( model.Job ) \ + .join( model.GalaxySession ) \ + .join( model.User ) \ + .filter( and_( model.Job.table.c.session_id == model.GalaxySession.table.c.id, + model.GalaxySession.table.c.user_id == model.User.table.c.id, + model.User.table.c.email == email, + model.Job.table.c.create_time >= start_date, + model.Job.table.c.create_time < end_date ) ) \ + .order_by( desc( model.Job.table.c.create_time ) ) + +class ToolForMonthListGrid( SpecifiedDateListGrid ): + def build_initial_query( self, trans, **kwd ): + tool_id = util.restore_text( kwd.get( 'tool_id', '' ) ) + year, month = map( int, kwd.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) + start_date = date( year, month, 1 ) + end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) + return trans.sa_session.query( model.Job ) \ + .filter( and_( model.Job.table.c.tool_id == tool_id, + model.Job.table.c.create_time >= start_date, + model.Job.table.c.create_time < end_date ) ) \ + .order_by( desc( model.Job.table.c.create_time ) ) + +class Jobs( BaseController ): + + specified_date_list_grid = SpecifiedDateListGrid() + specified_date_in_error_list_grid = SpecifiedDateInErrorListGrid() + all_unfinished_list_grid = AllUnfinishedListGrid() + user_for_month_list_grid = UserForMonthListGrid() + tool_for_month_list_grid = ToolForMonthListGrid() + + @web.expose + def specified_date( self, trans, **kwd ): + if 'operation' in kwd: + operation = kwd['operation'].lower() + if operation == "job_info": + return trans.response.send_redirect( web.url_for( controller='jobs', + action='job_info', + **kwd ) ) + if operation == "tool_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'tool_id' ] = job.tool_id + return trans.response.send_redirect( web.url_for( controller='jobs', + action='tool_per_month', + **kwd ) ) + if operation == "user_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'email' ] = None # For anonymous users + if job.history: + if job.history.user: + email = job.history.user.email + kwd[ 'email' ] = email + # TODO: handle libraries + return trans.response.send_redirect( web.url_for( controller='jobs', + action='user_per_month', + **kwd ) ) + return self.specified_date_list_grid( trans, **kwd ) + @web.expose + def today_all( self, trans, **kwd ): + kwd[ 'specified_date' ] = datetime.utcnow().strftime( "%Y-%m-%d" ) + return self.specified_date( trans, **kwd ) + @web.expose + def specified_date_in_error( self, trans, **kwd ): + if 'operation' in kwd: + operation = kwd['operation'].lower() + if operation == "job_info": + return trans.response.send_redirect( web.url_for( controller='jobs', + action='job_info', + **kwd ) ) + if operation == "tool_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'tool_id' ] = job.tool_id + return trans.response.send_redirect( web.url_for( controller='jobs', + action='tool_per_month', + **kwd ) ) + if operation == "user_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'email' ] = None # For anonymous users + if job.history: + if job.history.user: + email = job.history.user.email + kwd[ 'email' ] = email + # TODO: handle libraries + return trans.response.send_redirect( web.url_for( controller='jobs', + action='user_per_month', + **kwd ) ) + return self.specified_date_in_error_list_grid( trans, **kwd ) @web.expose def specified_month_all( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' ) year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) start_date = date( year, month, 1 ) end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) month_label = start_date.strftime( "%B" ) year_label = start_date.strftime( "%Y" ) - q = sa.select( ( sa.func.date( galaxy.model.Job.table.c.create_time ).label( 'date' ), - sa.func.sum( sa.case( [( galaxy.model.User.table.c.email == monitor_email, 1 )], else_=0 ) ).label( 'monitor_jobs' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = sa.and_( galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ).outerjoin( galaxy.model.User.table ) ], + q = sa.select( ( sa.func.date( model.Job.table.c.create_time ).label( 'date' ), + sa.func.sum( sa.case( [ ( model.User.table.c.email == monitor_email, 1 ) ], else_=0 ) ).label( 'monitor_jobs' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + whereclause = sa.and_( model.Job.table.c.create_time >= start_date, + model.Job.table.c.create_time < end_date ), + from_obj = [ sa.outerjoin( model.Job.table, + model.History.table ).outerjoin( model.User.table ) ], group_by = [ 'date' ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] @@ -74,28 +244,28 @@ class Jobs( BaseController ): row.monitor_jobs, row.total_jobs, row.date.strftime( "%d" ) ) ) - return trans.fill_template( 'jobs_specified_month_all.mako', + return trans.fill_template( '/webapps/reports/jobs_specified_month_all.mako', month_label=month_label, year_label=year_label, month=month, jobs=jobs, - msg=msg ) + message=message ) @web.expose def specified_month_in_error( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) start_date = date( year, month, 1 ) end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) month_label = start_date.strftime( "%B" ) year_label = start_date.strftime( "%Y" ) - q = sa.select( ( sa.func.date( galaxy.model.Job.table.c.create_time ).label( 'date' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = sa.and_( galaxy.model.Job.table.c.state == 'error', - galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ).outerjoin( galaxy.model.User.table ) ], + q = sa.select( ( sa.func.date( model.Job.table.c.create_time ).label( 'date' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + whereclause = sa.and_( model.Job.table.c.state == 'error', + model.Job.table.c.create_time >= start_date, + model.Job.table.c.create_time < end_date ), + from_obj = [ sa.outerjoin( model.Job.table, + model.History.table ).outerjoin( model.User.table ) ], group_by = [ 'date' ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] @@ -104,189 +274,55 @@ class Jobs( BaseController ): row.date, row.total_jobs, row.date.strftime( "%d" ) ) ) - return trans.fill_template( 'jobs_specified_month_in_error.mako', + return trans.fill_template( '/webapps/reports/jobs_specified_month_in_error.mako', month_label=month_label, year_label=year_label, month=month, jobs=jobs, - msg=msg ) - @web.expose - def specified_date_in_error( self, trans, **kwd ): - params = util.Params( kwd ) - msg = '' - year, month, day = map( int, params.get( 'specified_date', datetime.utcnow().strftime( "%Y-%m-%d" ) ).split( "-" ) ) - start_date = date( year, month, day ) - end_date = start_date + timedelta( days=1 ) - day_label = start_date.strftime( "%A" ) - month_label = start_date.strftime( "%B" ) - year_label = start_date.strftime( "%Y" ) - day_of_month = start_date.strftime( "%d" ) - q = sa.select( ( galaxy.model.Job.table.c.id, - galaxy.model.Job.table.c.state, - galaxy.model.Job.table.c.create_time, - galaxy.model.Job.table.c.update_time, - galaxy.model.Job.table.c.tool_id, - galaxy.model.Job.table.c.command_line, - galaxy.model.Job.table.c.stderr, - galaxy.model.Job.table.c.session_id, - ( galaxy.model.Job.table.c.traceback ).label( 'stack_trace' ), - galaxy.model.Job.table.c.info, - ( galaxy.model.User.table.c.email ).label( 'user_email' ), - galaxy.model.GalaxySession.table.c.remote_addr ), - whereclause = sa.and_( galaxy.model.Job.table.c.state == 'error', - galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ) \ - .outerjoin( galaxy.model.User.table ) \ - .outerjoin( galaxy.model.GalaxySession.table, - galaxy.model.Job.table.c.session_id == galaxy.model.GalaxySession.table.c.id ) ], - order_by = [ sa.desc( galaxy.model.Job.table.c.id ) ] ) - jobs = [] - for row in q.execute(): - remote_host = row.remote_addr - if row.remote_addr: - try: - remote_host = socket.gethostbyaddr( row.remote_addr )[0] - except: - pass - jobs.append( ( row.state, - row.id, - row.create_time, - row.update_time, - row.session_id, - row.tool_id, - row.user_email, - remote_host, - row.command_line, - row.stderr, - row.stack_trace, - row.info ) ) - return trans.fill_template( 'jobs_specified_date_in_error.mako', - specified_date=start_date, - day_label=day_label, - month_label=month_label, - year_label=year_label, - day_of_month=day_of_month, - jobs=jobs, - msg=msg ) - @web.expose - def specified_date_all( self, trans, **kwd ): - params = util.Params( kwd ) - msg = '' - monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' ) - year, month, day = map( int, params.get( 'specified_date', datetime.utcnow().strftime( "%Y-%m-%d" ) ).split( "-" ) ) - start_date = date( year, month, day ) - end_date = start_date + timedelta( days=1 ) - day_label = start_date.strftime( "%A" ) - month_label = start_date.strftime( "%B" ) - year_label = start_date.strftime( "%Y" ) - day_of_month = start_date.strftime( "%d" ) - q = sa.select( ( galaxy.model.Job.table.c.id, - galaxy.model.Job.table.c.state, - galaxy.model.Job.table.c.create_time, - galaxy.model.Job.table.c.update_time, - galaxy.model.Job.table.c.tool_id, - galaxy.model.Job.table.c.command_line, - galaxy.model.Job.table.c.stderr, - galaxy.model.Job.table.c.session_id, - ( galaxy.model.Job.table.c.traceback ).label( 'stack_trace' ), - galaxy.model.Job.table.c.info, - ( galaxy.model.User.table.c.email ).label( 'user_email' ), - galaxy.model.GalaxySession.table.c.remote_addr ), - whereclause = sa.and_( galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ) \ - .outerjoin( galaxy.model.User.table ) \ - .outerjoin( galaxy.model.GalaxySession.table, - galaxy.model.Job.table.c.session_id == galaxy.model.GalaxySession.table.c.id ) ], - order_by = [ sa.desc( galaxy.model.Job.table.c.id ) ] ) - jobs = [] - for row in q.execute(): - remote_host = row.remote_addr - if row.remote_addr: - try: - remote_host = socket.gethostbyaddr( row.remote_addr )[0] - except: - pass - jobs.append( ( row.state, - row.id, - row.create_time, - row.update_time, - row.session_id, - row.tool_id, - row.user_email, - remote_host, - row.command_line, - row.stderr, - row.stack_trace, - row.info ) ) - return trans.fill_template( 'jobs_specified_date_all.mako', - specified_date=start_date, - day_label=day_label, - month_label=month_label, - year_label=year_label, - day_of_month=day_of_month, - jobs=jobs, - msg=msg ) + message=message ) @web.expose def all_unfinished( self, trans, **kwd ): - params = util.Params( kwd ) - msg = '' - jobs = [] - q = sa.select( ( galaxy.model.Job.table.c.id, - galaxy.model.Job.table.c.state, - galaxy.model.Job.table.c.create_time, - galaxy.model.Job.table.c.update_time, - galaxy.model.Job.table.c.tool_id, - galaxy.model.Job.table.c.command_line, - galaxy.model.Job.table.c.stderr, - galaxy.model.Job.table.c.session_id, - ( galaxy.model.Job.table.c.traceback ).label( 'stack_trace' ), - galaxy.model.Job.table.c.info, - ( galaxy.model.User.table.c.email ).label( 'user_email' ), - galaxy.model.GalaxySession.table.c.remote_addr ), - whereclause = sa.not_( sa.or_( galaxy.model.Job.table.c.state == 'ok', - galaxy.model.Job.table.c.state == 'error', - galaxy.model.Job.table.c.state == 'deleted' ) ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ) \ - .outerjoin( galaxy.model.User.table ) \ - .outerjoin( galaxy.model.GalaxySession.table, - galaxy.model.Job.table.c.session_id == galaxy.model.GalaxySession.table.c.id ) ], - order_by = [ sa.desc( galaxy.model.Job.table.c.id ) ] ) - for row in q.execute(): - remote_host = row.remote_addr - if row.remote_addr: - try: - remote_host = socket.gethostbyaddr( row.remote_addr )[0] - except: - pass - jobs.append( ( row.state, - row.id, - row.create_time, - row.update_time, - row.session_id, - row.tool_id, - row.user_email, - remote_host, - row.command_line, - row.stderr, - row.stack_trace, - row.info ) ) - return trans.fill_template( 'jobs_all_unfinished.mako', jobs=jobs, msg=msg ) + if 'operation' in kwd: + operation = kwd['operation'].lower() + if operation == "job_info": + return trans.response.send_redirect( web.url_for( controller='jobs', + action='job_info', + **kwd ) ) + if operation == "tool_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'tool_id' ] = job.tool_id + return trans.response.send_redirect( web.url_for( controller='jobs', + action='tool_per_month', + **kwd ) ) + if operation == "user_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'email' ] = None # For anonymous users + if job.history: + if job.history.user: + email = job.history.user.email + kwd[ 'email' ] = email + # TODO: handle libraries + return trans.response.send_redirect( web.url_for( controller='jobs', + action='user_per_month', + **kwd ) ) + return self.all_unfinished_list_grid( trans, **kwd ) @web.expose def per_month_all( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' ) - q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ).label( 'date' ), - sa.func.sum( sa.case( [( galaxy.model.User.table.c.email == monitor_email, 1 )], else_=0 ) ).label( 'monitor_jobs' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ).outerjoin( galaxy.model.User.table ) ], - group_by = [ sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ) ], + q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ).label( 'date' ), + sa.func.sum( sa.case( [( model.User.table.c.email == monitor_email, 1 )], else_=0 ) ).label( 'monitor_jobs' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + from_obj = [ sa.outerjoin( model.Job.table, + model.History.table ).outerjoin( model.User.table ) ], + group_by = [ sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ) ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] for row in q.execute(): @@ -296,16 +332,16 @@ class Jobs( BaseController ): row.total_jobs, row.date.strftime( "%B" ), row.date.strftime( "%Y" ) ) ) - return trans.fill_template( 'jobs_per_month_all.mako', jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_per_month_all.mako', jobs=jobs, message=message ) @web.expose def per_month_in_error( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' - q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ).label( 'date' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = galaxy.model.Job.table.c.state == 'error', - from_obj = [ galaxy.model.Job.table ], - group_by = [ sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ) ], + message = '' + q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ).label( 'date' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + whereclause = model.Job.table.c.state == 'error', + from_obj = [ model.Job.table ], + group_by = [ sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ) ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] for row in q.execute(): @@ -313,36 +349,36 @@ class Jobs( BaseController ): row.total_jobs, row.date.strftime( "%B" ), row.date.strftime( "%Y" ) ) ) - return trans.fill_template( 'jobs_per_month_in_error.mako', jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_per_month_in_error.mako', jobs=jobs, message=message ) @web.expose def per_user( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' jobs = [] - q = sa.select( ( galaxy.model.User.table.c.email.label( 'user_email' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.GalaxySession.table ).outerjoin( galaxy.model.User.table ) ], + q = sa.select( ( model.User.table.c.email.label( 'user_email' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + from_obj = [ sa.outerjoin( model.Job.table, + model.GalaxySession.table ).outerjoin( model.User.table ) ], group_by = [ 'user_email' ], order_by = [ sa.desc( 'total_jobs' ), 'user_email' ] ) for row in q.execute(): jobs.append( ( row.user_email, row.total_jobs ) ) - return trans.fill_template( 'jobs_per_user.mako', jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_per_user.mako', jobs=jobs, message=message ) @web.expose def user_per_month( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' - email = params.get( 'email', None ) - if email is not None: - # The @ char has been converted to an 'X' - email = email.replace( 'X', '@' ) - q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ).label( 'date' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = galaxy.model.User.table.c.email == email, - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.GalaxySession.table ).outerjoin( galaxy.model.User.table ) ], - group_by = [ sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ) ], + message = '' + email = util.restore_text( params.get( 'email', '' ) ) + q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ).label( 'date' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + whereclause = sa.and_( model.Job.table.c.session_id == model.GalaxySession.table.c.id, + model.GalaxySession.table.c.user_id == model.User.table.c.id, + model.User.table.c.email == email + ), + from_obj = [ sa.join( model.Job.table, + model.GalaxySession.table ).join( model.User.table ) ], + group_by = [ sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ) ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] for row in q.execute(): @@ -350,92 +386,65 @@ class Jobs( BaseController ): row.total_jobs, row.date.strftime( "%B" ), row.date.strftime( "%Y" ) ) ) - return trans.fill_template( 'jobs_user_per_month.mako', email=email, jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_user_per_month.mako', + email=util.sanitize_text( email ), + jobs=jobs, message=message ) @web.expose def user_for_month( self, trans, **kwd ): - params = util.Params( kwd ) - msg = '' - email = params.get( 'email', None ) - if email is not None: - # The @ char has been converted to an 'X' - email = email.replace( 'X', '@' ) - year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) - start_date = date( year, month, 1 ) - end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) - month_label = start_date.strftime( "%B" ) - year_label = start_date.strftime( "%Y" ) - jobs = [] - q = sa.select( ( galaxy.model.Job.table.c.id, - galaxy.model.Job.table.c.state, - galaxy.model.Job.table.c.create_time, - galaxy.model.Job.table.c.update_time, - galaxy.model.Job.table.c.tool_id, - galaxy.model.Job.table.c.command_line, - galaxy.model.Job.table.c.stderr, - galaxy.model.Job.table.c.session_id, - ( galaxy.model.Job.table.c.traceback ).label( 'stack_trace' ), - galaxy.model.Job.table.c.info, - ( galaxy.model.User.table.c.email ).label( 'user_email' ), - galaxy.model.GalaxySession.table.c.remote_addr ), - whereclause = sa.and_( galaxy.model.User.table.c.email == email, - galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ) \ - .outerjoin( galaxy.model.User.table ) \ - .outerjoin( galaxy.model.GalaxySession.table, - galaxy.model.Job.table.c.session_id == galaxy.model.GalaxySession.table.c.id ) ], - order_by = [ sa.desc( galaxy.model.Job.table.c.id ) ] ) - for row in q.execute(): - remote_host = row.remote_addr - if row.remote_addr: - try: - remote_host = socket.gethostbyaddr( row.remote_addr )[0] - except: - pass - jobs.append( ( row.state, - row.id, - row.create_time, - row.update_time, - row.session_id, - row.tool_id, - row.user_email, - remote_host, - row.command_line, - row.stderr, - row.stack_trace, - row.info ) ) - return trans.fill_template( 'jobs_user_for_month.mako', - email=email, - month=month, - month_label=month_label, - year_label=year_label, - jobs=jobs, - msg=msg ) + if 'operation' in kwd: + operation = kwd['operation'].lower() + if operation == "job_info": + return trans.response.send_redirect( web.url_for( controller='jobs', + action='job_info', + **kwd ) ) + if operation == "tool_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'tool_id' ] = job.tool_id + return trans.response.send_redirect( web.url_for( controller='jobs', + action='tool_per_month', + **kwd ) ) + if operation == "user_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'email' ] = None # For anonymous users + if job.history: + if job.history.user: + email = job.history.user.email + kwd[ 'email' ] = email + # TODO: handle libraries + return trans.response.send_redirect( web.url_for( controller='jobs', + action='user_per_month', + **kwd ) ) + return self.user_for_month_list_grid( trans, **kwd ) @web.expose def per_tool( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' jobs = [] - q = sa.select( ( galaxy.model.Job.table.c.tool_id.label( 'tool_id' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - from_obj = [ galaxy.model.Job.table ], + q = sa.select( ( model.Job.table.c.tool_id.label( 'tool_id' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + from_obj = [ model.Job.table ], group_by = [ 'tool_id' ], order_by = [ 'tool_id' ] ) for row in q.execute(): jobs.append( ( row.tool_id, row.total_jobs ) ) - return trans.fill_template( 'jobs_per_tool.mako', jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_per_tool.mako', jobs=jobs, message=message ) @web.expose def tool_per_month( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' + message = '' tool_id = params.get( 'tool_id', 'Add a column1' ) - q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ).label( 'date' ), - sa.func.count( galaxy.model.Job.table.c.id ).label( 'total_jobs' ) ), - whereclause = galaxy.model.Job.table.c.tool_id == tool_id, - from_obj = [ galaxy.model.Job.table ], - group_by = [ sa.func.date_trunc( 'month', sa.func.date( galaxy.model.Job.table.c.create_time ) ) ], + q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ).label( 'date' ), + sa.func.count( model.Job.table.c.id ).label( 'total_jobs' ) ), + whereclause = model.Job.table.c.tool_id == tool_id, + from_obj = [ model.Job.table ], + group_by = [ sa.func.date_trunc( 'month', sa.func.date( model.Job.table.c.create_time ) ) ], order_by = [ sa.desc( 'date' ) ] ) jobs = [] for row in q.execute(): @@ -443,71 +452,58 @@ class Jobs( BaseController ): row.total_jobs, row.date.strftime( "%B" ), row.date.strftime( "%Y" ) ) ) - return trans.fill_template( 'jobs_tool_per_month.mako', tool_id=tool_id, jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_tool_per_month.mako', tool_id=tool_id, jobs=jobs, message=message ) @web.expose def tool_for_month( self, trans, **kwd ): + if 'operation' in kwd: + operation = kwd['operation'].lower() + if operation == "job_info": + return trans.response.send_redirect( web.url_for( controller='jobs', + action='job_info', + **kwd ) ) + if operation == "tool_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'tool_id' ] = job.tool_id + return trans.response.send_redirect( web.url_for( controller='jobs', + action='tool_per_month', + **kwd ) ) + if operation == "user_per_month": + # The received id is the job id, so we need to get the id of the user + # that submitted the job. + job_id = kwd.get( 'id', None ) + job = get_job( trans, job_id ) + kwd[ 'email' ] = None # For anonymous users + if job.history: + if job.history.user: + email = job.history.user.email + kwd[ 'email' ] = email + # TODO: handle libraries + return trans.response.send_redirect( web.url_for( controller='jobs', + action='user_per_month', + **kwd ) ) + return self.tool_for_month_list_grid( trans, **kwd ) + @web.expose + def job_info( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' - tool_id = params.get( 'tool_id', 'Add a column1' ) - year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) - start_date = date( year, month, 1 ) - end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) - month_label = start_date.strftime( "%B" ) - year_label = start_date.strftime( "%Y" ) - jobs = [] - q = sa.select( ( galaxy.model.Job.table.c.id, - galaxy.model.Job.table.c.state, - galaxy.model.Job.table.c.create_time, - galaxy.model.Job.table.c.update_time, - galaxy.model.Job.table.c.tool_id, - galaxy.model.Job.table.c.command_line, - galaxy.model.Job.table.c.stderr, - galaxy.model.Job.table.c.session_id, - ( galaxy.model.Job.table.c.traceback ).label( 'stack_trace' ), - galaxy.model.Job.table.c.info, - ( galaxy.model.User.table.c.email ).label( 'user_email' ), - galaxy.model.GalaxySession.table.c.remote_addr ), - whereclause = sa.and_( galaxy.model.Job.table.c.tool_id == tool_id, - galaxy.model.Job.table.c.create_time >= start_date, - galaxy.model.Job.table.c.create_time < end_date ), - from_obj = [ sa.outerjoin( galaxy.model.Job.table, - galaxy.model.History.table ) \ - .outerjoin( galaxy.model.User.table ) \ - .outerjoin( galaxy.model.GalaxySession.table, - galaxy.model.Job.table.c.session_id == galaxy.model.GalaxySession.table.c.id ) ], - order_by = [ sa.desc( galaxy.model.Job.table.c.id ) ] ) - for row in q.execute(): - remote_host = row.remote_addr - if row.remote_addr: - try: - remote_host = socket.gethostbyaddr( row.remote_addr )[0] - except: - pass - jobs.append( ( row.state, - row.id, - row.create_time, - row.update_time, - row.session_id, - row.tool_id, - row.user_email, - remote_host, - row.command_line, - row.stderr, - row.stack_trace, - row.info ) ) - return trans.fill_template( 'jobs_tool_for_month.mako', - tool_id=tool_id, - month=month, - month_label=month_label, - year_label=year_label, - jobs=jobs, - msg=msg ) + message = '' + job_id = trans.security.decode_id( kwd.get( 'id', '' ) ) + job_info = trans.sa_session.query( model.Job.table.join( model.GalaxySession.table ).join( model.User.table ) ) \ + .filter( and_( model.Job.table.c.id == job_id, + model.Job.table.c.session_id == model.GalaxySession.table.c.id, + model.GalaxySession.table.c.user_id == model.User.table.c.id ) ) \ + .one() + # TODO: for some reason the job_info.id is not the same as job_id in the template, so we need to pass job_id + # This needs to be fixed ASAP! + return trans.fill_template( '/webapps/reports/job_info.mako', job_id=job_id, job_info=job_info, message=message ) @web.expose def per_domain( self, trans, **kwd ): # TODO: rewrite using alchemy params = util.Params( kwd ) - msg = '' - engine = galaxy.model.mapping.metadata.engine + message = '' + engine = model.mapping.metadata.engine jobs = [] s = """ SELECT @@ -542,4 +538,9 @@ class Jobs( BaseController ): job_rows = engine.text( s ).execute().fetchall() for job in job_rows: jobs.append( ( job.domain, job.total_jobs ) ) - return trans.fill_template( 'jobs_per_domain.mako', jobs=jobs, msg=msg ) + return trans.fill_template( '/webapps/reports/jobs_per_domain.mako', jobs=jobs, message=message ) + +## ---- Utility methods ------------------------------------------------------- + +def get_job( trans, id ): + return trans.sa_session.query( trans.model.Job ).get( trans.security.decode_id( id ) ) diff --git a/lib/galaxy/webapps/reports/controllers/root.py b/lib/galaxy/webapps/reports/controllers/root.py index a2eba90990a..774687f08ee 100644 --- a/lib/galaxy/webapps/reports/controllers/root.py +++ b/lib/galaxy/webapps/reports/controllers/root.py @@ -1,24 +1,8 @@ -import sys, os, operator, string, shutil, re, socket, urllib, time -from galaxy import web -from cgi import escape, FieldStorage -from galaxy.webapps.reports.base.controller import * +from galaxy.web.base.controller import * import logging log = logging.getLogger( __name__ ) class Report( BaseController ): @web.expose def index( self, trans, **kwd ): - return trans.fill_template( 'index.mako' ) - @web.expose - def masthead( self, trans ): - brand = trans.app.config.get( "brand", "" ) - if brand: - brand ="/%s" % brand - wiki_url = trans.app.config.get( "wiki_url", "http://bitbucket.org/galaxy/galaxy-central/wiki/Home" ) - bugs_email = trans.app.config.get( "bugs_email", "mailto:galaxy-bugs@bx.psu.edu" ) - screencasts_url = trans.app.config.get( "screencasts_url", "http://galaxycast.org" ) - return trans.fill_template( "masthead.mako", - brand=brand, - wiki_url=wiki_url, - bugs_email=bugs_email, - screencasts_url=screencasts_url ) + return trans.fill_template( '/webapps/reports/index.mako' ) diff --git a/lib/galaxy/webapps/reports/controllers/system.py b/lib/galaxy/webapps/reports/controllers/system.py index 2116e3e33b0..2032bb15286 100644 --- a/lib/galaxy/webapps/reports/controllers/system.py +++ b/lib/galaxy/webapps/reports/controllers/system.py @@ -1,10 +1,12 @@ import operator, os from datetime import datetime, timedelta -from galaxy.webapps.reports.base.controller import * -import pkg_resources -pkg_resources.require( "SQLAlchemy >= 0.4" ) -from sqlalchemy.orm import eagerload -from sqlalchemy import desc +from galaxy.web.base.controller import * +#import pkg_resources +#pkg_resources.require( "SQLAlchemy >= 0.4" ) +#from sqlalchemy.orm import eagerload +#from sqlalchemy import desc +from galaxy import model +from galaxy.model.orm import * import logging log = logging.getLogger( __name__ ) @@ -12,32 +14,28 @@ class System( BaseController ): @web.expose def index( self, trans, **kwd ): params = util.Params( kwd ) - msg = '' - + message = '' if params.userless_histories_days: userless_histories_days = params.userless_histories_days else: userless_histories_days = '60' - if params.deleted_histories_days: deleted_histories_days = params.deleted_histories_days else: deleted_histories_days = '60' - if params.deleted_datasets_days: deleted_datasets_days = params.deleted_datasets_days else: deleted_datasets_days = '60' - file_path, disk_usage, datasets, file_size_str = self.disk_usage( trans, **kwd ) if 'action' in kwd: if kwd['action'] == "userless_histories": - userless_histories_days, msg = self.userless_histories( **kwd ) + userless_histories_days, message = self.userless_histories( trans, **kwd ) elif kwd['action'] == "deleted_histories": - deleted_histories_days, msg = self.deleted_histories( **kwd ) + deleted_histories_days, message = self.deleted_histories( trans, **kwd ) elif kwd['action'] == "deleted_datasets": - deleted_datasets_days, msg = self.deleted_datasets( **kwd ) - return trans.fill_template( 'system.mako', + deleted_datasets_days, message = self.deleted_datasets( trans, **kwd ) + return trans.fill_template( '/webapps/reports/system.mako', file_path=file_path, disk_usage=disk_usage, datasets=datasets, @@ -45,49 +43,54 @@ class System( BaseController ): userless_histories_days=userless_histories_days, deleted_histories_days=deleted_histories_days, deleted_datasets_days=deleted_datasets_days, - msg=msg ) + message=message ) - def userless_histories( self, **kwd ): + def userless_histories( self, trans, **kwd ): """The number of userless histories and associated datasets that have not been updated for the specified number of days.""" params = util.Params( kwd ) - msg = '' + message = '' if params.userless_histories_days: userless_histories_days = int( params.userless_histories_days ) cutoff_time = datetime.utcnow() - timedelta( days=userless_histories_days ) history_count = 0 dataset_count = 0 - h = self.app.model.History - where = ( h.table.c.user_id==None ) & ( h.table.c.deleted=='f' ) & ( h.table.c.update_time < cutoff_time ) - histories = h.query().filter( where ).options( eagerload( 'datasets' ) ) + #h = self.app.model.History + #where = ( h.table.c.user_id==None ) & ( h.table.c.deleted=='f' ) & ( h.table.c.update_time < cutoff_time ) + #histories = h.query().filter( where ).options( eagerload( 'datasets' ) ) - for history in histories: + #for history in histories: + for history in trans.sa_session.query( model.History ) \ + .filter( and_( model.History.table.c.user_id == None, + model.History.table.c.deleted == True, + model.History.table.c.update_time < cutoff_time ) ): for dataset in history.datasets: if not dataset.deleted: dataset_count += 1 history_count += 1 - msg = "%d userless histories ( including a total of %d datasets ) have not been updated for at least %d days." %( history_count, dataset_count, userless_histories_days ) + message = "%d userless histories ( including a total of %d datasets ) have not been updated for at least %d days." %( history_count, dataset_count, userless_histories_days ) else: - msg = "Enter the number of days." - return str( userless_histories_days ), msg + message = "Enter the number of days." + return str( userless_histories_days ), message - def deleted_histories( self, **kwd ): + def deleted_histories( self, trans, **kwd ): """ The number of histories that were deleted more than the specified number of days ago, but have not yet been purged. Also included is the number of datasets associated with the histories. """ params = util.Params( kwd ) - msg = '' + message = '' if params.deleted_histories_days: deleted_histories_days = int( params.deleted_histories_days ) cutoff_time = datetime.utcnow() - timedelta( days=deleted_histories_days ) history_count = 0 dataset_count = 0 disk_space = 0 - h = self.app.model.History - d = self.app.model.Dataset - where = ( h.table.c.deleted=='t' ) & ( h.table.c.purged=='f' ) & ( h.table.c.update_time < cutoff_time ) - - histories = h.query().filter( where ).options( eagerload( 'datasets' ) ) + histories = trans.sa_session.query( model.History ) \ + .filter( and_( model.History.table.c.deleted == True, + model.History.table.c.purged == False, + model.History.table.c.update_time < cutoff_time ) ) \ + .options( eagerload( 'datasets' ) ) + for history in histories: for hda in history.datasets: if not hda.dataset.purged: @@ -97,42 +100,39 @@ class System( BaseController ): except: pass history_count += 1 - msg = "%d histories ( including a total of %d datasets ) were deleted more than %d days ago, but have not yet been purged. Disk space: " %( history_count, dataset_count, deleted_histories_days ) + str( disk_space ) + message = "%d histories ( including a total of %d datasets ) were deleted more than %d days ago, but have not yet been purged. Disk space: " %( history_count, dataset_count, deleted_histories_days ) + str( disk_space ) else: - msg = "Enter the number of days." - return str( deleted_histories_days ), msg + message = "Enter the number of days." + return str( deleted_histories_days ), message - def deleted_datasets( self, **kwd ): + def deleted_datasets( self, trans, **kwd ): """The number of datasets that were deleted more than the specified number of days ago, but have not yet been purged.""" params = util.Params( kwd ) - msg = '' + message = '' if params.deleted_datasets_days: deleted_datasets_days = int( params.deleted_datasets_days ) cutoff_time = datetime.utcnow() - timedelta( days=deleted_datasets_days ) dataset_count = 0 disk_space = 0 - d = self.app.model.Dataset - where = ( d.table.c.deleted=='t' ) & ( d.table.c.purged=='f' ) & ( d.table.c.update_time < cutoff_time ) - - datasets = d.query().filter( where ) - for dataset in datasets: + for dataset in trans.sa_session.query( model.Dataset ) \ + .filter( and_( model.Dataset.table.c.deleted == True, + model.Dataset.table.c.purged == False, + model.Dataset.table.c.update_time < cutoff_time ) ): dataset_count += 1 try: disk_space += dataset.file_size except: pass - msg = str( dataset_count ) + " datasets were deleted more than " + str( deleted_datasets_days ) + \ + message = str( dataset_count ) + " datasets were deleted more than " + str( deleted_datasets_days ) + \ " days ago, but have not yet been purged, disk space: " + str( disk_space ) + "." else: - msg = "Enter the number of days." - return str( deleted_datasets_days ), msg - + message = "Enter the number of days." + return str( deleted_datasets_days ), message def get_disk_usage( self, file_path ): df_cmd = 'df -h ' + file_path is_sym_link = os.path.islink( file_path ) file_system = disk_size = disk_used = disk_avail = disk_cap_pct = mount = None df_file = os.popen( df_cmd ) - while True: df_line = df_file.readline() df_line = df_line.strip() @@ -159,22 +159,17 @@ class System( BaseController ): break # EOF df_file.close() return ( file_system, disk_size, disk_used, disk_avail, disk_cap_pct, mount ) - @web.expose def disk_usage( self, trans, **kwd ): file_path = trans.app.config.file_path disk_usage = self.get_disk_usage( file_path ) min_file_size = 2**32 # 4 Gb file_size_str = nice_size( min_file_size ) - hda = trans.model.HistoryDatasetAssociation - d = trans.model.Dataset datasets = [] - where = ( d.table.c.file_size > min_file_size ) - dataset_rows = d.query().filter( where ).order_by( desc( d.table.c.file_size ) ) - - for dataset in dataset_rows: - history_dataset_assoc = hda.filter_by( dataset_id=dataset.id ).order_by( desc( hda.table.c.history_id ) ).all()[0] - datasets.append( ( dataset.id, str( dataset.update_time )[0:10], history_dataset_assoc.history_id, dataset.deleted, dataset.file_size ) ) + for dataset in trans.sa_session.query( model.Dataset ) \ + .filter( model.Dataset.table.c.file_size > min_file_size ) \ + .order_by( desc( model.Dataset.table.c.file_size ) ): + datasets.append( ( dataset.id, str( dataset.update_time )[0:10], dataset.history.history_id, dataset.deleted, dataset.file_size ) ) return file_path, disk_usage, datasets, file_size_str def nice_size( size ): @@ -191,4 +186,3 @@ def nice_size( size ): out = "%.1f %s" % ( size, word ) return out return '??? bytes' - diff --git a/lib/galaxy/webapps/reports/controllers/users.py b/lib/galaxy/webapps/reports/controllers/users.py index 6cb05b0a4a1..7e6398db52b 100644 --- a/lib/galaxy/webapps/reports/controllers/users.py +++ b/lib/galaxy/webapps/reports/controllers/users.py @@ -1,7 +1,7 @@ from datetime import * from time import strftime import calendar, operator -from galaxy.webapps.reports.base.controller import * +from galaxy.web.base.controller import * import galaxy.model from galaxy.model.orm import * import pkg_resources @@ -12,20 +12,15 @@ log = logging.getLogger( __name__ ) class Users( BaseController ): @web.expose - def index( self, trans, **kwd ): - params = util.Params( kwd ) - msg = params.get( 'msg', '' ) - return trans.fill_template( 'users.mako', msg=msg ) - @web.expose def registered_users( self, trans, **kwd ): params = util.Params( kwd ) - msg = params.get( 'msg', '' ) + message = params.get( 'message', '' ) num_users = trans.sa_session.query( galaxy.model.User ).count() - return trans.fill_template( 'registered_users.mako', num_users=num_users, msg=msg ) + return trans.fill_template( '/webapps/reports/registered_users.mako', num_users=num_users, message=message ) @web.expose def registered_users_per_month( self, trans, **kwd ): params = util.Params( kwd ) - msg = params.get( 'msg', '' ) + message = params.get( 'message', '' ) q = sa.select( ( sa.func.date_trunc( 'month', sa.func.date( galaxy.model.User.table.c.create_time ) ).label( 'date' ), sa.func.count( galaxy.model.User.table.c.id ).label( 'num_users' ) ), from_obj = [ galaxy.model.User.table ], @@ -37,11 +32,11 @@ class Users( BaseController ): row.num_users, row.date.strftime( "%B" ), row.date.strftime( "%Y" ) ) ) - return trans.fill_template( 'registered_users_per_month.mako', users=users, msg=msg ) + return trans.fill_template( '/webapps/reports/registered_users_per_month.mako', users=users, message=message ) @web.expose def specified_month( self, trans, **kwd ): params = util.Params( kwd ) - msg = params.get( 'msg', '' ) + message = params.get( 'message', '' ) year, month = map( int, params.get( 'month', datetime.utcnow().strftime( "%Y-%m" ) ).split( "-" ) ) start_date = date( year, month, 1 ) end_date = start_date + timedelta( days=calendar.monthrange( year, month )[1] ) @@ -60,16 +55,16 @@ class Users( BaseController ): row.date.strftime( "%d" ), row.num_users, row.date.strftime( "%A" ) ) ) - return trans.fill_template( 'registered_users_specified_month.mako', + return trans.fill_template( '/webapps/reports/registered_users_specified_month.mako', month_label=month_label, year_label=year_label, month=month, users=users, - msg=msg ) + message=message ) @web.expose def specified_date( self, trans, **kwd ): params = util.Params( kwd ) - msg = params.get( 'msg', '' ) + message = params.get( 'message', '' ) year, month, day = map( int, params.get( 'specified_date', datetime.utcnow().strftime( "%Y-%m-%d" ) ).split( "-" ) ) start_date = date( year, month, day ) end_date = start_date + timedelta( days=1 ) @@ -86,18 +81,18 @@ class Users( BaseController ): users = [] for row in q.execute(): users.append( ( row.email ) ) - return trans.fill_template( 'registered_users_specified_date.mako', + return trans.fill_template( '/webapps/reports/registered_users_specified_date.mako', specified_date=start_date, day_label=day_label, month_label=month_label, year_label=year_label, day_of_month=day_of_month, users=users, - msg=msg ) + message=message ) @web.expose def last_access_date( self, trans, **kwd ): params = util.Params( kwd ) - msg = params.get( 'msg', '' ) + message = params.get( 'message', '' ) not_logged_in_for_days = params.get( 'not_logged_in_for_days', 90 ) if not not_logged_in_for_days: not_logged_in_for_days = 0 @@ -115,7 +110,7 @@ class Users( BaseController ): # The user has never logged in users.append( ( user.email, "never logged in" ) ) users = sorted( users, key=operator.itemgetter( 1 ), reverse=True ) - return trans.fill_template( 'users_last_access_date.mako', + return trans.fill_template( '/webapps/reports/users_last_access_date.mako', users=users, not_logged_in_for_days=not_logged_in_for_days, - msg=msg ) + message=message ) diff --git a/lib/galaxy/webapps/reports/static/favicon.ico b/lib/galaxy/webapps/reports/static/favicon.ico deleted file mode 100644 index 74049dbe65b..00000000000 Binary files a/lib/galaxy/webapps/reports/static/favicon.ico and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/images/galaxyIcon_noText.png b/lib/galaxy/webapps/reports/static/images/galaxyIcon_noText.png deleted file mode 100644 index df696fc543c..00000000000 Binary files a/lib/galaxy/webapps/reports/static/images/galaxyIcon_noText.png and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/base.css.tmpl b/lib/galaxy/webapps/reports/static/january_2008_style/base.css.tmpl deleted file mode 100644 index ed9e8666f72..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/base.css.tmpl +++ /dev/null @@ -1,284 +0,0 @@ -@import url( "reset.css" ); - -body -{ - font: 75% verdana, "Bitstream Vera Sans", geneva, arial, helvetica, helve, sans-serif; - background: $base_bg_bottom; - color: $base_text; - background-image: url(base_bg.png); - background-repeat: repeat-x; - background-position: top; - margin: 10px; -} - -a:link, a:visited, a:active -{ - color: $link_text; -} - -h1, h2, h3, h4 -{ - color: $header_text; - /*text-shadow: #bbb 2px 2px 1px;*/ -} - -hr -{ - border: none; - border-bottom: dotted $base_text 1px; -} - -div.report -{ - border: solid $report_border 1px; -} - -div.reportTitle -{ - font-weight: bold; - padding: 5px; - padding-left: 10px; - padding-right: 10px; - background: $report_title_bg_bottom; - background-image: url(report_title_bg.png); - background-repeat: repeat-x; - background-position: top; - border-bottom: solid $report_border 1px; -} - -div.reportParamHelp -{ - color: #666; -} - -div.reportParamHelp a -{ - color: #666; -} - -div.reportBody -{ - background: $report_body_bg_bottom; - background-image: url(report_body_bg.png); - background-repeat: repeat-x; - background-position: top; - padding: 5px; - padding-left: 10px; - padding-right: 10px; -} - -div.reportBody div.reportTitle -{ - background: transparent; - border: none; - font-weight: bold; - border-bottom: solid $report_border 1px; - margin-bottom: 5px; -} - -div.reportDisabled div.reportTitle { - background: ${layout_bg}; - border-color: ${layout_border}; -} - -div.reportDisabled { - border-color: ${layout_border}; -} - -div.reportHelp -{ -} - -div.reportHelpBody -{ - width: 100%; - overflow: auto; -} - -div.titleRow { - font-weight: bold; - border-bottom: dotted gray 1px; - margin-bottom: 0.5em; - padding-bottom: 0.25em; -} - -div.report-row -{ - margin-bottom: 1em; -} - -div.report-title-row -{ - margin-bottom: 0.5em; -} - -div.report-row-error -{ - background: $error_message_bg; - padding: 5px; -} - -div.report-row label -{ - font-weight: bold; - display: block; - margin-bottom: .2em; -} - -/* Messages */ - -.errormessage, .warningmessage, .donemessage, .infomessage, .welcomeBlue, .welcomeRed -{ - padding: 10px; - padding-left: 52px; - min-height: 32px; - border: 1px solid $error_message_border; - background-color: $error_message_bg; - background-image: url(error_message_icon.png); - background-repeat: no-repeat; - background-position: 10px 10px; -} - -.warningmessage -{ - background-image: url(warn_message_icon.png); - border-color: $warn_message_border; - background-color: $warn_message_bg; -} - -.donemessage -{ - background-image: url(done_message_icon.png); - border-color: $done_message_border; - background-color: $done_message_bg; -} - -.infomessage -{ - background-image: url(info_message_icon.png); - border-color: $info_message_border; - background-color: $info_message_bg; -} - -.welcomeBlue -{ - padding-left: 10px; - border-color: $info_message_border; - background-color: $info_message_bg; - background-image: none; -} - -.welcomeRed -{ - padding-left: 10px; - border-color: $error_message_border; - background-color: $error_message_bg; - background-image: none; -} - -.errormessagesmall, .warningmessagesmall, .donemessagesmall, .infomessagesmall -{ - padding: 5px; - padding-left: 25px; - min-height: 25px; - border: 1px solid $error_message_border; - background-color: $error_message_bg; - background-image: url(error_small.png); - background-repeat: no-repeat; - background-position: 5px 5px; -} - -.warningmessagesmall -{ - background-image: url(warn_small.png); - border-color: $warn_message_border; - background-color: $warn_message_bg; -} - -.donemessagesmall -{ - background-image: url(ok_small.png); - border-color: $done_message_border; - background-color: $done_message_bg; -} - -.infomessagesmall -{ - background-image: url(info_small.png); - border-color: $info_message_border; - background-color: $info_message_bg; -} - -.ok_bgr -{ - background: #AEFF5E; - border: 1px #76EC00 solid; - border-color: #66CC00 #66CC00 #66CC00 #66CC00; -} - -.errormark, .warningmark, .donemark, .infomark, .err_bgr -{ - padding-left: 20px; - min-height: 15px; - background: url(error_small.png) no-repeat; -} - -.warningmark -{ - background-image: url(warn_small.png); -} - -.donemark -{ - background-image: url(ok_small.png); -} - -.infomark -{ - background-image: url(info_small.png); -} - -table.colored -{ - border-top: solid $table_border 1px; - border-bottom: solid $table_border 1px; -} - -table.colored td -{ - padding: 5px; -} - -table.colored tr.header -{ - background: $table_header_bg; - background-image: url(report_title_bg.png); - background-repeat: repeat-x; - background-position: top; - border-bottom: solid $table_border 1px; - font-weight: bold; -} - -table.colored tr -{ - background: $table_row_bg; -} - -table.colored tr.odd_row -{ - background: $odd_row_bg; -} - -div.debug -{ - margin: 10px; - padding: 5px; - background: #FFFF99; - border: solid #FFFF33 1px; - color: black; -} - -#footer { - display: none; -} - diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/base.css b/lib/galaxy/webapps/reports/static/january_2008_style/blue/base.css deleted file mode 100644 index a73e021ff0f..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/blue/base.css +++ /dev/null @@ -1,359 +0,0 @@ -@import url( "reset.css" ); - -body -{ - font: 75% verdana, "Bitstream Vera Sans", geneva, arial, helvetica, helve, sans-serif; - background: #FFFFFF; - color: #303030; - background-image: url(base_bg.png); - background-repeat: repeat-x; - background-position: top; - margin: 10px; -} - -a:link, a:visited, a:active -{ - color: #303030; -} - -h1, h2, h3, h4 -{ - color: #023858; - /*text-shadow: #bbb 2px 2px 1px;*/ -} - -hr -{ - border: none; - border-bottom: dotted #303030 1px; -} - -div.report -{ - border: solid #d8b365 1px; -} - -div.reportTitle -{ - font-weight: bold; - padding: 5px; - padding-left: 10px; - padding-right: 10px; - background: #d2c099; - background-image: url(report_title_bg.png); - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; -} - -div.reportParamHelp -{ - color: #666; -} - -div.reportParamHelp a -{ - color: #666; -} - -div.reportBody -{ - background: #FFFFFF; - background-repeat: repeat-x; - background-position: top; - padding: 5px; - padding-left: 10px; - padding-right: 10px; - width: 100%; - scrolling: no; -} - -div.reportBody div.reportTitle -{ - background: transparent; - border: none; - font-weight: bold; - border-bottom: solid #d8b365 1px; - margin-bottom: 5px; -} - -div.reportDisabled div.reportTitle { - background: #eee; - border-color: #999; -} - -div.reportDisabled { - border-color: #999; -} - -div.reportHelp -{ -} - -div.reportHelpBody -{ - width: 100%; - overflow: auto; -} - -div.titleRow { - font-weight: bold; - border-bottom: dotted gray 1px; - margin-bottom: 0.5em; - padding-bottom: 0.25em; -} - -div.report-row -{ - margin-bottom: 1em; -} - -div.report-title-row -{ - margin-bottom: 0.5em; -} - -div.report-row-error -{ - background: #FFCCCC; - padding: 5px; -} - -div.report-row label -{ - font-weight: bold; - display: block; - margin-bottom: .2em; -} - -/* Messages */ - -.errormessage, .warningmessage, .donemessage, .infomessage, .welcomeBlue, .welcomeRed -{ - padding: 10px; - padding-left: 52px; - min-height: 32px; - border: 1px solid #AA6666; - background-color: #FFCCCC; - background-image: url(error_message_icon.png); - background-repeat: no-repeat; - background-position: 10px 10px; -} - -.warningmessage -{ - background-image: url(warn_message_icon.png); - border-color: #AAAA66; - background-color: #FFFFCC; -} - -.donemessage -{ - background-image: url(done_message_icon.png); - border-color: #66AA66; - background-color: #CCFFCC; -} - -.infomessage -{ - background-image: url(info_message_icon.png); - border-color: #6666AA; - background-color: #CCCCFF; -} - -.welcomeBlue -{ - padding-left: 10px; - border-color: #6666AA; - background-color: #CCCCFF; - background-image: none; -} - -.welcomeRed -{ - padding-left: 10px; - border-color: #AA6666; - background-color: #FFCCCC; - background-image: none; -} - -.errormessagesmall, .warningmessagesmall, .donemessagesmall, .infomessagesmall -{ - padding: 5px; - padding-left: 25px; - min-height: 25px; - border: 1px solid #AA6666; - background-color: #FFCCCC; - background-image: url(error_small.png); - background-repeat: no-repeat; - background-position: 5px 5px; -} - -.warningmessagesmall -{ - background-image: url(warn_small.png); - border-color: #AAAA66; - background-color: #FFFFCC; -} - -.donemessagesmall -{ - background-image: url(ok_small.png); - border-color: #66AA66; - background-color: #CCFFCC; -} - -.infomessagesmall -{ - background-image: url(info_small.png); - border-color: #6666AA; - background-color: #CCCCFF; -} - -.ok_bgr -{ - background: #AEFF5E; - border: 1px #76EC00 solid; - border-color: #66CC00 #66CC00 #66CC00 #66CC00; -} - -.errormark, .warningmark, .donemark, .infomark, .err_bgr -{ - padding-left: 20px; - min-height: 15px; - background: url(error_small.png) no-repeat; -} - -.warningmark -{ - background-image: url(warn_small.png); -} - -.donemark -{ - background-image: url(ok_small.png); -} - -.infomark -{ - background-image: url(info_small.png); -} - -table.colored -{ - border-top: solid #d8b365 1px; - border-bottom: solid #d8b365 1px; -} - -table.colored td -{ - padding: 5px; -} - -table.colored tr.header -{ - background: #EBD9B2; - background-image: url(report_title_bg.png); - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headernew -{ - background: #ADD8E6; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerwaiting -{ - background: #FF6600; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerqueued -{ - background: #EE82EE; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerrunning -{ - background: #FFFF00; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headererror -{ - background: #FF0000; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerdeleted -{ - background: #9900FF; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerok -{ - background: #008000; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerupload -{ - background: #336699; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr.headerunknown -{ - background: #FF6666; - background-repeat: repeat-x; - background-position: top; - border-bottom: solid #d8b365 1px; - font-weight: bold; -} -table.colored tr -{ - background: white; -} - -table.colored tr.odd_row -{ - background: #FFFF99; -} - -div.debug -{ - margin: 10px; - padding: 5px; - background: #FFFF99; - border: solid #FFFF33 1px; - color: black; -} - -#footer { - display: none; -} - -pre { - font-size: 80%; -} diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/base_bg.png b/lib/galaxy/webapps/reports/static/january_2008_style/blue/base_bg.png deleted file mode 100644 index c3a59afc2bb..00000000000 Binary files a/lib/galaxy/webapps/reports/static/january_2008_style/blue/base_bg.png and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/footer_title_bg.png b/lib/galaxy/webapps/reports/static/january_2008_style/blue/footer_title_bg.png deleted file mode 100644 index c747d95f587..00000000000 Binary files a/lib/galaxy/webapps/reports/static/january_2008_style/blue/footer_title_bg.png and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead.css b/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead.css deleted file mode 100644 index f206e7f1b44..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead.css +++ /dev/null @@ -1,26 +0,0 @@ -body -{ - background: #2C3143 url(masthead_bg.png) bottom; - color: #eeeeee; - padding: 0; - border: 0; - margin: 3px; - margin-right: 5px; - margin-left: 5px; -} - -div.pageTitle -{ - font-size: 175%; - font-weight: bold; -} - -div.pageTitle a:link, div.pageTitle a:visited, div.pageTitle a:active, div.pageTitle a:hover -{ - text-decoration: none; -} - -a:link, a:visited, a:active -{ - color: #eeeeee; -} diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead_bg.png b/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead_bg.png deleted file mode 100644 index 67fc014516d..00000000000 Binary files a/lib/galaxy/webapps/reports/static/january_2008_style/blue/masthead_bg.png and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue/report_title_bg.png b/lib/galaxy/webapps/reports/static/january_2008_style/blue/report_title_bg.png deleted file mode 100644 index dd7599aa3b7..00000000000 Binary files a/lib/galaxy/webapps/reports/static/january_2008_style/blue/report_title_bg.png and /dev/null differ diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/blue_colors.ini b/lib/galaxy/webapps/reports/static/january_2008_style/blue_colors.ini deleted file mode 100644 index bdb19687358..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/blue_colors.ini +++ /dev/null @@ -1,62 +0,0 @@ -base_text=#303030 -base_bg_top=#FFFFFF -base_bg_bottom=#FFFFFF -link_text=#303030 -header_text=#023858 -menu_bg_top=#DADFEF -menu_bg_over=#C1C9E5 -menu_bg_hatch=- -#menu_bg_hatch=#AAAAFF -# Forms -report_title_bg_top=#ebd9b2 -report_title_bg_bottom=#d2c099 -report_title_bg_hatch=- -report_border=#d8b365 -report_body_bg=#FFFFFF -report_body_bg_top=#FFFFFF -report_body_bg_bottom=#FFFFFF -odd_row_bg=#FFFF99 -# Messages -error_message_border=#AA6666 -error_message_bg=#FFCCCC -warn_message_border=#AAAA66 -warn_message_bg=#FFFFCC -done_message_border=#66AA66 -done_message_bg=#CCFFCC -info_message_border=#6666AA -info_message_bg=#CCCCFF -# Tables -table_header_bg=#ebd9b2 -table_row_bg=white -table_border=#d8b365 -# Footers -footer_bg=#023858 -footer_title_bg=#023858 -footer_title_hatch=#000000 -# History -history_error_border=#AA6666 -history_error_bg=#FFCCCC -history_running_border=#AAAA66 -history_running_bg=#FFFFCC -history_ok_border=#66AA66 -history_ok_bg=#CCFFCC -history_queued_border=#888888 -history_queued_bg=#EEEEEE -peek_table_header=#023858 -# Masthead -masthead_bg=#2C3143 -masthead_text=#eeeeee -masthead_bg_hatch=- -masthead_link=#eeeeee -# ---- Layout ----------------------------------------------------------------- -# Overall background color (including space between panels) -layout_bg=#eee -# Line underneath masthead -layout_masthead_border=#444 -# Borders around panels -layout_border=#999 -# Hover color when mouse over drag bars (panel resize) -layout_hover=#AAAAEE -# Gradient for the panel title backgrounds -panel_header_bg_top=#f5f5f5 -panel_header_bg_bottom=#cccccc \ No newline at end of file diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/gradient.py b/lib/galaxy/webapps/reports/static/january_2008_style/gradient.py deleted file mode 100755 index 3a857c189e9..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/gradient.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python - -""" -usage: %prog width height bg_color hatch_color [color alpha stop_pos] + -""" - -from __future__ import division - -import sys -import cairo - -assert sys.version_info[:2] >= ( 2, 4 ) - -def parse_css_color( color ): - if color.startswith( '#' ): - color = color[1:] - if len( color ) == 3: - r = int( color[0], 16 ) - g = int( color[1], 16 ) - b = int( color[2], 16 ) - elif len( color ) == 6: - r = int( color[0:2], 16 ) - g = int( color[2:4], 16 ) - b = int( color[4:6], 16 ) - else: - raise Exception( "Color should be 3 hex numbers" ) - return r/256, g/256, b/256 - -def gradient( width, height, args ): - pat = cairo.LinearGradient(0.0, 0.0, 0.0, height) - while len( args ) > 2: - col = parse_css_color( args[0] ) - alpha = float( args[1]) - pos = float( args[2] ) - pat.add_color_stop_rgba( pos, col[0], col[1], col[2], alpha ) - args = args[3:] - return pat - -def hatch( width, height, color ): - im_surf = cairo.ImageSurface( cairo.FORMAT_ARGB32, width, width ) - c = cairo.Context( im_surf ) - c.set_source_rgb ( *color ) - c.set_line_width( 0.75 ) - for i in range( 0, 2*max(height,width), 3 ): - c.move_to ( 0-10, i+10 ) - c.line_to ( width+10, i - width - 10 ) - c.stroke() - pat = cairo.SurfacePattern( im_surf ) - pat.set_extend (cairo.EXTEND_REPEAT) - return pat - -width = int( sys.argv[1] ) -height = int( sys.argv[2] ) - -surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, width, height ) -c = cairo.Context( surface ) - -c.rectangle(0,0,width,height) -c.set_source_rgb( *parse_css_color( sys.argv[3] ) ) -c.fill() - -if sys.argv[4] != "-": - c.rectangle (0, 0, width, height) - c.set_source( hatch( width, height, parse_css_color( sys.argv[4] ) ) ) - c.fill() - -pat = cairo.LinearGradient(0.0, 0.0, 0.0, height) -pat.add_color_stop_rgba( 0, 1, 1, 1, 0 ) -pat.add_color_stop_rgba( 1, 1, 1, 1, 1 ) -c.rectangle (0, 0, width, height) -c.set_source( gradient( width, height, sys.argv[5:] ) ) -c.fill() - -surface.write_to_png( "/dev/stdout" ) diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/make_style.py b/lib/galaxy/webapps/reports/static/january_2008_style/make_style.py deleted file mode 100755 index 6ceb32d368c..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/make_style.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python - -import pkg_resources; -pkg_resources.require( "Cheetah" ) - -import sys -from Cheetah.Template import Template -import string -from subprocess import Popen, PIPE -import os.path - -assert sys.version_info[:2] >= ( 2, 4 ) - -def run( cmd ): - return Popen( cmd, stdout=PIPE).communicate()[0] - -templates = [ ( "masthead.css.tmpl", "masthead.css"), - ( "base.css.tmpl", "base.css" ) ] - -images = [ - ( "./gradient.py 9 1000 $base_bg_top - $base_bg_bottom 0 0 $base_bg_bottom 1 1", "base_bg.png" ), - ( "./gradient.py 9 50 $masthead_bg $masthead_bg_hatch", "masthead_bg.png" ), - ( "./gradient.py 9 30 $footer_title_bg $footer_title_hatch 000000 0 0.5 000000 1 1", "footer_title_bg.png" ) - ] - -vars, out_dir = sys.argv[1:] - -context = dict() -for line in open( vars ): - line = line.rstrip( '\r\n' ) - if line and not line.startswith( '#' ): - key, value = line.split( '=' ) - if value.startswith( '"' ) and value.endswith( '"' ): - value = value[1:-1] - context[key] = value - -for input, output in templates: - print input ,"->", output - open( os.path.join( out_dir, output ), "w" ).write( str( Template( file=input, searchList=[context] ) ) ) - -for rule, output in images: - t = string.Template( rule ).substitute( context ) - print t, "->", output - open( os.path.join( out_dir, output ), "w" ).write( run( t.split() ) ) - diff --git a/lib/galaxy/webapps/reports/static/january_2008_style/masthead.css.tmpl b/lib/galaxy/webapps/reports/static/january_2008_style/masthead.css.tmpl deleted file mode 100644 index 0c759f2aba6..00000000000 --- a/lib/galaxy/webapps/reports/static/january_2008_style/masthead.css.tmpl +++ /dev/null @@ -1,26 +0,0 @@ -body -{ - background: $masthead_bg url(masthead_bg.png) bottom; - color: $masthead_text; - padding: 0; - border: 0; - margin: 3px; - margin-right: 5px; - margin-left: 5px; -} - -div.pageTitle -{ - font-size: 175%; - font-weight: bold; -} - -div.pageTitle a:link, div.pageTitle a:visited, div.pageTitle a:active, div.pageTitle a:hover -{ - text-decoration: none; -} - -a:link, a:visited, a:active -{ - color: $masthead_link; -} diff --git a/lib/galaxy/webapps/reports/static/scripts/IE7.js b/lib/galaxy/webapps/reports/static/scripts/IE7.js deleted file mode 100644 index c02f3756e64..00000000000 --- a/lib/galaxy/webapps/reports/static/scripts/IE7.js +++ /dev/null @@ -1,2205 +0,0 @@ -// timestamp: Sun, 03 Feb 2008 19:26:22 -/* - IE7/IE8.js - copyright 2004-2008, Dean Edwards - http://dean.edwards.name/IE7/ - http://www.opensource.org/licenses/mit-license.php -*/ - -/* W3C compliance for Microsoft Internet Explorer */ - -/* credits/thanks: - Shaggy, Martijn Wargers, Jimmy Cerra, Mark D Anderson, - Lars Dieckow, Erik Arvidsson, Gellért Gyuris, James Denny, - Unknown W Brackets, Benjamin Westfarer, Rob Eberhardt, - Bill Edney, Kevin Newman, James Crompton, Matthew Mastracci, - Doug Wright, Richard York, Kenneth Kolano, MegaZone, - Thomas Verelst, Mark 'Tarquin' Wilton-Jones, Rainer Åhlfors, - David Zulaica, Ken Kolano, Kevin Newman -*/ - -// ======================================================================= -// TO DO -// ======================================================================= - -// PNG - unclickable content - -// ======================================================================= -// TEST/BUGGY -// ======================================================================= - -// hr{margin:1em auto} (doesn't look right in IE5) - -(function() { - -IE7 = { - toString: function(){return "IE7 version 2.0 (beta3)"} -}; -var appVersion = IE7.appVersion = navigator.appVersion.match(/MSIE (\d\.\d)/)[1]; - -if (/ie7_off/.test(top.location.search) || appVersion < 5) return; - -var Undefined = K(); -var quirksMode = document.compatMode != "CSS1Compat"; -var documentElement = document.documentElement, body, viewport; -var ANON = "!"; -var HEADER = ":link{ie7-link:link}:visited{ie7-link:visited}"; - -// ----------------------------------------------------------------------- -// external -// ----------------------------------------------------------------------- - -var RELATIVE = /^[\w\.]+[^:]*$/; -function makePath(href, path) { - if (RELATIVE.test(href)) href = (path || "") + href; - return href; -}; - -function getPath(href, path) { - href = makePath(href, path); - return href.slice(0, href.lastIndexOf("/") + 1); -}; - -// get the path to this script -var script = document.scripts[document.scripts.length - 1]; -var path = getPath(script.src); - -// we'll use microsoft's http request object to load external files -try { - var httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); -} catch (e) { - // ActiveX disabled -} - -var fileCache = {}; -function loadFile(href, path) { -try { - href = makePath(href, path); - if (!fileCache[href]) { - // easy to load a file huh? - httpRequest.open("GET", href, false); - httpRequest.send(); - if (httpRequest.status == 0 || httpRequest.status == 200) { - fileCache[href] = httpRequest.responseText; - } - } -} catch (e) { - // ignore errors -} finally { - return fileCache[href] || ""; -}}; - -// ----------------------------------------------------------------------- -// IE5.0 compatibility -// ----------------------------------------------------------------------- - - -if (appVersion < 5.5) { - undefined = Undefined(); - - ANON = "HTML:!"; // for anonymous content - - // Fix String.replace (Safari1.x/IE5.0). - var GLOBAL = /(g|gi)$/; - var _String_replace = String.prototype.replace; - String.prototype.replace = function(expression, replacement) { - if (typeof replacement == "function") { // Safari doesn't like functions - if (expression && expression.constructor == RegExp) { - var regexp = expression; - var global = regexp.global; - if (global == null) global = GLOBAL.test(regexp); - // we have to convert global RexpExps for exec() to work consistently - if (global) regexp = new RegExp(regexp.source); // non-global - } else { - regexp = new RegExp(rescape(expression)); - } - var match, string = this, result = ""; - while (string && (match = regexp.exec(string))) { - result += string.slice(0, match.index) + replacement.apply(this, match); - string = string.slice(match.index + match[0].length); - if (!global) break; - } - return result + string; - } - return _String_replace.apply(this, arguments); - }; - - Array.prototype.pop = function() { - if (this.length) { - var i = this[this.length - 1]; - this.length--; - return i; - } - return undefined; - }; - - Array.prototype.push = function() { - for (var i = 0; i < arguments.length; i++) { - this[this.length] = arguments[i]; - } - return this.length; - }; - - var ns = this; - Function.prototype.apply = function(o, a) { - if (o === undefined) o = ns; - else if (o == null) o = window; - else if (typeof o == "string") o = new String(o); - else if (typeof o == "number") o = new Number(o); - else if (typeof o == "boolean") o = new Boolean(o); - if (arguments.length == 1) a = []; - else if (a[0] && a[0].writeln) a[0] = a[0].documentElement.document || a[0]; - var $ = "#ie7_apply", r; - o[$] = this; - switch (a.length) { // unroll for speed - case 0: r = o[$](); break; - case 1: r = o[$](a[0]); break; - case 2: r = o[$](a[0],a[1]); break; - case 3: r = o[$](a[0],a[1],a[2]); break; - case 4: r = o[$](a[0],a[1],a[2],a[3]); break; - case 5: r = o[$](a[0],a[1],a[2],a[3],a[4]); break; - default: - var b = [], i = a.length - 1; - do b[i] = "a[" + i + "]"; while (i--); - eval("r=o[$](" + b + ")"); - } - if (typeof o.valueOf == "function") { // not a COM object - delete o[$]; - } else { - o[$] = undefined; - if (r && r.writeln) r = r.documentElement.document || r; - } - return r; - }; - - Function.prototype.call = function(o) { - return this.apply(o, _slice.apply(arguments, [1])); - }; - - // block elements are "inline" according to IE5.0 so we'll fix it - HEADER += "address,blockquote,body,dd,div,dt,fieldset,form,"+ - "frame,frameset,h1,h2,h3,h4,h5,h6,iframe,noframes,object,p,"+ - "hr,applet,center,dir,menu,pre,dl,li,ol,ul{display:block}"; -} - -// ----------------------------------------------------------------------- -// OO support -// ----------------------------------------------------------------------- - - -// This is a cut-down version of base2 (http://code.google.com/p/base2/) - -var _slice = Array.prototype.slice; - -// private -var _FORMAT = /%([1-9])/g; -var _LTRIM = /^\s\s*/; -var _RTRIM = /\s\s*$/; -var _RESCAPE = /([\/()[\]{}|*+-.,^$?\\])/g; // safe regular expressions -var _BASE = /\bbase\b/; -var _HIDDEN = ["constructor", "toString"]; // only override these when prototyping - -var prototyping; - -function Base(){}; -Base.extend = function(_instance, _static) { - // Build the prototype. - prototyping = true; - var _prototype = new this; - extend(_prototype, _instance); - prototyping = false; - - // Create the wrapper for the constructor function. - var _constructor = _prototype.constructor; - function klass() { - // Don't call the constructor function when prototyping. - if (!prototyping) _constructor.apply(this, arguments); - }; - _prototype.constructor = klass; - - // Build the static interface. - klass.extend = arguments.callee; - extend(klass, _static); - klass.prototype = _prototype; - return klass; -}; -Base.prototype.extend = function(source) { - return extend(this, source); -}; - -// A collection of regular expressions and their associated replacement values. -// A Base class for creating parsers. - -var _HASH = "#"; -var _KEYS = "~"; - -var _RG_ESCAPE_CHARS = /\\./g; -var _RG_ESCAPE_BRACKETS = /\(\?[:=!]|\[[^\]]+\]/g; -var _RG_BRACKETS = /\(/g; - -var RegGrp = Base.extend({ - constructor: function(values) { - this[_KEYS] = []; - this.merge(values); - }, - - exec: function(string) { - var items = this, keys = this[_KEYS]; - return String(string).replace(new RegExp(this, this.ignoreCase ? "gi" : "g"), function() { - var item, offset = 1, i = 0; - // Loop through the RegGrp items. - while ((item = items[_HASH + keys[i++]])) { - var next = offset + item.length + 1; - if (arguments[offset]) { // do we have a result? - var replacement = item.replacement; - switch (typeof replacement) { - case "function": - return replacement.apply(items, _slice.call(arguments, offset, next)); - case "number": - return arguments[offset + replacement]; - default: - return replacement; - } - } - offset = next; - } - }); - }, - - add: function(expression, replacement) { - if (expression instanceof RegExp) { - expression = expression.source; - } - if (!this[_HASH + expression]) this[_KEYS].push(String(expression)); - this[_HASH + expression] = new RegGrp.Item(expression, replacement); - }, - - merge: function(values) { - for (var i in values) this.add(i, values[i]); - }, - - toString: function() { - // back references not supported in simple RegGrp - return "(" + this[_KEYS].join(")|(") + ")"; - } -}, { - IGNORE: "$0", - - Item: Base.extend({ - constructor: function(expression, replacement) { - expression = expression instanceof RegExp ? expression.source : String(expression); - - if (typeof replacement == "number") replacement = String(replacement); - else if (replacement == null) replacement = ""; - - // does the pattern use sub-expressions? - if (typeof replacement == "string" && /\$(\d+)/.test(replacement)) { - // a simple lookup? (e.g. "$2") - if (/^\$\d+$/.test(replacement)) { - // store the index (used for fast retrieval of matched strings) - replacement = parseInt(replacement.slice(1)); - } else { // a complicated lookup (e.g. "Hello $2 $1") - // build a function to do the lookup - var Q = /'/.test(replacement.replace(/\\./g, "")) ? '"' : "'"; - replacement = replacement.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\$(\d+)/g, Q + - "+(arguments[$1]||" + Q+Q + ")+" + Q); - replacement = new Function("return " + Q + replacement.replace(/(['"])\1\+(.*)\+\1\1$/, "$1") + Q); - } - } - - this.length = RegGrp.count(expression); - this.replacement = replacement; - this.toString = K(expression); - } - }), - - count: function(expression) { - // Count the number of sub-expressions in a RegExp/RegGrp.Item. - expression = String(expression).replace(_RG_ESCAPE_CHARS, "").replace(_RG_ESCAPE_BRACKETS, ""); - return match(expression, _RG_BRACKETS).length; - } -}); - -// ========================================================================= -// lang/extend.js -// ========================================================================= - -function extend(object, source) { // or extend(object, key, value) - if (object && source) { - var proto = (typeof source == "function" ? Function : Object).prototype; - // Add constructor, toString etc - var i = _HIDDEN.length, key; - if (prototyping) while (key = _HIDDEN[--i]) { - var value = source[key]; - if (value != proto[key]) { - if (_BASE.test(value)) { - _override(object, key, value) - } else { - object[key] = value; - } - } - } - // Copy each of the source object's properties to the target object. - for (key in source) if (proto[key] === undefined) { - var value = source[key]; - // Check for method overriding. - if (object[key] && typeof value == "function" && _BASE.test(value)) { - _override(object, key, value); - } else { - object[key] = value; - } - } - } - return object; -}; - -function _override(object, name, method) { - // Override an existing method. - var ancestor = object[name]; - object[name] = function() { - var previous = this.base; - this.base = ancestor; - var returnValue = method.apply(this, arguments); - this.base = previous; - return returnValue; - }; -}; - -function combine(keys, values) { - // Combine two arrays to make a hash. - if (!values) values = keys; - var hash = {}; - for (var i in keys) hash[i] = values[i]; - return hash; -}; - -function format(string) { - // Replace %n with arguments[n]. - // e.g. format("%1 %2%3 %2a %1%3", "she", "se", "lls"); - // ==> "she sells sea shells" - // Only %1 - %9 supported. - var args = arguments; - var _FORMAT = new RegExp("%([1-" + arguments.length + "])", "g"); - return String(string).replace(_FORMAT, function(match, index) { - return index < args.length ? args[index] : match; - }); -}; - -function match(string, expression) { - // Same as String.match() except that this function will return an empty - // array if there is no match. - return String(string).match(expression) || []; -}; - -function rescape(string) { - // Make a string safe for creating a RegExp. - return String(string).replace(_RESCAPE, "\\$1"); -}; - -// http://blog.stevenlevithan.com/archives/faster-trim-javascript -function trim(string) { - return String(string).replace(_LTRIM, "").replace(_RTRIM, ""); -}; - -function K(k) { - return function() { - return k; - }; -}; - -// ----------------------------------------------------------------------- -// parsing -// ----------------------------------------------------------------------- - -var Parser = RegGrp.extend({ignoreCase: true}); - -var ENCODED = /\x01(\d+)/g, - QUOTES = /'/g, - STRING = /^\x01/, - UNICODE = /\\([\da-fA-F]{1,4})/g; - -var _strings = []; - -var encoder = new Parser({ - // comments - "": "", - "\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\/": "", - // get rid - "@(namespace|import)[^;\\n]+[;\\n]": "", - // strings - "'(\\\\.|[^'\\\\])*'": encodeString, - '"(\\\\.|[^"\\\\])*"': encodeString, - // white space - "\\s+": " " -}); - -function encode(cssText) { - return encoder.exec(cssText); -}; - -function decode(cssText) { - return cssText.replace(ENCODED, function(match, index) { - return _strings[index - 1]; - }); -}; - -function encodeString(string) { - return "\x01" + _strings.push(string.replace(UNICODE, function(match, chr) { - return eval("'\\u" + "0000".slice(chr.length) + chr + "'"); - }).slice(1, -1).replace(QUOTES, "\\'")); -}; - -function getString(value) { - return STRING.test(value) ? _strings[value.slice(1) - 1] : value; -}; - -// clone a "width" function to create a "height" function -var rotater = new RegGrp({ - Width: "Height", - width: "height", - Left: "Top", - left: "top", - Right: "Bottom", - right: "bottom", - onX: "onY" -}); - -function rotate(fn) { - return rotater.exec(fn); -}; - -// ----------------------------------------------------------------------- -// event handling -// ----------------------------------------------------------------------- - -var eventHandlers = []; - -function addResize(handler) { - addRecalc(handler); - addEventHandler(window, "onresize", handler); -}; - -// add an event handler (function) to an element -function addEventHandler(element, type, handler) { - element.attachEvent(type, handler); - // store the handler so it can be detached later - eventHandlers.push(arguments); -}; - -// remove an event handler assigned to an element by IE7 -function removeEventHandler(element, type, handler) { -try { - element.detachEvent(type, handler); -} catch (ignore) { - // write a letter of complaint to microsoft.. -}}; - -// remove event handlers (they eat memory) -addEventHandler(window, "onunload", function() { - var handler; - while (handler = eventHandlers.pop()) { - removeEventHandler(handler[0], handler[1], handler[2]); - } -}); - -function register(handler, element, condition) { // -@DRE - //var set = handler[element.uniqueID]; - if (!handler.elements) handler.elements = {}; - if (condition) handler.elements[element.uniqueID] = element; - else delete handler.elements[element.uniqueID]; - //return !set && condition; - return condition; -}; - -addEventHandler(window, "onbeforeprint", function() { - if (!IE7.CSS.print) new StyleSheet("print"); - IE7.CSS.print.recalc(); -}); - -// ----------------------------------------------------------------------- -// pixel conversion -// ----------------------------------------------------------------------- - -// this is handy because it means that web developers can mix and match -// measurement units in their style sheets. it is not uncommon to -// express something like padding in "em" units whilst border thickness -// is most often expressed in pixels. - -var PIXEL = /^\d+(px)?$/i; -var PERCENT = /^\d+%$/; -var getPixelValue = function(element, value) { - if (PIXEL.test(value)) return parseInt(value); - var style = element.style.left; - var runtimeStyle = element.runtimeStyle.left; - element.runtimeStyle.left = element.currentStyle.left; - element.style.left = value || 0; - value = element.style.pixelLeft; - element.style.left = style; - element.runtimeStyle.left = runtimeStyle; - return value; -}; - -// ----------------------------------------------------------------------- -// generic -// ----------------------------------------------------------------------- - -var $IE7 = "ie7-"; - -var Fix = Base.extend({ - constructor: function() { - this.fixes = []; - this.recalcs = []; - }, - init: Undefined -}); - -// a store for functions that will be called when refreshing IE7 -var recalcs = []; -function addRecalc(recalc) { - recalcs.push(recalc); -}; - -IE7.recalc = function() { - IE7.HTML.recalc(); - // re-apply style sheet rules (re-calculate ie7 classes) - IE7.CSS.recalc(); - // apply global fixes to the document - for (var i = 0; i < recalcs.length; i++) recalcs[i](); -}; - -function isFixed(element) { - return element.currentStyle["ie7-position"] == "fixed"; -}; - -// original style -function getDefinedStyle(element, propertyName) { - return element.currentStyle[$IE7 + propertyName] || element.currentStyle[propertyName]; -}; - -function setOverrideStyle(element, propertyName, value) { - if (element.currentStyle[$IE7 + propertyName] == null) { - element.runtimeStyle[$IE7 + propertyName] = element.currentStyle[propertyName]; - } - element.runtimeStyle[propertyName] = value; -}; - -// create a temporary element which is used to inherit styles -// from the target element. the temporary element can be resized -// to determine pixel widths/heights -function createTempElement(tagName) { - var element = document.createElement(tagName || "object"); - element.style.cssText = "position:absolute;padding:0;display:block;border:none;clip:rect(0 0 0 0);left:-9999"; - element.ie7_anon = true; - return element; -}; - - -// ========================================================================= -// ie7-cssQuery.js -// ========================================================================= - -function cssQuery(selector, context, single) { - if (!_cache[selector]) { - reg = []; // store for RegExp objects - var fn = ""; - var selectors = cssParser.escape(selector).split(","); - for (var i = 0; i < selectors.length; i++) { - _wild = _index = _list = 0; // reset - _duplicate = selectors.length > 1 ? 2 : 0; // reset - var block = cssParser.exec(selectors[i]) || "if(0){"; - if (_wild) { // IE's pesky comment nodes - block += format("if(e%1.nodeName!='!'){", _index); - } - // check for duplicates before storing results - var store = _duplicate > 1 ? _TEST : ""; - block += format(store + _STORE, _index); - // add closing braces - block += Array(match(block, /\{/g).length + 1).join("}"); - fn += block; - } - eval(format(_FN, reg) + cssParser.unescape(fn) + "return s?null:r}"); - _cache[selector] = _selectorFunction; - } - return _cache[selector](context || document, single); -}; - -var _MSIE5 = appVersion < 6; - -var _EVALUATED = /^(href|src)$/; -var _ATTRIBUTES = { - "class": "className", - "for": "htmlFor" -}; - -IE7._indexed = 1; - -IE7._byId = function(document, id) { - var result = document.all[id] || null; - // returns a single element or a collection - if (!result || result.id == id) return result; - // document.all has returned a collection of elements with name/id - for (var i = 0; i < result.length; i++) { - if (result[i].id == id) return result[i]; - } - return null; -}; - -IE7._getAttribute = function(element, name) { - if (name == "src" && element.pngSrc) return element.pngSrc; - - var attribute = _MSIE5 ? (element.attributes[name] || element.attributes[_ATTRIBUTES[name.toLowerCase()]]) : element.getAttributeNode(name); - if (attribute && (attribute.specified || name == "value")) { - if (_EVALUATED.test(name)) { - return element.getAttribute(name, 2); - } else if (name == "class") { - return element.className.replace(/\sie7_\w+/g, ""); - } else if (name == "style") { - return element.style.cssText; - } else { - return attribute.nodeValue; - } - } - return null; -}; - -var names = "colSpan,rowSpan,vAlign,dateTime,accessKey,tabIndex,encType,maxLength,readOnly,longDesc"; -// Convert the list of strings to a hash, mapping the lowercase name to the camelCase name. -extend(_ATTRIBUTES, combine(names.toLowerCase().split(","), names.split(","))); - -IE7._getNextElementSibling = function(node) { - // return the next element to the supplied element - // nextSibling is not good enough as it might return a text or comment node - while (node && (node = node.nextSibling) && (node.nodeType != 1 || node.nodeName == "!")) continue; - return node; -}; - -IE7._getPreviousElementSibling = function(node) { - // return the previous element to the supplied element - while (node && (node = node.previousSibling) && (node.nodeType != 1 || node.nodeName == "!")) continue; - return node; -}; - -// ========================================================================= -// CSSParser -// ========================================================================= - -var IMPLIED_ASTERISK = /([\s>+~,]|[^(]\+|^)([#.:\[])/g, - IMPLIED_SPACE = /(^|,)([^\s>+~])/g, - WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g, - WILD_CARD = /\s\*\s/g;; - -var CSSParser = RegGrp.extend({ - constructor: function(items) { - this.base(items); - this.sorter = new RegGrp; - this.sorter.add(/:not\([^)]*\)/, RegGrp.IGNORE); - this.sorter.add(/([ >](\*|[\w-]+))([^: >+~]*)(:\w+-child(\([^)]+\))?)([^: >+~]*)/, "$1$3$6$4"); - }, - - ignoreCase: true, - - escape: function(selector) { - return this.optimise(this.format(selector)); - }, - - format: function(selector) { - return selector - .replace(WHITESPACE, "$1") - .replace(IMPLIED_SPACE, "$1 $2") - .replace(IMPLIED_ASTERISK, "$1*$2"); - }, - - optimise: function(selector) { - // optimise wild card descendant selectors - return this.sorter.exec(selector.replace(WILD_CARD, ">* ")); - }, - - unescape: function(selector) { - return decode(selector); - } -}); - -// some constants -var _OPERATORS = { - "": "%1!=null", - "=": "%1=='%2'", - "~=": /(^| )%1( |$)/, - "|=": /^%1(-|$)/, - "^=": /^%1/, - "$=": /%1$/, - "*=": /%1/ -}; - -var _PSEUDO_CLASSES = { - "first-child": "!IE7._getPreviousElementSibling(e%1)", - "link": "e%1.currentStyle['ie7-link']=='link'", - "visited": "e%1.currentStyle['ie7-link']=='visited'" -}; - -var _VAR = "var p%2=0,i%2,e%2,n%2=e%1."; -var _ID = "e%1.sourceIndex"; -var _TEST = "var g=" + _ID + ";if(!p[g]){p[g]=1;"; -var _STORE = "r[r.length]=e%1;if(s)return e%1;"; -var _FN = "var _selectorFunction=function(e0,s){IE7._indexed++;var r=[],p={},reg=[%1],d=document;"; -var reg; // a store for RexExp objects -var _index; -var _wild; // need to flag certain _wild card selectors as MSIE includes comment nodes -var _list; // are we processing a node _list? -var _duplicate; // possible duplicates? -var _cache = {}; // store parsed selectors - -// a hideous parser -var cssParser = new CSSParser({ - " (\\*|[\\w-]+)#([\\w-]+)": function(match, tagName, id) { // descendant selector followed by ID - _wild = false; - var replacement = "var e%2=IE7._byId(d,'%4');if(e%2&&"; - if (tagName != "*") replacement += "e%2.nodeName=='%3'&&"; - replacement += "(e%1==d||e%1.contains(e%2))){"; - if (_list) replacement += format("i%1=n%1.length;", _list); - return format(replacement, _index++, _index, tagName.toUpperCase(), id); - }, - - " (\\*|[\\w-]+)": function(match, tagName) { // descendant selector - _duplicate++; // this selector may produce duplicates - _wild = tagName == "*"; - var replacement = _VAR; - // IE5.x does not support getElementsByTagName("*"); - replacement += (_wild && _MSIE5) ? "all" : "getElementsByTagName('%3')"; - replacement += ";for(i%2=0;(e%2=n%2[i%2]);i%2++){"; - return format(replacement, _index++, _list = _index, tagName.toUpperCase()); - }, - - ">(\\*|[\\w-]+)": function(match, tagName) { // child selector - var children = _list; - _wild = tagName == "*"; - var replacement = _VAR; - // use the children property for MSIE as it does not contain text nodes - // (but the children collection still includes comments). - // the document object does not have a children collection - replacement += children ? "children": "childNodes"; - if (!_wild && children) replacement += ".tags('%3')"; - replacement += ";for(i%2=0;(e%2=n%2[i%2]);i%2++){"; - if (_wild) { - replacement += "if(e%2.nodeType==1){"; - _wild = _MSIE5; - } else { - if (!children) replacement += "if(e%2.nodeName=='%3'){"; - } - return format(replacement, _index++, _list = _index, tagName.toUpperCase()); - }, - - "\\+(\\*|[\\w-]+)": function(match, tagName) { // direct adjacent selector - var replacement = ""; - if (_wild) replacement += "if(e%1.nodeName!='!'){"; - _wild = false; - replacement += "e%1=IE7._getNextElementSibling(e%1);if(e%1"; - if (tagName != "*") replacement += "&&e%1.nodeName=='%2'"; - replacement += "){"; - return format(replacement, _index, tagName.toUpperCase()); - }, - - "~(\\*|[\\w-]+)": function(match, tagName) { // indirect adjacent selector - var replacement = ""; - if (_wild) replacement += "if(e%1.nodeName!='!'){"; - _wild = false; - _duplicate = 2; // this selector may produce duplicates - replacement += "while(e%1=e%1.nextSibling){if(e%1.ie7_adjacent==IE7._indexed)break;if("; - if (tagName == "*") { - replacement += "e%1.nodeType==1"; - if (_MSIE5) replacement += "&&e%1.nodeName!='!'"; - } else replacement += "e%1.nodeName=='%2'"; - replacement += "){e%1.ie7_adjacent=IE7._indexed;"; - return format(replacement, _index, tagName.toUpperCase()); - }, - - "#([\\w-]+)": function(match, id) { // ID selector - _wild = false; - var replacement = "if(e%1.id=='%2'){"; - if (_list) replacement += format("i%1=n%1.length;", _list); - return format(replacement, _index, id); - }, - - "\\.([\\w-]+)": function(match, className) { // class selector - _wild = false; - // store RegExp objects - slightly faster on IE - reg.push(new RegExp("(^|\\s)" + rescape(className) + "(\\s|$)")); - return format("if(e%1.className&®[%2].test(e%1.className)){", _index, reg.length - 1); - }, - - "\\[([\\w-]+)\\s*([^=]?=)?\\s*([^\\]]*)\\]": function(match, attr, operator, value) { // attribute selectors - var alias = _ATTRIBUTES[attr] || attr; - if (operator) { - var getAttribute = "e%1.getAttribute('%2',2)"; - if (!_EVALUATED.test(attr)) { - getAttribute = "e%1.%3||" + getAttribute; - } - attr = format("(" + getAttribute + ")", _index, attr, alias); - } else { - attr = format("IE7._getAttribute(e%1,'%2')", _index, attr); - } - var replacement = _OPERATORS[operator || ""] || "0"; - if (replacement && replacement.source) { - reg.push(new RegExp(format(replacement.source, rescape(cssParser.unescape(value))))); - replacement = "reg[%2].test(%1)"; - value = reg.length - 1; - } - return "if(" + format(replacement, attr, value) + "){"; - }, - - ":+([\\w-]+)(\\(([^)]+)\\))?": function(match, pseudoClass, $2, args) { // pseudo class selectors - pseudoClass = _PSEUDO_CLASSES[pseudoClass]; - return "if(" + (pseudoClass ? format(pseudoClass, _index, args || "") : "0") + "){"; - } -}); - -// ========================================================================= -// ie7-css.js -// ========================================================================= - -var HYPERLINK = /a(#[\w-]+)?(\.[\w-]+)?:(hover|active)/i; -var BRACE1 = /\s*\{\s*/, BRACE2 = /\s*\}\s*/, COMMA = /\s*\,\s*/; -var FIRST_LINE_LETTER = /(.*)(:first-(line|letter))/; - -//var UNKNOWN = /UNKNOWN|([:.])\w+\1/i; - -var styleSheets = document.styleSheets; - -IE7.CSS = new (Fix.extend({ // single instance - parser: new Parser, - screen: "", - print: "", - styles: [], - rules: [], - pseudoClasses: appVersion < 7 ? "first\\-child" : "", - dynamicPseudoClasses: { - toString: function() { - var strings = []; - for (var pseudoClass in this) strings.push(pseudoClass); - return strings.join("|"); - } - }, - - init: function() { - var NONE = "^\x01$"; - var CLASS = "\\[class=?[^\\]]*\\]"; - var pseudoClasses = []; - if (this.pseudoClasses) pseudoClasses.push(this.pseudoClasses); - var dynamicPseudoClasses = this.dynamicPseudoClasses.toString(); - if (dynamicPseudoClasses) pseudoClasses.push(dynamicPseudoClasses); - pseudoClasses = pseudoClasses.join("|"); - var unknown = appVersion < 7 ? ["[>+~[(]|([:.])\\w+\\1"] : [CLASS]; - if (pseudoClasses) unknown.push(":(" + pseudoClasses + ")"); - this.UNKNOWN = new RegExp(unknown.join("|") || NONE, "i"); - var complex = appVersion < 7 ? ["\\[[^\\]]+\\]|[^\\s(\\[]+\\s*[+~]"] : [CLASS]; - var complexRule = complex.concat(); - if (pseudoClasses) complexRule.push(":(" + pseudoClasses + ")"); - Rule.COMPLEX = new RegExp(complexRule.join("|") || NONE, "ig"); - if (this.pseudoClasses) complex.push(":(" + this.pseudoClasses + ")"); - DynamicRule.COMPLEX = new RegExp(complex.join("|") || NONE, "i"); - DynamicRule.MATCH = new RegExp(dynamicPseudoClasses ? "(.*):(" + dynamicPseudoClasses + ")(.*)" : NONE, "i"); - - this.createStyleSheet(); - this.refresh(); - }, - - addEventHandler: function() { - addEventHandler.apply(null, arguments); - }, - - addFix: function(expression, replacement) { - this.parser.add(expression, replacement); - }, - - addRecalc: function(propertyName, test, handler, replacement) { - // recalcs occur whenever the document is refreshed using document.recalc() - test = new RegExp("([{;\\s])" + propertyName + "\\s*:\\s*" + test + "[^;}]*"); - var id = this.recalcs.length; - if (replacement) replacement = propertyName + ":" + replacement; - this.addFix(test, function(match, $1) { - return (replacement ? $1 + replacement : match) + ";ie7-" + match.slice(1) + ";ie7_recalc" + id + ":1"; - }); - this.recalcs.push(arguments); - return id; - }, - - apply: function() { - this.getInlineStyles(); - new StyleSheet("screen"); - this.trash(); - }, - - createStyleSheet: function() { - // create the IE7 style sheet - this.styleSheet = document.createStyleSheet(); - // flag it so we can ignore it during parsing - this.styleSheet.ie7 = true; - this.styleSheet.owningElement.ie7 = true; - this.styleSheet.cssText = HEADER; - }, - - getInlineStyles: function() { - // load inline styles - var styleSheets = document.getElementsByTagName("style"), styleSheet; - for (var i = styleSheets.length - 1; (styleSheet = styleSheets[i]); i--) { - if (!styleSheet.disabled && !styleSheet.ie7) { - this.styles.push(styleSheet.innerHTML); - } - } - }, - - getText: function(styleSheet, path) { - // explorer will trash unknown selectors (it converts them to "UNKNOWN"). - // so we must reload external style sheets (internal style sheets can have their text - // extracted through the innerHTML property). - // load the style sheet text from an external file - try { - var cssText = styleSheet.cssText; - } catch (e) { - cssText = ""; - } - if (httpRequest) cssText = loadFile(styleSheet.href, path) || cssText; - return cssText; - }, - - recalc: function() { - this.screen.recalc(); - // we're going to read through all style rules. - // certain rules have had ie7 properties added to them. - // e.g. p{top:0; ie7_recalc2:1; left:0} - // this flags a property in the rule as needing a fix. - // the selector text is then used to query the document. - // we can then loop through the results of the query - // and fix the elements. - // we ignore the IE7 rules - so count them in the header - var RECALCS = /ie7_recalc\d+/g; - var start = HEADER.match(/[{,]/g).length; - // only calculate screen fixes. print fixes don't show up anyway - var stop = start + (this.screen.cssText.match(/\{/g)||"").length; - var rules = this.styleSheet.rules, rule; - var calcs, calc, elements, element, i, j, k, id; - // loop through all rules - for (i = start; i < stop; i++) { - rule = rules[i]; - var cssText = rule.style.cssText; - // search for the "ie7_recalc" flag (there may be more than one) - if (rule && (calcs = cssText.match(RECALCS))) { - // use the selector text to query the document - elements = cssQuery(rule.selectorText); - // if there are matching elements then loop - // through the recalc functions and apply them - // to each element - if (elements.length) for (j = 0; j < calcs.length; j++) { - // get the matching flag (e.g. ie7_recalc3) - id = calcs[j]; - // extract the numeric id from the end of the flag - // and use it to index the collection of recalc - // functions - calc = IE7.CSS.recalcs[id.slice(10)][2]; - for (k = 0; (element = elements[k]); k++) { - // apply the fix - if (element.currentStyle[id]) calc(element, cssText); - } - } - } - } - }, - - refresh: function() { - this.styleSheet.cssText = HEADER + this.screen + this.print; - }, - - trash: function() { - // trash the old style sheets - for (var i = 0; i < styleSheets.length; i++) { - if (!styleSheets[i].ie7) { - try { - var cssText = styleSheets[i].cssText; - } catch (e) { - cssText = ""; - } - if (cssText) styleSheets[i].cssText = ""; - } - } - } -})); - -// ----------------------------------------------------------------------- -// IE7 StyleSheet class -// ----------------------------------------------------------------------- - -var StyleSheet = Base.extend({ - constructor: function(media) { - this.media = media; - this.load(); - IE7.CSS[media] = this; - IE7.CSS.refresh(); - }, - - createRule: function(selector, cssText) { - if (IE7.CSS.UNKNOWN.test(selector)) { - var match; - if (PseudoElement && (match = selector.match(PseudoElement.MATCH))) { - return new PseudoElement(match[1], match[2], cssText); - } else if (match = selector.match(DynamicRule.MATCH)) { - if (!HYPERLINK.test(match[0]) || DynamicRule.COMPLEX.test(match[0])) { - return new DynamicRule(selector, match[1], match[2], match[3], cssText); - } - } else return new Rule(selector, cssText); - } - return selector + " {" + cssText + "}"; - }, - - getText: function() { - // store for style sheet text - var _inlineStyles = [].concat(IE7.CSS.styles); - // parse media decalarations - var MEDIA = /@media\s+([^{]*)\{([^@]+\})\s*\}/gi; - var ALL = /\ball\b|^$/i, SCREEN = /\bscreen\b/i, PRINT = /\bprint\b/i; - function _parseMedia(cssText, media) { - _filterMedia.value = media; - return cssText.replace(MEDIA, _filterMedia); - }; - function _filterMedia(match, media, cssText) { - media = _simpleMedia(media); - switch (media) { - case "screen": - case "print": - if (media != _filterMedia.value) return ""; - case "all": - return cssText; - } - return ""; - }; - function _simpleMedia(media) { - if (ALL.test(media)) return "all"; - else if (SCREEN.test(media)) return (PRINT.test(media)) ? "all" : "screen"; - else if (PRINT.test(media)) return "print"; - }; - var self = this; - function _getCSSText(styleSheet, path, media, level) { - var cssText = ""; - if (!level) { - media = _simpleMedia(styleSheet.media); - level = 0; - } - if (media == "all" || media == self.media) { - // IE only allows importing style sheets three levels deep. - // it will crash if you try to access a level below this - if (level < 3) { - // loop through imported style sheets - for (var i = 0; i < styleSheet.imports.length; i++) { - // call this function recursively to get all imported style sheets - cssText += _getCSSText(styleSheet.imports[i], getPath(styleSheet.href, path), media, level + 1); - } - } - // retrieve inline style or load an external style sheet - cssText += encode(styleSheet.href ? _loadStyleSheet(styleSheet, path) : _inlineStyles.pop() || ""); - cssText = _parseMedia(cssText, self.media); - } - return cssText; - }; - // store loaded cssText URLs - var fileCache = {}; - // load an external style sheet - function _loadStyleSheet(styleSheet, path) { - var url = makePath(styleSheet.href, path); - // if the style sheet has already loaded then don't duplicate it - if (fileCache[url]) return ""; - // load from source - fileCache[url] = (styleSheet.disabled) ? "" : - _fixUrls(IE7.CSS.getText(styleSheet, path), getPath(styleSheet.href, path)); - return fileCache[url]; - }; - // fix css paths - // we're lumping all css text into one big style sheet so relative - // paths have to be fixed. this is necessary anyway because of other - // explorer bugs. - var URL = /(url\s*\(\s*['"]?)([\w\.]+[^:\)]*['"]?\))/gi; - function _fixUrls(cssText, pathname) { - // hack & slash - return cssText.replace(URL, "$1" + pathname.slice(0, pathname.lastIndexOf("/") + 1) + "$2"); - }; - - // load all style sheets in the document - for (var i = 0; i < styleSheets.length; i++) { - if (!styleSheets[i].disabled && !styleSheets[i].ie7) { - this.cssText += _getCSSText(styleSheets[i]); - } - } - }, - - load: function() { - this.cssText = ""; - this.getText(); - this.parse(); - this.cssText = decode(this.cssText); - fileCache = {}; - }, - - parse: function() { - this.cssText = IE7.CSS.parser.exec(this.cssText); - - // parse the style sheet - var offset = IE7.CSS.rules.length; - var rules = this.cssText.split(BRACE2), rule; - var selectors, cssText, i, j; - for (i = 0; i < rules.length; i++) { - rule = rules[i].split(BRACE1); - selectors = rule[0].split(COMMA); - cssText = rule[1]; - for (j = 0; j < selectors.length; j++) { - selectors[j] = cssText ? this.createRule(selectors[j], cssText) : ""; - } - rules[i] = selectors.join("\n"); - } - this.cssText = rules.join("\n"); - this.rules = IE7.CSS.rules.slice(offset); - }, - - recalc: function() { - var rule, i; - for (i = 0; (rule = this.rules[i]); i++) rule.recalc(); - }, - - toString: function() { - return "@media " + this.media + "{" + this.cssText + "}"; - } -}); - -var PseudoElement; - -// ----------------------------------------------------------------------- -// IE7 style rules -// ----------------------------------------------------------------------- - -var Rule = IE7.Rule = Base.extend({ - // properties - constructor: function(selector, cssText) { - this.id = IE7.CSS.rules.length; - this.className = Rule.PREFIX + this.id; - selector = selector.match(FIRST_LINE_LETTER) || selector || "*"; - this.selector = selector[1] || selector; - this.selectorText = this.parse(this.selector) + (selector[2] || ""); - this.cssText = cssText; - this.MATCH = new RegExp("\\s" + this.className + "(\\s|$)", "g"); - IE7.CSS.rules.push(this); - this.init(); - }, - - init: Undefined, - - add: function(element) { - // allocate this class - element.className += " " + this.className; - }, - - recalc: function() { - // execute the underlying css query for this class - var match = cssQuery(this.selector); - // add the class name for all matching elements - for (var i = 0; i < match.length; i++) this.add(match[i]); - }, - - parse: function(selector) { - // attempt to preserve specificity for "loose" parsing by - // removing unknown tokens from a css selector but keep as - // much as we can.. - var simple = selector.replace(Rule.CHILD, " ").replace(Rule.COMPLEX, ""); - if (appVersion < 7) simple = simple.replace(Rule.MULTI, ""); - var tags = match(simple, Rule.TAGS).length - match(selector, Rule.TAGS).length; - var classes = match(simple, Rule.CLASSES).length - match(selector, Rule.CLASSES).length + 1; - while (classes > 0 && Rule.CLASS.test(simple)) { - simple = simple.replace(Rule.CLASS, ""); - classes--; - } - while (tags > 0 && Rule.TAG.test(simple)) { - simple = simple.replace(Rule.TAG, "$1*"); - tags--; - } - simple += "." + this.className; - classes = Math.min(classes, 2); - tags = Math.min(tags, 2); - var score = -10 * classes - tags; - if (score > 0) { - simple = simple + "," + Rule.MAP[score] + " " + simple; - } - return simple; - }, - - remove: function(element) { - // deallocate this class - element.className = element.className.replace(this.MATCH, "$1"); - }, - - toString: function() { - return format("%1 {%2}", this.selectorText, this.cssText); - } -}, { - CHILD: />/g, - CLASS: /\.[\w-]+/, - CLASSES: /[.:\[]/g, - MULTI: /(\.[\w-]+)+/g, - PREFIX: "ie7_class", - TAG: /^\w+|([\s>+~])\w+/, - TAGS: /^\w|[\s>+~]\w/g, - MAP: { - 1: "html", - 2: "html body", - 10: ".ie7_html", - 11: "html.ie7_html", - 12: "html.ie7_html body", - 20: ".ie7_html .ie7_body", - 21: "html.ie7_html .ie7_body", - 22: "html.ie7_html body.ie7_body" - } -}); - -// ----------------------------------------------------------------------- -// IE7 dynamic style -// ----------------------------------------------------------------------- - -// object properties: -// attach: the element that an event handler will be attached to -// target: the element that will have the IE7 class applied - -var DynamicRule = Rule.extend({ - // properties - constructor: function(selector, attach, dynamicPseudoClass, target, cssText) { - // initialise object properties - this.attach = attach || "*"; - this.dynamicPseudoClass = IE7.CSS.dynamicPseudoClasses[dynamicPseudoClass]; - this.target = target; - this.base(selector, cssText); - }, - - recalc: function() { - // execute the underlying css query for this class - var attaches = cssQuery(this.attach), attach; - // process results - for (var i = 0; attach = attaches[i]; i++) { - // retrieve the event handler's target element(s) - var target = this.target ? cssQuery(this.target, attach) : [attach]; - // attach event handlers for dynamic pseudo-classes - if (target.length) this.dynamicPseudoClass.apply(attach, target, this); - } - } -}); - -// ----------------------------------------------------------------------- -// IE7 dynamic pseudo-classes -// ----------------------------------------------------------------------- - -var DynamicPseudoClass = Base.extend({ - constructor: function(name, apply) { - this.name = name; - this.apply = apply; - this.instances = {}; - IE7.CSS.dynamicPseudoClasses[name] = this; - }, - - register: function(instance) { - // an "instance" is actually an Arguments object - var _class = instance[2]; - instance.id = _class.id + instance[0].uniqueID; - if (!this.instances[instance.id]) { - var target = instance[1], j; - for (j = 0; j < target.length; j++) _class.add(target[j]); - this.instances[instance.id] = instance; - } - }, - - unregister: function(instance) { - if (this.instances[instance.id]) { - var _class = instance[2]; - var target = instance[1], j; - for (j = 0; j < target.length; j++) _class.remove(target[j]); - delete this.instances[instance.id]; - } - } -}); - -// ----------------------------------------------------------------------- -// dynamic pseudo-classes -// ----------------------------------------------------------------------- - -if (appVersion < 7) { - var Hover = new DynamicPseudoClass("hover", function(element) { - var instance = arguments; - IE7.CSS.addEventHandler(element, appVersion < 5.5 ? "onmouseover" : "onmouseenter", function() { - Hover.register(instance); - }); - IE7.CSS.addEventHandler(element, appVersion < 5.5 ? "onmouseout" : "onmouseleave", function() { - Hover.unregister(instance); - }); - }); - - // globally trap the mouseup event (thanks Martijn!) - addEventHandler(document, "onmouseup", function() { - var instances = Hover.instances; - for (var i in instances) - if (!instances[i][0].contains(event.srcElement)) - Hover.unregister(instances[i]); - }); -} - -// ----------------------------------------------------------------------- -// propertyName: inherit; -// ----------------------------------------------------------------------- - -IE7.CSS.addRecalc("[\\w-]+", "inherit", function(element, cssText) { - var inherited = cssText.match(/[\w-]+\s*:\s*inherit/g); - for (var i = 0; i < inherited.length; i++) { - var propertyName = inherited[i].replace(/ie7\-|\s*:\s*inherit/g, "").replace(/\-([a-z])/g, function(match, chr) { - return chr.toUpperCase() - }); - element.runtimeStyle[propertyName] = element.parentElement.currentStyle[propertyName]; - } -}); - -// ========================================================================= -// ie7-html.js -// ========================================================================= - -// default font-sizes -//HEADER += "h1{font-size:2em}h2{font-size:1.5em;}h3{font-size:1.17em;}h4{font-size:1em}h5{font-size:.83em}h6{font-size:.67em}"; - -IE7.HTML = new (Fix.extend({ // single instance - fixed: {}, - - init: Undefined, - - addFix: function() { - // fixes are a one-off, they are applied when the document is loaded - this.fixes.push(arguments); - }, - - apply: function() { - for (var i = 0; i < this.fixes.length; i++) { - var match = cssQuery(this.fixes[i][0]); - var fix = this.fixes[i][1]; - for (var j = 0; j < match.length; j++) fix(match[j]); - } - }, - - addRecalc: function() { - // recalcs occur whenever the document is refreshed using document.recalc() - this.recalcs.push(arguments); - }, - - recalc: function() { - // loop through the fixes - for (var i = 0; i < this.recalcs.length; i++) { - var match = cssQuery(this.recalcs[i][0]); - var recalc = this.recalcs[i][1], element; - var key = Math.pow(2, i); - for (var j = 0; (element = match[j]); j++) { - var uniqueID = element.uniqueID; - if ((this.fixed[uniqueID] & key) == 0) { - element = recalc(element) || element; - this.fixed[uniqueID] |= key; - } - } - } - } -})); - -if (appVersion < 7) { - // provide support for the tag. - // this is a proper fix, it preserves the DOM structure and - // elements report the correct tagName & namespace prefix - document.createElement("abbr"); - - // bind to the first child control - IE7.HTML.addRecalc("label", function(label) { - if (!label.htmlFor) { - var firstChildControl = cssQuery("input,textarea", label, true); - if (firstChildControl) { - addEventHandler(label, "onclick", function() { - firstChildControl.click(); - }); - } - } - }); -} - -// ========================================================================= -// ie7-layout.js -// ========================================================================= - -var NUMERIC = "[.\\d]"; - -new function(_) { -var layout = IE7.Layout = this; - - // big, ugly box-model hack + min/max stuff - - // #tantek > #erik > #dean { voice-family: hacker; } - - // ----------------------------------------------------------------------- - // "layout" - // ----------------------------------------------------------------------- - - HEADER += "*{boxSizing:content-box}"; - - // does an element have "layout" ? - IE7.hasLayout = appVersion < 5.5 ? function(element) { - // element.currentStyle.hasLayout doesn't work for IE5.0 - return element.clientWidth; - } : function(element) { - return element.currentStyle.hasLayout; - }; - - // give an element "layout" - layout.boxSizing = function(element) { - if (!IE7.hasLayout(element)) { - //# element.runtimeStyle.fixedHeight = - element.style.height = "0cm"; - if (element.currentStyle.verticalAlign == "auto") - element.runtimeStyle.verticalAlign = "top"; - // when an element acquires "layout", margins no longer collapse correctly - collapseMargins(element); - } - }; - - // ----------------------------------------------------------------------- - // Margin Collapse - // ----------------------------------------------------------------------- - - function collapseMargins(element) { - if (element != viewport && element.currentStyle.position != "absolute") { - collapseMargin(element, "marginTop"); - collapseMargin(element, "marginBottom"); - } - }; - - function collapseMargin(element, type) { - if (!element.runtimeStyle[type]) { - var parentElement = element.parentElement; - if (parentElement && IE7.hasLayout(parentElement) && !IE7[type == "marginTop" ? "_getPreviousElementSibling" : "_getNextElementSibling"](element)) return; - var child = cssQuery(">*:" + (type == "marginTop" ? "first" : "last") + "-child", element, true); - if (child && child.currentStyle.styleFloat == "none" && IE7.hasLayout(child)) { - collapseMargin(child, type); - margin = _getMargin(element, element.currentStyle[type]); - childMargin = _getMargin(child, child.currentStyle[type]); - if (margin < 0 || childMargin < 0) { - element.runtimeStyle[type] = margin + childMargin; - } else { - element.runtimeStyle[type] = Math.max(childMargin, margin); - } - child.runtimeStyle[type] = "0px"; - } - } - }; - - function _getMargin(element, value) { - return value == "auto" ? 0 : getPixelValue(element, value); - }; - - // ----------------------------------------------------------------------- - // box-model - // ----------------------------------------------------------------------- - - // constants - var UNIT = /^[.\d][\w%]*$/, AUTO = /^(auto|0cm)$/; - - var applyWidth, applyHeight; - IE7.Layout.borderBox = function(element){ - applyWidth(element); - applyHeight(element); - }; - - var fixWidth = function(HEIGHT) { - applyWidth = function(element) { - if (!PERCENT.test(element.currentStyle.width)) fixWidth(element); - collapseMargins(element); - }; - - function fixWidth(element, value) { - if (!element.runtimeStyle.fixedWidth) { - if (!value) value = element.currentStyle.width; - element.runtimeStyle.fixedWidth = (UNIT.test(value)) ? Math.max(0, getFixedWidth(element, value)) : value; - setOverrideStyle(element, "width", element.runtimeStyle.fixedWidth); - } - }; - - function layoutWidth(element) { - if (!isFixed(element)) { - var layoutParent = element.offsetParent; - while (layoutParent && !IE7.hasLayout(layoutParent)) layoutParent = layoutParent.offsetParent; - } - return (layoutParent || viewport).clientWidth; - }; - - function getPixelWidth(element, value) { - if (PERCENT.test(value)) return parseInt(parseFloat(value) / 100 * layoutWidth(element)); - return getPixelValue(element, value); - }; - - var getFixedWidth = function(element, value) { - var borderBox = element.currentStyle["box-sizing"] == "border-box"; - var adjustment = 0; - if (quirksMode && !borderBox) - adjustment += getBorderWidth(element) + getWidth(element, "padding"); - else if (!quirksMode && borderBox) - adjustment -= getBorderWidth(element) + getWidth(element, "padding"); - return getPixelWidth(element, value) + adjustment; - }; - - // easy way to get border thickness for elements with "layout" - function getBorderWidth(element) { - return element.offsetWidth - element.clientWidth; - }; - - // have to do some pixel conversion to get padding/margin thickness :-( - function getWidth(element, type) { - return getPixelWidth(element, element.currentStyle[type + "Left"]) + getPixelWidth(element, element.currentStyle[type + "Right"]); - }; - - // ----------------------------------------------------------------------- - // min/max - // ----------------------------------------------------------------------- - - HEADER += "*{minWidth:none;maxWidth:none;min-width:none;max-width:none}"; - - // handle min-width property - layout.minWidth = function(element) { - // IE6 supports min-height so we frig it here - //#if (element.currentStyle.minHeight == "auto") element.runtimeStyle.minHeight = 0; - if (element.currentStyle["min-width"] != null) { - element.style.minWidth = element.currentStyle["min-width"]; - } - if (register(arguments.callee, element, element.currentStyle.minWidth != "none")) { - layout.boxSizing(element); - fixWidth(element); - resizeWidth(element); - } - }; - - // clone the minWidth function to make a maxWidth function - eval("IE7.Layout.maxWidth=" + String(layout.minWidth).replace(/min/g, "max")); - - // apply min/max restrictions - function resizeWidth(element) { - // check boundaries - var rect = element.getBoundingClientRect(); - var width = rect.right - rect.left; - - if (element.currentStyle.minWidth != "none" && width <= getFixedWidth(element, element.currentStyle.minWidth)) { - element.runtimeStyle.width = element.currentStyle.minWidth; - } else if (element.currentStyle.maxWidth != "none" && width >= getFixedWidth(element, element.currentStyle.maxWidth)) { - element.runtimeStyle.width = element.currentStyle.maxWidth; - } else { - element.runtimeStyle.width = element.runtimeStyle.fixedWidth; // || "auto"; - } - }; - - // ----------------------------------------------------------------------- - // right/bottom - // ----------------------------------------------------------------------- - - function fixRight(element) { - if (register(fixRight, element, /^(fixed|absolute)$/.test(element.currentStyle.position) && - getDefinedStyle(element, "left") != "auto" && - getDefinedStyle(element, "right") != "auto" && - AUTO.test(getDefinedStyle(element, "width")))) { - resizeRight(element); - IE7.Layout.boxSizing(element); - } - }; - IE7.Layout.fixRight = fixRight; - - function resizeRight(element) { - var left = getPixelWidth(element, element.runtimeStyle._left || element.currentStyle.left); - var width = layoutWidth(element) - getPixelWidth(element, element.currentStyle.right) - left - getWidth(element, "margin"); - if (parseInt(element.runtimeStyle.width) == width) return; - element.runtimeStyle.width = ""; - if (isFixed(element) || HEIGHT || element.offsetWidth < width) { - if (!quirksMode) width -= getBorderWidth(element) + getWidth(element, "padding"); - if (width < 0) width = 0; - element.runtimeStyle.fixedWidth = width; - setOverrideStyle(element, "width", width); - } - }; - - // ----------------------------------------------------------------------- - // window.onresize - // ----------------------------------------------------------------------- - - // handle window resize - var clientWidth = 0; - addResize(function() { - if (!viewport) return; - var i, wider = (clientWidth < viewport.clientWidth); - clientWidth = viewport.clientWidth; - // resize elements with "min-width" set - var elements = layout.minWidth.elements; - for (i in elements) { - var element = elements[i]; - var fixedWidth = (parseInt(element.runtimeStyle.width) == getFixedWidth(element, element.currentStyle.minWidth)); - if (wider && fixedWidth) element.runtimeStyle.width = ""; - if (wider == fixedWidth) resizeWidth(element); - } - // resize elements with "max-width" set - var elements = layout.maxWidth.elements; - for (i in elements) { - var element = elements[i]; - var fixedWidth = (parseInt(element.runtimeStyle.width) == getFixedWidth(element, element.currentStyle.maxWidth)); - if (!wider && fixedWidth) element.runtimeStyle.width = ""; - if (wider != fixedWidth) resizeWidth(element); - } - // resize elements with "right" set - for (i in fixRight.elements) resizeRight(fixRight.elements[i]); - }); - - // ----------------------------------------------------------------------- - // fix CSS - // ----------------------------------------------------------------------- - if (quirksMode) { - IE7.CSS.addRecalc("width", NUMERIC, applyWidth); - } - if (appVersion < 7) { - IE7.CSS.addRecalc("min-width", NUMERIC, layout.minWidth); - IE7.CSS.addRecalc("max-width", NUMERIC, layout.maxWidth); - IE7.CSS.addRecalc("right", NUMERIC, fixRight); - } - }; - - eval("var fixHeight=" + rotate(fixWidth)); - - // apply box-model + min/max fixes - fixWidth(); - fixHeight(true); -}; - -// ========================================================================= -// ie7-graphics.js -// ========================================================================= - -// a small transparent image used as a placeholder -var BLANK_GIF = makePath("blank.gif", path); - -var ALPHA_IMAGE_LOADER = "DXImageTransform.Microsoft.AlphaImageLoader"; -var PNG_FILTER = "progid:" + ALPHA_IMAGE_LOADER + "(src='%1',sizingMethod='%2')"; - -// regular expression version of the above -var PNG; - -var filtered = []; - -function fixImage(element) { - if (PNG.test(element.src)) { - // we have to preserve width and height - var image = new Image(element.width, element.height); - image.onload = function() { - element.width = image.width; - element.height = image.height; - image = null; - }; - image.src = element.src; - // store the original url (we'll put it back when it's printed) - element.pngSrc = element.src; - // add the AlphaImageLoader thingy - addFilter(element); - } -}; - -if (appVersion >= 5.5 && appVersion < 7) { - // ** IE7 VARIABLE - // e.g. only apply the hack to files ending in ".png" - // IE7_PNG_SUFFIX = ".png"; - - // replace background(-image): url(..) .. with background(-image): .. ;filter: ..; - IE7.CSS.addFix(/background(-image)?\s*:\s*([^};]*)?url\(([^\)]+)\)([^;}]*)?/, function(match, $1, $2, url, $4) { - url = getString(url); - return PNG.test(url) ? "filter:" + format(PNG_FILTER, url, "crop") + - ";zoom:1;background" + ($1||"") + ":" + ($2||"") + "none" + ($4||"") : match; - }); - - // ----------------------------------------------------------------------- - // fix PNG transparency (HTML images) - // ----------------------------------------------------------------------- - - IE7.HTML.addRecalc("img,input", function(element) { - if (element.tagName == "INPUT" && element.type != "image") return; - fixImage(element); - addEventHandler(element, "onpropertychange", function() { - if (!printing && event.propertyName == "src" && - element.src.indexOf(BLANK_GIF) == -1) fixImage(element); - }); - }); - - // assume that background images should not be printed - // (if they are not transparent then they'll just obscure content) - // but we'll put foreground images back... - var printing = false; - addEventHandler(window, "onbeforeprint", function() { - printing = true; - for (var i = 0; i < filtered.length; i++) removeFilter(filtered[i]); - }); - addEventHandler(window, "onafterprint", function() { - for (var i = 0; i < filtered.length; i++) addFilter(filtered[i]); - printing = false; - }); -} - -// apply a filter -function addFilter(element, sizingMethod) { - var filter = element.filters[ALPHA_IMAGE_LOADER]; - if (filter) { - filter.src = element.src; - filter.enabled = true; - } else { - element.runtimeStyle.filter = format(PNG_FILTER, element.src, sizingMethod || "scale"); - filtered.push(element); - } - // remove the real image - element.src = BLANK_GIF; -}; - -function removeFilter(element) { - element.src = element.pngSrc; - element.filters[ALPHA_IMAGE_LOADER].enabled = false; -}; - -// ========================================================================= -// ie7-fixed.js -// ========================================================================= - -new function(_) { - if (appVersion >= 7) return; - - // some things to consider for this hack. - // the document body requires a fixed background. even if - // it is just a blank image. - // you have to use setExpression instead of onscroll, this - // together with a fixed body background helps avoid the - // annoying screen flicker of other solutions. - - IE7.CSS.addRecalc("position", "fixed", _positionFixed, "absolute"); - IE7.CSS.addRecalc("background(-attachment)?", "[^};]*fixed", _backgroundFixed); - - // scrolling is relative to the documentElement (HTML tag) when in - // standards mode, otherwise it's relative to the document body - var $viewport = quirksMode ? "body" : "documentElement"; - - function _fixBackground() { - // this is required by both position:fixed and background-attachment:fixed. - // it is necessary for the document to also have a fixed background image. - // we can fake this with a blank image if necessary - if (body.currentStyle.backgroundAttachment != "fixed") { - if (body.currentStyle.backgroundImage == "none") { - body.runtimeStyle.backgroundRepeat = "no-repeat"; - body.runtimeStyle.backgroundImage = "url(" + BLANK_GIF + ")"; // dummy - } - body.runtimeStyle.backgroundAttachment = "fixed"; - } - _fixBackground = Undefined; - }; - - var _tmp = createTempElement("img"); - - function _isFixed(element) { - return element ? isFixed(element) || _isFixed(element.parentElement) : false; - }; - - function _setExpression(element, propertyName, expression) { - setTimeout("document.all." + element.uniqueID + ".runtimeStyle.setExpression('" + propertyName + "','" + expression + "')", 0); - }; - - // ----------------------------------------------------------------------- - // backgroundAttachment: fixed - // ----------------------------------------------------------------------- - - function _backgroundFixed(element) { - if (register(_backgroundFixed, element, element.currentStyle.backgroundAttachment == "fixed" && !element.contains(body))) { - _fixBackground(); - bgLeft(element); - bgTop(element); - _backgroundPosition(element); - } - }; - - function _backgroundPosition(element) { - _tmp.src = element.currentStyle.backgroundImage.slice(5, -2); - var parentElement = element.canHaveChildren ? element : element.parentElement; - parentElement.appendChild(_tmp); - setOffsetLeft(element); - setOffsetTop(element); - parentElement.removeChild(_tmp); - }; - - function bgLeft(element) { - element.style.backgroundPositionX = element.currentStyle.backgroundPositionX; - if (!_isFixed(element)) { - _setExpression(element, "backgroundPositionX", "(parseInt(runtimeStyle.offsetLeft)+document." + $viewport + ".scrollLeft)||0"); - } - }; - eval(rotate(bgLeft)); - - function setOffsetLeft(element) { - var propertyName = _isFixed(element) ? "backgroundPositionX" : "offsetLeft"; - element.runtimeStyle[propertyName] = - getOffsetLeft(element, element.style.backgroundPositionX) - - element.getBoundingClientRect().left - element.clientLeft + 2; - }; - eval(rotate(setOffsetLeft)); - - function getOffsetLeft(element, position) { - switch (position) { - case "left": - case "top": - return 0; - case "right": - case "bottom": - return viewport.clientWidth - _tmp.offsetWidth; - case "center": - return (viewport.clientWidth - _tmp.offsetWidth) / 2; - default: - if (PERCENT.test(position)) { - return parseInt((viewport.clientWidth - _tmp.offsetWidth) * parseFloat(position) / 100); - } - _tmp.style.left = position; - return _tmp.offsetLeft; - } - }; - eval(rotate(getOffsetLeft)); - - // ----------------------------------------------------------------------- - // position: fixed - // ----------------------------------------------------------------------- - - function _positionFixed(element) { - if (register(_positionFixed, element, isFixed(element))) { - setOverrideStyle(element, "position", "absolute"); - setOverrideStyle(element, "left", element.currentStyle.left); - setOverrideStyle(element, "top", element.currentStyle.top); - _fixBackground(); - IE7.Layout.fixRight(element); - _foregroundPosition(element); - } - }; - - function _foregroundPosition(element, recalc) { - positionTop(element, recalc); - positionLeft(element, recalc, true); - if (!element.runtimeStyle.autoLeft && element.currentStyle.marginLeft == "auto" && - element.currentStyle.right != "auto") { - var left = viewport.clientWidth - getPixelWidth(element, element.currentStyle.right) - - getPixelWidth(element, element.runtimeStyle._left) - element.clientWidth; - if (element.currentStyle.marginRight == "auto") left = parseInt(left / 2); - if (_isFixed(element.offsetParent)) element.runtimeStyle.pixelLeft += left; - else element.runtimeStyle.shiftLeft = left; - } - clipWidth(element); - clipHeight(element); - }; - - function clipWidth(element) { - var fixWidth = element.runtimeStyle.fixWidth; - element.runtimeStyle.borderRightWidth = ""; - element.runtimeStyle.width = fixWidth ? getPixelWidth(element, fixWidth) : ""; - if (element.currentStyle.width != "auto") { - var rect = element.getBoundingClientRect(); - var width = element.offsetWidth - viewport.clientWidth + rect.left - 2; - if (width >= 0) { - element.runtimeStyle.borderRightWidth = "0px"; - width = Math.max(getPixelValue(element, element.currentStyle.width) - width, 0); - setOverrideStyle(element, "width", width); - return width; - } - } - }; - eval(rotate(clipWidth)); - - function positionLeft(element, recalc) { - // if the element's width is in % units then it must be recalculated - // with respect to the viewport - if (!recalc && PERCENT.test(element.currentStyle.width)) { - element.runtimeStyle.fixWidth = element.currentStyle.width; - } - if (element.runtimeStyle.fixWidth) { - element.runtimeStyle.width = getPixelWidth(element, element.runtimeStyle.fixWidth); - } - //if (recalc) { - // // if the element is fixed on the right then no need to recalculate - // if (!element.runtimeStyle.autoLeft) return; - //} else { - element.runtimeStyle.shiftLeft = 0; - element.runtimeStyle._left = element.currentStyle.left; - // is the element fixed on the right? - element.runtimeStyle.autoLeft = element.currentStyle.right != "auto" && - element.currentStyle.left == "auto"; - //} - // reset the element's "left" value and get it's natural position - element.runtimeStyle.left = ""; - element.runtimeStyle.screenLeft = getScreenLeft(element); - element.runtimeStyle.pixelLeft = element.runtimeStyle.screenLeft; - // if the element is contained by another fixed element then there is no need to - // continually recalculate it's left position - if (!recalc && !_isFixed(element.offsetParent)) { - // onsrcoll produces jerky movement, so we use an expression - _setExpression(element, "pixelLeft", "runtimeStyle.screenLeft+runtimeStyle.shiftLeft+document." + $viewport + ".scrollLeft"); - } - }; - // clone this function so we can do "top" - eval(rotate(positionLeft)); - - // I've forgotten how this works... - function getScreenLeft(element) { // thanks to kevin newman (captainn) - var screenLeft = element.offsetLeft, nested = 1; - if (element.runtimeStyle.autoLeft) { - screenLeft = viewport.clientWidth - element.offsetWidth - getPixelWidth(element, element.currentStyle.right); - } - // accommodate margins - if (element.currentStyle.marginLeft != "auto") { - screenLeft -= getPixelWidth(element, element.currentStyle.marginLeft); - } - while (element = element.offsetParent) { - if (element.currentStyle.position != "static") nested = -1; - screenLeft += element.offsetLeft * nested; - } - return screenLeft; - }; - eval(rotate(getScreenLeft)); - - function getPixelWidth(element, value) { - return PERCENT.test(value) ? parseInt(parseFloat(value) / 100 * viewport.clientWidth) : getPixelValue(element, value); - }; - eval(rotate(getPixelWidth)); - - // ----------------------------------------------------------------------- - // capture window resize - // ----------------------------------------------------------------------- - - function _resize() { - // if the window has been resized then some positions need to be - // recalculated (especially those aligned to "right" or "top" - var elements = _backgroundFixed.elements; - for (var i in elements) _backgroundPosition(elements[i]); - elements = _positionFixed.elements; - for (i in elements) { - _foregroundPosition(elements[i], true); - // do this twice to be sure - hackish, I know :-) - _foregroundPosition(elements[i], true); - } - _timer = 0; - }; - - // use a timer for some reason. - // (sometimes this is a good way to prevent resize loops) - var _timer; - addResize(function() { - if (!_timer) _timer = setTimeout(_resize, 0); - }); -}; - -// ========================================================================= -// ie7-oveflow.js -// ========================================================================= - -/* --------------------------------------------------------------------- - - This module alters the structure of the document. - It may adversely affect other CSS rules. Be warned. - ---------------------------------------------------------------------- */ - -var WRAPPER_STYLE = { - backgroundColor: "transparent", - backgroundImage: "none", - backgroundPositionX: null, - backgroundPositionY: null, - backgroundRepeat: null, - borderTopWidth: 0, - borderRightWidth: 0, - borderBottomWidth: 0, - borderLeftStyle: "none", - borderTopStyle: "none", - borderRightStyle: "none", - borderBottomStyle: "none", - borderLeftWidth: 0, - height: null, - marginTop: 0, - marginBottom: 0, - marginRight: 0, - marginLeft: 0, - width: "100%" -}; - -IE7.CSS.addRecalc("overflow", "visible", function(element) { - // don't do this again - if (element.parentNode.ie7_wrapped) return; - - // if max-height is applied, makes sure it gets applied first - if (IE7.Layout && element.currentStyle["max-height"] != "auto") { - IE7.Layout.maxHeight(element); - } - - if (element.currentStyle.marginLeft == "auto") element.style.marginLeft = 0; - if (element.currentStyle.marginRight == "auto") element.style.marginRight = 0; - - var wrapper = document.createElement(ANON); - wrapper.ie7_wrapped = element; - for (var propertyName in WRAPPER_STYLE) { - wrapper.style[propertyName] = element.currentStyle[propertyName]; - if (WRAPPER_STYLE[propertyName] != null) { - element.runtimeStyle[propertyName] = WRAPPER_STYLE[propertyName]; - } - } - wrapper.style.display = "block"; - wrapper.style.position = "relative"; - element.runtimeStyle.position = "absolute"; - element.parentNode.insertBefore(wrapper, element); - wrapper.appendChild(element); -}); - -// ========================================================================= -// ie7-quirks.js -// ========================================================================= - -function ie7Quirks() { - var FONT_SIZES = "xx-small,x-small,small,medium,large,x-large,xx-large".split(","); - for (var i = 0; i < FONT_SIZES.length; i++) { - FONT_SIZES[FONT_SIZES[i]] = FONT_SIZES[i - 1] || "0.67em"; - } - - IE7.CSS.addFix(/(font(-size)?\s*:\s*)([\w.-]+)/, function(match, label, size, value) { - return label + (FONT_SIZES[value] || value); - }); - - if (appVersion < 6) { - var NEGATIVE = /^\-/, LENGTH = /(em|ex)$/i; - var EM = /em$/i, EX = /ex$/i; - - getPixelValue = function(element, value) { - if (PIXEL.test(value)) return parseInt(value)||0; - var scale = NEGATIVE.test(value)? -1 : 1; - if (LENGTH.test(value)) scale *= getFontScale(element); - temp.style.width = (scale < 0) ? value.slice(1) : value; - body.appendChild(temp); - // retrieve pixel width - value = scale * temp.offsetWidth; - // remove the temporary element - temp.removeNode(); - return parseInt(value); - }; - - var temp = createTempElement(); - function getFontScale(element) { - var scale = 1; - temp.style.fontFamily = element.currentStyle.fontFamily; - temp.style.lineHeight = element.currentStyle.lineHeight; - //temp.style.fontSize = ""; - while (element != body) { - var fontSize = element.currentStyle["ie7-font-size"]; - if (fontSize) { - if (EM.test(fontSize)) scale *= parseFloat(fontSize); - else if (PERCENT.test(fontSize)) scale *= (parseFloat(fontSize) / 100); - else if (EX.test(fontSize)) scale *= (parseFloat(fontSize) / 2); - else { - temp.style.fontSize = fontSize; - return 1; - } - } - element = element.parentElement; - } - return scale; - }; - - // cursor:pointer (IE5.x) - IE7.CSS.addFix(/cursor\s*:\s*pointer/, "cursor:hand"); - // display:list-item (IE5.x) - IE7.CSS.addFix(/display\s*:\s*list-item/, "display:block"); - } - - // ----------------------------------------------------------------------- - // margin:auto - // ----------------------------------------------------------------------- - - function fixMargin(element) { - if (appVersion < 5.5) IE7.Layout.boxSizing(element.parentElement); - var parent = element.parentElement; - var margin = parent.offsetWidth - element.offsetWidth - getPaddingWidth(parent); - var autoRight = (element.currentStyle["ie7-margin"] && element.currentStyle.marginRight == "auto") || - element.currentStyle["ie7-margin-right"] == "auto"; - switch (parent.currentStyle.textAlign) { - case "right": - margin = autoRight ? parseInt(margin / 2) : 0; - element.runtimeStyle.marginRight = margin + "px"; - break; - case "center": - if (autoRight) margin = 0; - default: - if (autoRight) margin /= 2; - element.runtimeStyle.marginLeft = parseInt(margin) + "px"; - } - }; - - function getPaddingWidth(element) { - return getPixelValue(element, element.currentStyle.paddingLeft) + - getPixelValue(element, element.currentStyle.paddingRight); - }; - - IE7.CSS.addRecalc("margin(-left|-right)?", "[^};]*auto", function(element) { - if (register(fixMargin, element, - element.parentElement && - element.currentStyle.display == "block" && - element.currentStyle.marginLeft == "auto" && - element.currentStyle.position != "absolute")) { - fixMargin(element); - } - }); - - addResize(function() { - for (var i in fixMargin.elements) { - var element = fixMargin.elements[i]; - element.runtimeStyle.marginLeft = - element.runtimeStyle.marginRight = ""; - fixMargin(element); - } - }); -}; - - -// ----------------------------------------------------------------------- -// initialisation -// ----------------------------------------------------------------------- - -IE7.loaded = true; - -(function() { - try { - // http://javascript.nwbox.com/IEContentLoaded/ - documentElement.doScroll("left"); - } catch (e) { - setTimeout(arguments.callee, 1); - return; - } - // execute the inner text of the IE7 script - try { - eval(script.innerHTML); - } catch (e) { - // ignore errors - } - PNG = new RegExp(rescape(typeof IE7_PNG_SUFFIX == "string" ? IE7_PNG_SUFFIX : "-trans.png") + "$", "i"); - - // frequently used references - body = document.body; - viewport = quirksMode ? body : documentElement; - - // classes - body.className += " ie7_body"; - documentElement.className += " ie7_html"; - - if (quirksMode) ie7Quirks(); - - IE7.CSS.init(); - IE7.HTML.init(); - - IE7.HTML.apply(); - IE7.CSS.apply(); - - IE7.recalc(); -})(); - - -})(); diff --git a/lib/galaxy/webapps/reports/static/scripts/IE8.js b/lib/galaxy/webapps/reports/static/scripts/IE8.js deleted file mode 100644 index cadc72345b5..00000000000 --- a/lib/galaxy/webapps/reports/static/scripts/IE8.js +++ /dev/null @@ -1,2601 +0,0 @@ -// timestamp: Sun, 03 Feb 2008 19:26:22 -/* - IE7/IE8.js - copyright 2004-2008, Dean Edwards - http://dean.edwards.name/IE7/ - http://www.opensource.org/licenses/mit-license.php -*/ - -/* W3C compliance for Microsoft Internet Explorer */ - -/* credits/thanks: - Shaggy, Martijn Wargers, Jimmy Cerra, Mark D Anderson, - Lars Dieckow, Erik Arvidsson, Gellért Gyuris, James Denny, - Unknown W Brackets, Benjamin Westfarer, Rob Eberhardt, - Bill Edney, Kevin Newman, James Crompton, Matthew Mastracci, - Doug Wright, Richard York, Kenneth Kolano, MegaZone, - Thomas Verelst, Mark 'Tarquin' Wilton-Jones, Rainer Åhlfors, - David Zulaica, Ken Kolano, Kevin Newman -*/ - -// ======================================================================= -// TO DO -// ======================================================================= - -// PNG - unclickable content - -// ======================================================================= -// TEST/BUGGY -// ======================================================================= - -// hr{margin:1em auto} (doesn't look right in IE5) - -(function() { - -IE7 = { - toString: function(){return "IE7 version 2.0 (beta3)"} -}; -var appVersion = IE7.appVersion = navigator.appVersion.match(/MSIE (\d\.\d)/)[1]; - -if (/ie7_off/.test(top.location.search) || appVersion < 5) return; - -var Undefined = K(); -var quirksMode = document.compatMode != "CSS1Compat"; -var documentElement = document.documentElement, body, viewport; -var ANON = "!"; -var HEADER = ":link{ie7-link:link}:visited{ie7-link:visited}"; - -// ----------------------------------------------------------------------- -// external -// ----------------------------------------------------------------------- - -var RELATIVE = /^[\w\.]+[^:]*$/; -function makePath(href, path) { - if (RELATIVE.test(href)) href = (path || "") + href; - return href; -}; - -function getPath(href, path) { - href = makePath(href, path); - return href.slice(0, href.lastIndexOf("/") + 1); -}; - -// get the path to this script -var script = document.scripts[document.scripts.length - 1]; -var path = getPath(script.src); - -// we'll use microsoft's http request object to load external files -try { - var httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); -} catch (e) { - // ActiveX disabled -} - -var fileCache = {}; -function loadFile(href, path) { -try { - href = makePath(href, path); - if (!fileCache[href]) { - // easy to load a file huh? - httpRequest.open("GET", href, false); - httpRequest.send(); - if (httpRequest.status == 0 || httpRequest.status == 200) { - fileCache[href] = httpRequest.responseText; - } - } -} catch (e) { - // ignore errors -} finally { - return fileCache[href] || ""; -}}; - -// ----------------------------------------------------------------------- -// IE5.0 compatibility -// ----------------------------------------------------------------------- - - -if (appVersion < 5.5) { - undefined = Undefined(); - - ANON = "HTML:!"; // for anonymous content - - // Fix String.replace (Safari1.x/IE5.0). - var GLOBAL = /(g|gi)$/; - var _String_replace = String.prototype.replace; - String.prototype.replace = function(expression, replacement) { - if (typeof replacement == "function") { // Safari doesn't like functions - if (expression && expression.constructor == RegExp) { - var regexp = expression; - var global = regexp.global; - if (global == null) global = GLOBAL.test(regexp); - // we have to convert global RexpExps for exec() to work consistently - if (global) regexp = new RegExp(regexp.source); // non-global - } else { - regexp = new RegExp(rescape(expression)); - } - var match, string = this, result = ""; - while (string && (match = regexp.exec(string))) { - result += string.slice(0, match.index) + replacement.apply(this, match); - string = string.slice(match.index + match[0].length); - if (!global) break; - } - return result + string; - } - return _String_replace.apply(this, arguments); - }; - - Array.prototype.pop = function() { - if (this.length) { - var i = this[this.length - 1]; - this.length--; - return i; - } - return undefined; - }; - - Array.prototype.push = function() { - for (var i = 0; i < arguments.length; i++) { - this[this.length] = arguments[i]; - } - return this.length; - }; - - var ns = this; - Function.prototype.apply = function(o, a) { - if (o === undefined) o = ns; - else if (o == null) o = window; - else if (typeof o == "string") o = new String(o); - else if (typeof o == "number") o = new Number(o); - else if (typeof o == "boolean") o = new Boolean(o); - if (arguments.length == 1) a = []; - else if (a[0] && a[0].writeln) a[0] = a[0].documentElement.document || a[0]; - var $ = "#ie7_apply", r; - o[$] = this; - switch (a.length) { // unroll for speed - case 0: r = o[$](); break; - case 1: r = o[$](a[0]); break; - case 2: r = o[$](a[0],a[1]); break; - case 3: r = o[$](a[0],a[1],a[2]); break; - case 4: r = o[$](a[0],a[1],a[2],a[3]); break; - case 5: r = o[$](a[0],a[1],a[2],a[3],a[4]); break; - default: - var b = [], i = a.length - 1; - do b[i] = "a[" + i + "]"; while (i--); - eval("r=o[$](" + b + ")"); - } - if (typeof o.valueOf == "function") { // not a COM object - delete o[$]; - } else { - o[$] = undefined; - if (r && r.writeln) r = r.documentElement.document || r; - } - return r; - }; - - Function.prototype.call = function(o) { - return this.apply(o, _slice.apply(arguments, [1])); - }; - - // block elements are "inline" according to IE5.0 so we'll fix it - HEADER += "address,blockquote,body,dd,div,dt,fieldset,form,"+ - "frame,frameset,h1,h2,h3,h4,h5,h6,iframe,noframes,object,p,"+ - "hr,applet,center,dir,menu,pre,dl,li,ol,ul{display:block}"; -} - -// ----------------------------------------------------------------------- -// OO support -// ----------------------------------------------------------------------- - - -// This is a cut-down version of base2 (http://code.google.com/p/base2/) - -var _slice = Array.prototype.slice; - -// private -var _FORMAT = /%([1-9])/g; -var _LTRIM = /^\s\s*/; -var _RTRIM = /\s\s*$/; -var _RESCAPE = /([\/()[\]{}|*+-.,^$?\\])/g; // safe regular expressions -var _BASE = /\bbase\b/; -var _HIDDEN = ["constructor", "toString"]; // only override these when prototyping - -var prototyping; - -function Base(){}; -Base.extend = function(_instance, _static) { - // Build the prototype. - prototyping = true; - var _prototype = new this; - extend(_prototype, _instance); - prototyping = false; - - // Create the wrapper for the constructor function. - var _constructor = _prototype.constructor; - function klass() { - // Don't call the constructor function when prototyping. - if (!prototyping) _constructor.apply(this, arguments); - }; - _prototype.constructor = klass; - - // Build the static interface. - klass.extend = arguments.callee; - extend(klass, _static); - klass.prototype = _prototype; - return klass; -}; -Base.prototype.extend = function(source) { - return extend(this, source); -}; - -// A collection of regular expressions and their associated replacement values. -// A Base class for creating parsers. - -var _HASH = "#"; -var _KEYS = "~"; - -var _RG_ESCAPE_CHARS = /\\./g; -var _RG_ESCAPE_BRACKETS = /\(\?[:=!]|\[[^\]]+\]/g; -var _RG_BRACKETS = /\(/g; - -var RegGrp = Base.extend({ - constructor: function(values) { - this[_KEYS] = []; - this.merge(values); - }, - - exec: function(string) { - var items = this, keys = this[_KEYS]; - return String(string).replace(new RegExp(this, this.ignoreCase ? "gi" : "g"), function() { - var item, offset = 1, i = 0; - // Loop through the RegGrp items. - while ((item = items[_HASH + keys[i++]])) { - var next = offset + item.length + 1; - if (arguments[offset]) { // do we have a result? - var replacement = item.replacement; - switch (typeof replacement) { - case "function": - return replacement.apply(items, _slice.call(arguments, offset, next)); - case "number": - return arguments[offset + replacement]; - default: - return replacement; - } - } - offset = next; - } - }); - }, - - add: function(expression, replacement) { - if (expression instanceof RegExp) { - expression = expression.source; - } - if (!this[_HASH + expression]) this[_KEYS].push(String(expression)); - this[_HASH + expression] = new RegGrp.Item(expression, replacement); - }, - - merge: function(values) { - for (var i in values) this.add(i, values[i]); - }, - - toString: function() { - // back references not supported in simple RegGrp - return "(" + this[_KEYS].join(")|(") + ")"; - } -}, { - IGNORE: "$0", - - Item: Base.extend({ - constructor: function(expression, replacement) { - expression = expression instanceof RegExp ? expression.source : String(expression); - - if (typeof replacement == "number") replacement = String(replacement); - else if (replacement == null) replacement = ""; - - // does the pattern use sub-expressions? - if (typeof replacement == "string" && /\$(\d+)/.test(replacement)) { - // a simple lookup? (e.g. "$2") - if (/^\$\d+$/.test(replacement)) { - // store the index (used for fast retrieval of matched strings) - replacement = parseInt(replacement.slice(1)); - } else { // a complicated lookup (e.g. "Hello $2 $1") - // build a function to do the lookup - var Q = /'/.test(replacement.replace(/\\./g, "")) ? '"' : "'"; - replacement = replacement.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\$(\d+)/g, Q + - "+(arguments[$1]||" + Q+Q + ")+" + Q); - replacement = new Function("return " + Q + replacement.replace(/(['"])\1\+(.*)\+\1\1$/, "$1") + Q); - } - } - - this.length = RegGrp.count(expression); - this.replacement = replacement; - this.toString = K(expression); - } - }), - - count: function(expression) { - // Count the number of sub-expressions in a RegExp/RegGrp.Item. - expression = String(expression).replace(_RG_ESCAPE_CHARS, "").replace(_RG_ESCAPE_BRACKETS, ""); - return match(expression, _RG_BRACKETS).length; - } -}); - -// ========================================================================= -// lang/extend.js -// ========================================================================= - -function extend(object, source) { // or extend(object, key, value) - if (object && source) { - var proto = (typeof source == "function" ? Function : Object).prototype; - // Add constructor, toString etc - var i = _HIDDEN.length, key; - if (prototyping) while (key = _HIDDEN[--i]) { - var value = source[key]; - if (value != proto[key]) { - if (_BASE.test(value)) { - _override(object, key, value) - } else { - object[key] = value; - } - } - } - // Copy each of the source object's properties to the target object. - for (key in source) if (proto[key] === undefined) { - var value = source[key]; - // Check for method overriding. - if (object[key] && typeof value == "function" && _BASE.test(value)) { - _override(object, key, value); - } else { - object[key] = value; - } - } - } - return object; -}; - -function _override(object, name, method) { - // Override an existing method. - var ancestor = object[name]; - object[name] = function() { - var previous = this.base; - this.base = ancestor; - var returnValue = method.apply(this, arguments); - this.base = previous; - return returnValue; - }; -}; - -function combine(keys, values) { - // Combine two arrays to make a hash. - if (!values) values = keys; - var hash = {}; - for (var i in keys) hash[i] = values[i]; - return hash; -}; - -function format(string) { - // Replace %n with arguments[n]. - // e.g. format("%1 %2%3 %2a %1%3", "she", "se", "lls"); - // ==> "she sells sea shells" - // Only %1 - %9 supported. - var args = arguments; - var _FORMAT = new RegExp("%([1-" + arguments.length + "])", "g"); - return String(string).replace(_FORMAT, function(match, index) { - return index < args.length ? args[index] : match; - }); -}; - -function match(string, expression) { - // Same as String.match() except that this function will return an empty - // array if there is no match. - return String(string).match(expression) || []; -}; - -function rescape(string) { - // Make a string safe for creating a RegExp. - return String(string).replace(_RESCAPE, "\\$1"); -}; - -// http://blog.stevenlevithan.com/archives/faster-trim-javascript -function trim(string) { - return String(string).replace(_LTRIM, "").replace(_RTRIM, ""); -}; - -function K(k) { - return function() { - return k; - }; -}; - -// ----------------------------------------------------------------------- -// parsing -// ----------------------------------------------------------------------- - -var Parser = RegGrp.extend({ignoreCase: true}); - -var ENCODED = /\x01(\d+)/g, - QUOTES = /'/g, - STRING = /^\x01/, - UNICODE = /\\([\da-fA-F]{1,4})/g; - -var _strings = []; - -var encoder = new Parser({ - // comments - "": "", - "\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\/": "", - // get rid - "@(namespace|import)[^;\\n]+[;\\n]": "", - // strings - "'(\\\\.|[^'\\\\])*'": encodeString, - '"(\\\\.|[^"\\\\])*"': encodeString, - // white space - "\\s+": " " -}); - -function encode(cssText) { - return encoder.exec(cssText); -}; - -function decode(cssText) { - return cssText.replace(ENCODED, function(match, index) { - return _strings[index - 1]; - }); -}; - -function encodeString(string) { - return "\x01" + _strings.push(string.replace(UNICODE, function(match, chr) { - return eval("'\\u" + "0000".slice(chr.length) + chr + "'"); - }).slice(1, -1).replace(QUOTES, "\\'")); -}; - -function getString(value) { - return STRING.test(value) ? _strings[value.slice(1) - 1] : value; -}; - -// clone a "width" function to create a "height" function -var rotater = new RegGrp({ - Width: "Height", - width: "height", - Left: "Top", - left: "top", - Right: "Bottom", - right: "bottom", - onX: "onY" -}); - -function rotate(fn) { - return rotater.exec(fn); -}; - -// ----------------------------------------------------------------------- -// event handling -// ----------------------------------------------------------------------- - -var eventHandlers = []; - -function addResize(handler) { - addRecalc(handler); - addEventHandler(window, "onresize", handler); -}; - -// add an event handler (function) to an element -function addEventHandler(element, type, handler) { - element.attachEvent(type, handler); - // store the handler so it can be detached later - eventHandlers.push(arguments); -}; - -// remove an event handler assigned to an element by IE7 -function removeEventHandler(element, type, handler) { -try { - element.detachEvent(type, handler); -} catch (ignore) { - // write a letter of complaint to microsoft.. -}}; - -// remove event handlers (they eat memory) -addEventHandler(window, "onunload", function() { - var handler; - while (handler = eventHandlers.pop()) { - removeEventHandler(handler[0], handler[1], handler[2]); - } -}); - -function register(handler, element, condition) { // -@DRE - //var set = handler[element.uniqueID]; - if (!handler.elements) handler.elements = {}; - if (condition) handler.elements[element.uniqueID] = element; - else delete handler.elements[element.uniqueID]; - //return !set && condition; - return condition; -}; - -addEventHandler(window, "onbeforeprint", function() { - if (!IE7.CSS.print) new StyleSheet("print"); - IE7.CSS.print.recalc(); -}); - -// ----------------------------------------------------------------------- -// pixel conversion -// ----------------------------------------------------------------------- - -// this is handy because it means that web developers can mix and match -// measurement units in their style sheets. it is not uncommon to -// express something like padding in "em" units whilst border thickness -// is most often expressed in pixels. - -var PIXEL = /^\d+(px)?$/i; -var PERCENT = /^\d+%$/; -var getPixelValue = function(element, value) { - if (PIXEL.test(value)) return parseInt(value); - var style = element.style.left; - var runtimeStyle = element.runtimeStyle.left; - element.runtimeStyle.left = element.currentStyle.left; - element.style.left = value || 0; - value = element.style.pixelLeft; - element.style.left = style; - element.runtimeStyle.left = runtimeStyle; - return value; -}; - -// ----------------------------------------------------------------------- -// generic -// ----------------------------------------------------------------------- - -var $IE7 = "ie7-"; - -var Fix = Base.extend({ - constructor: function() { - this.fixes = []; - this.recalcs = []; - }, - init: Undefined -}); - -// a store for functions that will be called when refreshing IE7 -var recalcs = []; -function addRecalc(recalc) { - recalcs.push(recalc); -}; - -IE7.recalc = function() { - IE7.HTML.recalc(); - // re-apply style sheet rules (re-calculate ie7 classes) - IE7.CSS.recalc(); - // apply global fixes to the document - for (var i = 0; i < recalcs.length; i++) recalcs[i](); -}; - -function isFixed(element) { - return element.currentStyle["ie7-position"] == "fixed"; -}; - -// original style -function getDefinedStyle(element, propertyName) { - return element.currentStyle[$IE7 + propertyName] || element.currentStyle[propertyName]; -}; - -function setOverrideStyle(element, propertyName, value) { - if (element.currentStyle[$IE7 + propertyName] == null) { - element.runtimeStyle[$IE7 + propertyName] = element.currentStyle[propertyName]; - } - element.runtimeStyle[propertyName] = value; -}; - -// create a temporary element which is used to inherit styles -// from the target element. the temporary element can be resized -// to determine pixel widths/heights -function createTempElement(tagName) { - var element = document.createElement(tagName || "object"); - element.style.cssText = "position:absolute;padding:0;display:block;border:none;clip:rect(0 0 0 0);left:-9999"; - element.ie7_anon = true; - return element; -}; - - -// ========================================================================= -// ie7-cssQuery.js -// ========================================================================= - -function cssQuery(selector, context, single) { - if (!_cache[selector]) { - reg = []; // store for RegExp objects - var fn = ""; - var selectors = cssParser.escape(selector).split(","); - for (var i = 0; i < selectors.length; i++) { - _wild = _index = _list = 0; // reset - _duplicate = selectors.length > 1 ? 2 : 0; // reset - var block = cssParser.exec(selectors[i]) || "if(0){"; - if (_wild) { // IE's pesky comment nodes - block += format("if(e%1.nodeName!='!'){", _index); - } - // check for duplicates before storing results - var store = _duplicate > 1 ? _TEST : ""; - block += format(store + _STORE, _index); - // add closing braces - block += Array(match(block, /\{/g).length + 1).join("}"); - fn += block; - } - eval(format(_FN, reg) + cssParser.unescape(fn) + "return s?null:r}"); - _cache[selector] = _selectorFunction; - } - return _cache[selector](context || document, single); -}; - -var _MSIE5 = appVersion < 6; - -var _EVALUATED = /^(href|src)$/; -var _ATTRIBUTES = { - "class": "className", - "for": "htmlFor" -}; - -IE7._indexed = 1; - -IE7._byId = function(document, id) { - var result = document.all[id] || null; - // returns a single element or a collection - if (!result || result.id == id) return result; - // document.all has returned a collection of elements with name/id - for (var i = 0; i < result.length; i++) { - if (result[i].id == id) return result[i]; - } - return null; -}; - -IE7._getAttribute = function(element, name) { - if (name == "src" && element.pngSrc) return element.pngSrc; - - var attribute = _MSIE5 ? (element.attributes[name] || element.attributes[_ATTRIBUTES[name.toLowerCase()]]) : element.getAttributeNode(name); - if (attribute && (attribute.specified || name == "value")) { - if (_EVALUATED.test(name)) { - return element.getAttribute(name, 2); - } else if (name == "class") { - return element.className.replace(/\sie7_\w+/g, ""); - } else if (name == "style") { - return element.style.cssText; - } else { - return attribute.nodeValue; - } - } - return null; -}; - -var names = "colSpan,rowSpan,vAlign,dateTime,accessKey,tabIndex,encType,maxLength,readOnly,longDesc"; -// Convert the list of strings to a hash, mapping the lowercase name to the camelCase name. -extend(_ATTRIBUTES, combine(names.toLowerCase().split(","), names.split(","))); - -IE7._getNextElementSibling = function(node) { - // return the next element to the supplied element - // nextSibling is not good enough as it might return a text or comment node - while (node && (node = node.nextSibling) && (node.nodeType != 1 || node.nodeName == "!")) continue; - return node; -}; - -IE7._getPreviousElementSibling = function(node) { - // return the previous element to the supplied element - while (node && (node = node.previousSibling) && (node.nodeType != 1 || node.nodeName == "!")) continue; - return node; -}; - -// ========================================================================= -// CSSParser -// ========================================================================= - -var IMPLIED_ASTERISK = /([\s>+~,]|[^(]\+|^)([#.:\[])/g, - IMPLIED_SPACE = /(^|,)([^\s>+~])/g, - WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g, - WILD_CARD = /\s\*\s/g;; - -var CSSParser = RegGrp.extend({ - constructor: function(items) { - this.base(items); - this.sorter = new RegGrp; - this.sorter.add(/:not\([^)]*\)/, RegGrp.IGNORE); - this.sorter.add(/([ >](\*|[\w-]+))([^: >+~]*)(:\w+-child(\([^)]+\))?)([^: >+~]*)/, "$1$3$6$4"); - }, - - ignoreCase: true, - - escape: function(selector) { - return this.optimise(this.format(selector)); - }, - - format: function(selector) { - return selector - .replace(WHITESPACE, "$1") - .replace(IMPLIED_SPACE, "$1 $2") - .replace(IMPLIED_ASTERISK, "$1*$2"); - }, - - optimise: function(selector) { - // optimise wild card descendant selectors - return this.sorter.exec(selector.replace(WILD_CARD, ">* ")); - }, - - unescape: function(selector) { - return decode(selector); - } -}); - -// some constants -var _OPERATORS = { - "": "%1!=null", - "=": "%1=='%2'", - "~=": /(^| )%1( |$)/, - "|=": /^%1(-|$)/, - "^=": /^%1/, - "$=": /%1$/, - "*=": /%1/ -}; - -var _PSEUDO_CLASSES = { - "first-child": "!IE7._getPreviousElementSibling(e%1)", - "link": "e%1.currentStyle['ie7-link']=='link'", - "visited": "e%1.currentStyle['ie7-link']=='visited'" -}; - -var _VAR = "var p%2=0,i%2,e%2,n%2=e%1."; -var _ID = "e%1.sourceIndex"; -var _TEST = "var g=" + _ID + ";if(!p[g]){p[g]=1;"; -var _STORE = "r[r.length]=e%1;if(s)return e%1;"; -var _FN = "var _selectorFunction=function(e0,s){IE7._indexed++;var r=[],p={},reg=[%1],d=document;"; -var reg; // a store for RexExp objects -var _index; -var _wild; // need to flag certain _wild card selectors as MSIE includes comment nodes -var _list; // are we processing a node _list? -var _duplicate; // possible duplicates? -var _cache = {}; // store parsed selectors - -// a hideous parser -var cssParser = new CSSParser({ - " (\\*|[\\w-]+)#([\\w-]+)": function(match, tagName, id) { // descendant selector followed by ID - _wild = false; - var replacement = "var e%2=IE7._byId(d,'%4');if(e%2&&"; - if (tagName != "*") replacement += "e%2.nodeName=='%3'&&"; - replacement += "(e%1==d||e%1.contains(e%2))){"; - if (_list) replacement += format("i%1=n%1.length;", _list); - return format(replacement, _index++, _index, tagName.toUpperCase(), id); - }, - - " (\\*|[\\w-]+)": function(match, tagName) { // descendant selector - _duplicate++; // this selector may produce duplicates - _wild = tagName == "*"; - var replacement = _VAR; - // IE5.x does not support getElementsByTagName("*"); - replacement += (_wild && _MSIE5) ? "all" : "getElementsByTagName('%3')"; - replacement += ";for(i%2=0;(e%2=n%2[i%2]);i%2++){"; - return format(replacement, _index++, _list = _index, tagName.toUpperCase()); - }, - - ">(\\*|[\\w-]+)": function(match, tagName) { // child selector - var children = _list; - _wild = tagName == "*"; - var replacement = _VAR; - // use the children property for MSIE as it does not contain text nodes - // (but the children collection still includes comments). - // the document object does not have a children collection - replacement += children ? "children": "childNodes"; - if (!_wild && children) replacement += ".tags('%3')"; - replacement += ";for(i%2=0;(e%2=n%2[i%2]);i%2++){"; - if (_wild) { - replacement += "if(e%2.nodeType==1){"; - _wild = _MSIE5; - } else { - if (!children) replacement += "if(e%2.nodeName=='%3'){"; - } - return format(replacement, _index++, _list = _index, tagName.toUpperCase()); - }, - - "\\+(\\*|[\\w-]+)": function(match, tagName) { // direct adjacent selector - var replacement = ""; - if (_wild) replacement += "if(e%1.nodeName!='!'){"; - _wild = false; - replacement += "e%1=IE7._getNextElementSibling(e%1);if(e%1"; - if (tagName != "*") replacement += "&&e%1.nodeName=='%2'"; - replacement += "){"; - return format(replacement, _index, tagName.toUpperCase()); - }, - - "~(\\*|[\\w-]+)": function(match, tagName) { // indirect adjacent selector - var replacement = ""; - if (_wild) replacement += "if(e%1.nodeName!='!'){"; - _wild = false; - _duplicate = 2; // this selector may produce duplicates - replacement += "while(e%1=e%1.nextSibling){if(e%1.ie7_adjacent==IE7._indexed)break;if("; - if (tagName == "*") { - replacement += "e%1.nodeType==1"; - if (_MSIE5) replacement += "&&e%1.nodeName!='!'"; - } else replacement += "e%1.nodeName=='%2'"; - replacement += "){e%1.ie7_adjacent=IE7._indexed;"; - return format(replacement, _index, tagName.toUpperCase()); - }, - - "#([\\w-]+)": function(match, id) { // ID selector - _wild = false; - var replacement = "if(e%1.id=='%2'){"; - if (_list) replacement += format("i%1=n%1.length;", _list); - return format(replacement, _index, id); - }, - - "\\.([\\w-]+)": function(match, className) { // class selector - _wild = false; - // store RegExp objects - slightly faster on IE - reg.push(new RegExp("(^|\\s)" + rescape(className) + "(\\s|$)")); - return format("if(e%1.className&®[%2].test(e%1.className)){", _index, reg.length - 1); - }, - - "\\[([\\w-]+)\\s*([^=]?=)?\\s*([^\\]]*)\\]": function(match, attr, operator, value) { // attribute selectors - var alias = _ATTRIBUTES[attr] || attr; - if (operator) { - var getAttribute = "e%1.getAttribute('%2',2)"; - if (!_EVALUATED.test(attr)) { - getAttribute = "e%1.%3||" + getAttribute; - } - attr = format("(" + getAttribute + ")", _index, attr, alias); - } else { - attr = format("IE7._getAttribute(e%1,'%2')", _index, attr); - } - var replacement = _OPERATORS[operator || ""] || "0"; - if (replacement && replacement.source) { - reg.push(new RegExp(format(replacement.source, rescape(cssParser.unescape(value))))); - replacement = "reg[%2].test(%1)"; - value = reg.length - 1; - } - return "if(" + format(replacement, attr, value) + "){"; - }, - - ":+([\\w-]+)(\\(([^)]+)\\))?": function(match, pseudoClass, $2, args) { // pseudo class selectors - pseudoClass = _PSEUDO_CLASSES[pseudoClass]; - return "if(" + (pseudoClass ? format(pseudoClass, _index, args || "") : "0") + "){"; - } -}); - -// ========================================================================= -// ie7-css.js -// ========================================================================= - -var HYPERLINK = /a(#[\w-]+)?(\.[\w-]+)?:(hover|active)/i; -var BRACE1 = /\s*\{\s*/, BRACE2 = /\s*\}\s*/, COMMA = /\s*\,\s*/; -var FIRST_LINE_LETTER = /(.*)(:first-(line|letter))/; - -//var UNKNOWN = /UNKNOWN|([:.])\w+\1/i; - -var styleSheets = document.styleSheets; - -IE7.CSS = new (Fix.extend({ // single instance - parser: new Parser, - screen: "", - print: "", - styles: [], - rules: [], - pseudoClasses: appVersion < 7 ? "first\\-child" : "", - dynamicPseudoClasses: { - toString: function() { - var strings = []; - for (var pseudoClass in this) strings.push(pseudoClass); - return strings.join("|"); - } - }, - - init: function() { - var NONE = "^\x01$"; - var CLASS = "\\[class=?[^\\]]*\\]"; - var pseudoClasses = []; - if (this.pseudoClasses) pseudoClasses.push(this.pseudoClasses); - var dynamicPseudoClasses = this.dynamicPseudoClasses.toString(); - if (dynamicPseudoClasses) pseudoClasses.push(dynamicPseudoClasses); - pseudoClasses = pseudoClasses.join("|"); - var unknown = appVersion < 7 ? ["[>+~[(]|([:.])\\w+\\1"] : [CLASS]; - if (pseudoClasses) unknown.push(":(" + pseudoClasses + ")"); - this.UNKNOWN = new RegExp(unknown.join("|") || NONE, "i"); - var complex = appVersion < 7 ? ["\\[[^\\]]+\\]|[^\\s(\\[]+\\s*[+~]"] : [CLASS]; - var complexRule = complex.concat(); - if (pseudoClasses) complexRule.push(":(" + pseudoClasses + ")"); - Rule.COMPLEX = new RegExp(complexRule.join("|") || NONE, "ig"); - if (this.pseudoClasses) complex.push(":(" + this.pseudoClasses + ")"); - DynamicRule.COMPLEX = new RegExp(complex.join("|") || NONE, "i"); - DynamicRule.MATCH = new RegExp(dynamicPseudoClasses ? "(.*):(" + dynamicPseudoClasses + ")(.*)" : NONE, "i"); - - this.createStyleSheet(); - this.refresh(); - }, - - addEventHandler: function() { - addEventHandler.apply(null, arguments); - }, - - addFix: function(expression, replacement) { - this.parser.add(expression, replacement); - }, - - addRecalc: function(propertyName, test, handler, replacement) { - // recalcs occur whenever the document is refreshed using document.recalc() - test = new RegExp("([{;\\s])" + propertyName + "\\s*:\\s*" + test + "[^;}]*"); - var id = this.recalcs.length; - if (replacement) replacement = propertyName + ":" + replacement; - this.addFix(test, function(match, $1) { - return (replacement ? $1 + replacement : match) + ";ie7-" + match.slice(1) + ";ie7_recalc" + id + ":1"; - }); - this.recalcs.push(arguments); - return id; - }, - - apply: function() { - this.getInlineStyles(); - new StyleSheet("screen"); - this.trash(); - }, - - createStyleSheet: function() { - // create the IE7 style sheet - this.styleSheet = document.createStyleSheet(); - // flag it so we can ignore it during parsing - this.styleSheet.ie7 = true; - this.styleSheet.owningElement.ie7 = true; - this.styleSheet.cssText = HEADER; - }, - - getInlineStyles: function() { - // load inline styles - var styleSheets = document.getElementsByTagName("style"), styleSheet; - for (var i = styleSheets.length - 1; (styleSheet = styleSheets[i]); i--) { - if (!styleSheet.disabled && !styleSheet.ie7) { - this.styles.push(styleSheet.innerHTML); - } - } - }, - - getText: function(styleSheet, path) { - // explorer will trash unknown selectors (it converts them to "UNKNOWN"). - // so we must reload external style sheets (internal style sheets can have their text - // extracted through the innerHTML property). - // load the style sheet text from an external file - try { - var cssText = styleSheet.cssText; - } catch (e) { - cssText = ""; - } - if (httpRequest) cssText = loadFile(styleSheet.href, path) || cssText; - return cssText; - }, - - recalc: function() { - this.screen.recalc(); - // we're going to read through all style rules. - // certain rules have had ie7 properties added to them. - // e.g. p{top:0; ie7_recalc2:1; left:0} - // this flags a property in the rule as needing a fix. - // the selector text is then used to query the document. - // we can then loop through the results of the query - // and fix the elements. - // we ignore the IE7 rules - so count them in the header - var RECALCS = /ie7_recalc\d+/g; - var start = HEADER.match(/[{,]/g).length; - // only calculate screen fixes. print fixes don't show up anyway - var stop = start + (this.screen.cssText.match(/\{/g)||"").length; - var rules = this.styleSheet.rules, rule; - var calcs, calc, elements, element, i, j, k, id; - // loop through all rules - for (i = start; i < stop; i++) { - rule = rules[i]; - var cssText = rule.style.cssText; - // search for the "ie7_recalc" flag (there may be more than one) - if (rule && (calcs = cssText.match(RECALCS))) { - // use the selector text to query the document - elements = cssQuery(rule.selectorText); - // if there are matching elements then loop - // through the recalc functions and apply them - // to each element - if (elements.length) for (j = 0; j < calcs.length; j++) { - // get the matching flag (e.g. ie7_recalc3) - id = calcs[j]; - // extract the numeric id from the end of the flag - // and use it to index the collection of recalc - // functions - calc = IE7.CSS.recalcs[id.slice(10)][2]; - for (k = 0; (element = elements[k]); k++) { - // apply the fix - if (element.currentStyle[id]) calc(element, cssText); - } - } - } - } - }, - - refresh: function() { - this.styleSheet.cssText = HEADER + this.screen + this.print; - }, - - trash: function() { - // trash the old style sheets - for (var i = 0; i < styleSheets.length; i++) { - if (!styleSheets[i].ie7) { - try { - var cssText = styleSheets[i].cssText; - } catch (e) { - cssText = ""; - } - if (cssText) styleSheets[i].cssText = ""; - } - } - } -})); - -// ----------------------------------------------------------------------- -// IE7 StyleSheet class -// ----------------------------------------------------------------------- - -var StyleSheet = Base.extend({ - constructor: function(media) { - this.media = media; - this.load(); - IE7.CSS[media] = this; - IE7.CSS.refresh(); - }, - - createRule: function(selector, cssText) { - if (IE7.CSS.UNKNOWN.test(selector)) { - var match; - if (PseudoElement && (match = selector.match(PseudoElement.MATCH))) { - return new PseudoElement(match[1], match[2], cssText); - } else if (match = selector.match(DynamicRule.MATCH)) { - if (!HYPERLINK.test(match[0]) || DynamicRule.COMPLEX.test(match[0])) { - return new DynamicRule(selector, match[1], match[2], match[3], cssText); - } - } else return new Rule(selector, cssText); - } - return selector + " {" + cssText + "}"; - }, - - getText: function() { - // store for style sheet text - var _inlineStyles = [].concat(IE7.CSS.styles); - // parse media decalarations - var MEDIA = /@media\s+([^{]*)\{([^@]+\})\s*\}/gi; - var ALL = /\ball\b|^$/i, SCREEN = /\bscreen\b/i, PRINT = /\bprint\b/i; - function _parseMedia(cssText, media) { - _filterMedia.value = media; - return cssText.replace(MEDIA, _filterMedia); - }; - function _filterMedia(match, media, cssText) { - media = _simpleMedia(media); - switch (media) { - case "screen": - case "print": - if (media != _filterMedia.value) return ""; - case "all": - return cssText; - } - return ""; - }; - function _simpleMedia(media) { - if (ALL.test(media)) return "all"; - else if (SCREEN.test(media)) return (PRINT.test(media)) ? "all" : "screen"; - else if (PRINT.test(media)) return "print"; - }; - var self = this; - function _getCSSText(styleSheet, path, media, level) { - var cssText = ""; - if (!level) { - media = _simpleMedia(styleSheet.media); - level = 0; - } - if (media == "all" || media == self.media) { - // IE only allows importing style sheets three levels deep. - // it will crash if you try to access a level below this - if (level < 3) { - // loop through imported style sheets - for (var i = 0; i < styleSheet.imports.length; i++) { - // call this function recursively to get all imported style sheets - cssText += _getCSSText(styleSheet.imports[i], getPath(styleSheet.href, path), media, level + 1); - } - } - // retrieve inline style or load an external style sheet - cssText += encode(styleSheet.href ? _loadStyleSheet(styleSheet, path) : _inlineStyles.pop() || ""); - cssText = _parseMedia(cssText, self.media); - } - return cssText; - }; - // store loaded cssText URLs - var fileCache = {}; - // load an external style sheet - function _loadStyleSheet(styleSheet, path) { - var url = makePath(styleSheet.href, path); - // if the style sheet has already loaded then don't duplicate it - if (fileCache[url]) return ""; - // load from source - fileCache[url] = (styleSheet.disabled) ? "" : - _fixUrls(IE7.CSS.getText(styleSheet, path), getPath(styleSheet.href, path)); - return fileCache[url]; - }; - // fix css paths - // we're lumping all css text into one big style sheet so relative - // paths have to be fixed. this is necessary anyway because of other - // explorer bugs. - var URL = /(url\s*\(\s*['"]?)([\w\.]+[^:\)]*['"]?\))/gi; - function _fixUrls(cssText, pathname) { - // hack & slash - return cssText.replace(URL, "$1" + pathname.slice(0, pathname.lastIndexOf("/") + 1) + "$2"); - }; - - // load all style sheets in the document - for (var i = 0; i < styleSheets.length; i++) { - if (!styleSheets[i].disabled && !styleSheets[i].ie7) { - this.cssText += _getCSSText(styleSheets[i]); - } - } - }, - - load: function() { - this.cssText = ""; - this.getText(); - this.parse(); - this.cssText = decode(this.cssText); - fileCache = {}; - }, - - parse: function() { - this.cssText = IE7.CSS.parser.exec(this.cssText); - - // parse the style sheet - var offset = IE7.CSS.rules.length; - var rules = this.cssText.split(BRACE2), rule; - var selectors, cssText, i, j; - for (i = 0; i < rules.length; i++) { - rule = rules[i].split(BRACE1); - selectors = rule[0].split(COMMA); - cssText = rule[1]; - for (j = 0; j < selectors.length; j++) { - selectors[j] = cssText ? this.createRule(selectors[j], cssText) : ""; - } - rules[i] = selectors.join("\n"); - } - this.cssText = rules.join("\n"); - this.rules = IE7.CSS.rules.slice(offset); - }, - - recalc: function() { - var rule, i; - for (i = 0; (rule = this.rules[i]); i++) rule.recalc(); - }, - - toString: function() { - return "@media " + this.media + "{" + this.cssText + "}"; - } -}); - -var PseudoElement; - -// ----------------------------------------------------------------------- -// IE7 style rules -// ----------------------------------------------------------------------- - -var Rule = IE7.Rule = Base.extend({ - // properties - constructor: function(selector, cssText) { - this.id = IE7.CSS.rules.length; - this.className = Rule.PREFIX + this.id; - selector = selector.match(FIRST_LINE_LETTER) || selector || "*"; - this.selector = selector[1] || selector; - this.selectorText = this.parse(this.selector) + (selector[2] || ""); - this.cssText = cssText; - this.MATCH = new RegExp("\\s" + this.className + "(\\s|$)", "g"); - IE7.CSS.rules.push(this); - this.init(); - }, - - init: Undefined, - - add: function(element) { - // allocate this class - element.className += " " + this.className; - }, - - recalc: function() { - // execute the underlying css query for this class - var match = cssQuery(this.selector); - // add the class name for all matching elements - for (var i = 0; i < match.length; i++) this.add(match[i]); - }, - - parse: function(selector) { - // attempt to preserve specificity for "loose" parsing by - // removing unknown tokens from a css selector but keep as - // much as we can.. - var simple = selector.replace(Rule.CHILD, " ").replace(Rule.COMPLEX, ""); - if (appVersion < 7) simple = simple.replace(Rule.MULTI, ""); - var tags = match(simple, Rule.TAGS).length - match(selector, Rule.TAGS).length; - var classes = match(simple, Rule.CLASSES).length - match(selector, Rule.CLASSES).length + 1; - while (classes > 0 && Rule.CLASS.test(simple)) { - simple = simple.replace(Rule.CLASS, ""); - classes--; - } - while (tags > 0 && Rule.TAG.test(simple)) { - simple = simple.replace(Rule.TAG, "$1*"); - tags--; - } - simple += "." + this.className; - classes = Math.min(classes, 2); - tags = Math.min(tags, 2); - var score = -10 * classes - tags; - if (score > 0) { - simple = simple + "," + Rule.MAP[score] + " " + simple; - } - return simple; - }, - - remove: function(element) { - // deallocate this class - element.className = element.className.replace(this.MATCH, "$1"); - }, - - toString: function() { - return format("%1 {%2}", this.selectorText, this.cssText); - } -}, { - CHILD: />/g, - CLASS: /\.[\w-]+/, - CLASSES: /[.:\[]/g, - MULTI: /(\.[\w-]+)+/g, - PREFIX: "ie7_class", - TAG: /^\w+|([\s>+~])\w+/, - TAGS: /^\w|[\s>+~]\w/g, - MAP: { - 1: "html", - 2: "html body", - 10: ".ie7_html", - 11: "html.ie7_html", - 12: "html.ie7_html body", - 20: ".ie7_html .ie7_body", - 21: "html.ie7_html .ie7_body", - 22: "html.ie7_html body.ie7_body" - } -}); - -// ----------------------------------------------------------------------- -// IE7 dynamic style -// ----------------------------------------------------------------------- - -// object properties: -// attach: the element that an event handler will be attached to -// target: the element that will have the IE7 class applied - -var DynamicRule = Rule.extend({ - // properties - constructor: function(selector, attach, dynamicPseudoClass, target, cssText) { - // initialise object properties - this.attach = attach || "*"; - this.dynamicPseudoClass = IE7.CSS.dynamicPseudoClasses[dynamicPseudoClass]; - this.target = target; - this.base(selector, cssText); - }, - - recalc: function() { - // execute the underlying css query for this class - var attaches = cssQuery(this.attach), attach; - // process results - for (var i = 0; attach = attaches[i]; i++) { - // retrieve the event handler's target element(s) - var target = this.target ? cssQuery(this.target, attach) : [attach]; - // attach event handlers for dynamic pseudo-classes - if (target.length) this.dynamicPseudoClass.apply(attach, target, this); - } - } -}); - -// ----------------------------------------------------------------------- -// IE7 dynamic pseudo-classes -// ----------------------------------------------------------------------- - -var DynamicPseudoClass = Base.extend({ - constructor: function(name, apply) { - this.name = name; - this.apply = apply; - this.instances = {}; - IE7.CSS.dynamicPseudoClasses[name] = this; - }, - - register: function(instance) { - // an "instance" is actually an Arguments object - var _class = instance[2]; - instance.id = _class.id + instance[0].uniqueID; - if (!this.instances[instance.id]) { - var target = instance[1], j; - for (j = 0; j < target.length; j++) _class.add(target[j]); - this.instances[instance.id] = instance; - } - }, - - unregister: function(instance) { - if (this.instances[instance.id]) { - var _class = instance[2]; - var target = instance[1], j; - for (j = 0; j < target.length; j++) _class.remove(target[j]); - delete this.instances[instance.id]; - } - } -}); - -// ----------------------------------------------------------------------- -// dynamic pseudo-classes -// ----------------------------------------------------------------------- - -if (appVersion < 7) { - var Hover = new DynamicPseudoClass("hover", function(element) { - var instance = arguments; - IE7.CSS.addEventHandler(element, appVersion < 5.5 ? "onmouseover" : "onmouseenter", function() { - Hover.register(instance); - }); - IE7.CSS.addEventHandler(element, appVersion < 5.5 ? "onmouseout" : "onmouseleave", function() { - Hover.unregister(instance); - }); - }); - - // globally trap the mouseup event (thanks Martijn!) - addEventHandler(document, "onmouseup", function() { - var instances = Hover.instances; - for (var i in instances) - if (!instances[i][0].contains(event.srcElement)) - Hover.unregister(instances[i]); - }); -} - -// ----------------------------------------------------------------------- -// propertyName: inherit; -// ----------------------------------------------------------------------- - -IE7.CSS.addRecalc("[\\w-]+", "inherit", function(element, cssText) { - var inherited = cssText.match(/[\w-]+\s*:\s*inherit/g); - for (var i = 0; i < inherited.length; i++) { - var propertyName = inherited[i].replace(/ie7\-|\s*:\s*inherit/g, "").replace(/\-([a-z])/g, function(match, chr) { - return chr.toUpperCase() - }); - element.runtimeStyle[propertyName] = element.parentElement.currentStyle[propertyName]; - } -}); - -// ========================================================================= -// ie7-html.js -// ========================================================================= - -// default font-sizes -//HEADER += "h1{font-size:2em}h2{font-size:1.5em;}h3{font-size:1.17em;}h4{font-size:1em}h5{font-size:.83em}h6{font-size:.67em}"; - -IE7.HTML = new (Fix.extend({ // single instance - fixed: {}, - - init: Undefined, - - addFix: function() { - // fixes are a one-off, they are applied when the document is loaded - this.fixes.push(arguments); - }, - - apply: function() { - for (var i = 0; i < this.fixes.length; i++) { - var match = cssQuery(this.fixes[i][0]); - var fix = this.fixes[i][1]; - for (var j = 0; j < match.length; j++) fix(match[j]); - } - }, - - addRecalc: function() { - // recalcs occur whenever the document is refreshed using document.recalc() - this.recalcs.push(arguments); - }, - - recalc: function() { - // loop through the fixes - for (var i = 0; i < this.recalcs.length; i++) { - var match = cssQuery(this.recalcs[i][0]); - var recalc = this.recalcs[i][1], element; - var key = Math.pow(2, i); - for (var j = 0; (element = match[j]); j++) { - var uniqueID = element.uniqueID; - if ((this.fixed[uniqueID] & key) == 0) { - element = recalc(element) || element; - this.fixed[uniqueID] |= key; - } - } - } - } -})); - -if (appVersion < 7) { - // provide support for the tag. - // this is a proper fix, it preserves the DOM structure and - // elements report the correct tagName & namespace prefix - document.createElement("abbr"); - - // bind to the first child control - IE7.HTML.addRecalc("label", function(label) { - if (!label.htmlFor) { - var firstChildControl = cssQuery("input,textarea", label, true); - if (firstChildControl) { - addEventHandler(label, "onclick", function() { - firstChildControl.click(); - }); - } - } - }); -} - -// ========================================================================= -// ie7-layout.js -// ========================================================================= - -var NUMERIC = "[.\\d]"; - -new function(_) { -var layout = IE7.Layout = this; - - // big, ugly box-model hack + min/max stuff - - // #tantek > #erik > #dean { voice-family: hacker; } - - // ----------------------------------------------------------------------- - // "layout" - // ----------------------------------------------------------------------- - - HEADER += "*{boxSizing:content-box}"; - - // does an element have "layout" ? - IE7.hasLayout = appVersion < 5.5 ? function(element) { - // element.currentStyle.hasLayout doesn't work for IE5.0 - return element.clientWidth; - } : function(element) { - return element.currentStyle.hasLayout; - }; - - // give an element "layout" - layout.boxSizing = function(element) { - if (!IE7.hasLayout(element)) { - //# element.runtimeStyle.fixedHeight = - element.style.height = "0cm"; - if (element.currentStyle.verticalAlign == "auto") - element.runtimeStyle.verticalAlign = "top"; - // when an element acquires "layout", margins no longer collapse correctly - collapseMargins(element); - } - }; - - // ----------------------------------------------------------------------- - // Margin Collapse - // ----------------------------------------------------------------------- - - function collapseMargins(element) { - if (element != viewport && element.currentStyle.position != "absolute") { - collapseMargin(element, "marginTop"); - collapseMargin(element, "marginBottom"); - } - }; - - function collapseMargin(element, type) { - if (!element.runtimeStyle[type]) { - var parentElement = element.parentElement; - if (parentElement && IE7.hasLayout(parentElement) && !IE7[type == "marginTop" ? "_getPreviousElementSibling" : "_getNextElementSibling"](element)) return; - var child = cssQuery(">*:" + (type == "marginTop" ? "first" : "last") + "-child", element, true); - if (child && child.currentStyle.styleFloat == "none" && IE7.hasLayout(child)) { - collapseMargin(child, type); - margin = _getMargin(element, element.currentStyle[type]); - childMargin = _getMargin(child, child.currentStyle[type]); - if (margin < 0 || childMargin < 0) { - element.runtimeStyle[type] = margin + childMargin; - } else { - element.runtimeStyle[type] = Math.max(childMargin, margin); - } - child.runtimeStyle[type] = "0px"; - } - } - }; - - function _getMargin(element, value) { - return value == "auto" ? 0 : getPixelValue(element, value); - }; - - // ----------------------------------------------------------------------- - // box-model - // ----------------------------------------------------------------------- - - // constants - var UNIT = /^[.\d][\w%]*$/, AUTO = /^(auto|0cm)$/; - - var applyWidth, applyHeight; - IE7.Layout.borderBox = function(element){ - applyWidth(element); - applyHeight(element); - }; - - var fixWidth = function(HEIGHT) { - applyWidth = function(element) { - if (!PERCENT.test(element.currentStyle.width)) fixWidth(element); - collapseMargins(element); - }; - - function fixWidth(element, value) { - if (!element.runtimeStyle.fixedWidth) { - if (!value) value = element.currentStyle.width; - element.runtimeStyle.fixedWidth = (UNIT.test(value)) ? Math.max(0, getFixedWidth(element, value)) : value; - setOverrideStyle(element, "width", element.runtimeStyle.fixedWidth); - } - }; - - function layoutWidth(element) { - if (!isFixed(element)) { - var layoutParent = element.offsetParent; - while (layoutParent && !IE7.hasLayout(layoutParent)) layoutParent = layoutParent.offsetParent; - } - return (layoutParent || viewport).clientWidth; - }; - - function getPixelWidth(element, value) { - if (PERCENT.test(value)) return parseInt(parseFloat(value) / 100 * layoutWidth(element)); - return getPixelValue(element, value); - }; - - var getFixedWidth = function(element, value) { - var borderBox = element.currentStyle["box-sizing"] == "border-box"; - var adjustment = 0; - if (quirksMode && !borderBox) - adjustment += getBorderWidth(element) + getWidth(element, "padding"); - else if (!quirksMode && borderBox) - adjustment -= getBorderWidth(element) + getWidth(element, "padding"); - return getPixelWidth(element, value) + adjustment; - }; - - // easy way to get border thickness for elements with "layout" - function getBorderWidth(element) { - return element.offsetWidth - element.clientWidth; - }; - - // have to do some pixel conversion to get padding/margin thickness :-( - function getWidth(element, type) { - return getPixelWidth(element, element.currentStyle[type + "Left"]) + getPixelWidth(element, element.currentStyle[type + "Right"]); - }; - - // ----------------------------------------------------------------------- - // min/max - // ----------------------------------------------------------------------- - - HEADER += "*{minWidth:none;maxWidth:none;min-width:none;max-width:none}"; - - // handle min-width property - layout.minWidth = function(element) { - // IE6 supports min-height so we frig it here - //#if (element.currentStyle.minHeight == "auto") element.runtimeStyle.minHeight = 0; - if (element.currentStyle["min-width"] != null) { - element.style.minWidth = element.currentStyle["min-width"]; - } - if (register(arguments.callee, element, element.currentStyle.minWidth != "none")) { - layout.boxSizing(element); - fixWidth(element); - resizeWidth(element); - } - }; - - // clone the minWidth function to make a maxWidth function - eval("IE7.Layout.maxWidth=" + String(layout.minWidth).replace(/min/g, "max")); - - // apply min/max restrictions - function resizeWidth(element) { - // check boundaries - var rect = element.getBoundingClientRect(); - var width = rect.right - rect.left; - - if (element.currentStyle.minWidth != "none" && width <= getFixedWidth(element, element.currentStyle.minWidth)) { - element.runtimeStyle.width = element.currentStyle.minWidth; - } else if (element.currentStyle.maxWidth != "none" && width >= getFixedWidth(element, element.currentStyle.maxWidth)) { - element.runtimeStyle.width = element.currentStyle.maxWidth; - } else { - element.runtimeStyle.width = element.runtimeStyle.fixedWidth; // || "auto"; - } - }; - - // ----------------------------------------------------------------------- - // right/bottom - // ----------------------------------------------------------------------- - - function fixRight(element) { - if (register(fixRight, element, /^(fixed|absolute)$/.test(element.currentStyle.position) && - getDefinedStyle(element, "left") != "auto" && - getDefinedStyle(element, "right") != "auto" && - AUTO.test(getDefinedStyle(element, "width")))) { - resizeRight(element); - IE7.Layout.boxSizing(element); - } - }; - IE7.Layout.fixRight = fixRight; - - function resizeRight(element) { - var left = getPixelWidth(element, element.runtimeStyle._left || element.currentStyle.left); - var width = layoutWidth(element) - getPixelWidth(element, element.currentStyle.right) - left - getWidth(element, "margin"); - if (parseInt(element.runtimeStyle.width) == width) return; - element.runtimeStyle.width = ""; - if (isFixed(element) || HEIGHT || element.offsetWidth < width) { - if (!quirksMode) width -= getBorderWidth(element) + getWidth(element, "padding"); - if (width < 0) width = 0; - element.runtimeStyle.fixedWidth = width; - setOverrideStyle(element, "width", width); - } - }; - - // ----------------------------------------------------------------------- - // window.onresize - // ----------------------------------------------------------------------- - - // handle window resize - var clientWidth = 0; - addResize(function() { - if (!viewport) return; - var i, wider = (clientWidth < viewport.clientWidth); - clientWidth = viewport.clientWidth; - // resize elements with "min-width" set - var elements = layout.minWidth.elements; - for (i in elements) { - var element = elements[i]; - var fixedWidth = (parseInt(element.runtimeStyle.width) == getFixedWidth(element, element.currentStyle.minWidth)); - if (wider && fixedWidth) element.runtimeStyle.width = ""; - if (wider == fixedWidth) resizeWidth(element); - } - // resize elements with "max-width" set - var elements = layout.maxWidth.elements; - for (i in elements) { - var element = elements[i]; - var fixedWidth = (parseInt(element.runtimeStyle.width) == getFixedWidth(element, element.currentStyle.maxWidth)); - if (!wider && fixedWidth) element.runtimeStyle.width = ""; - if (wider != fixedWidth) resizeWidth(element); - } - // resize elements with "right" set - for (i in fixRight.elements) resizeRight(fixRight.elements[i]); - }); - - // ----------------------------------------------------------------------- - // fix CSS - // ----------------------------------------------------------------------- - if (quirksMode) { - IE7.CSS.addRecalc("width", NUMERIC, applyWidth); - } - if (appVersion < 7) { - IE7.CSS.addRecalc("min-width", NUMERIC, layout.minWidth); - IE7.CSS.addRecalc("max-width", NUMERIC, layout.maxWidth); - IE7.CSS.addRecalc("right", NUMERIC, fixRight); - } - }; - - eval("var fixHeight=" + rotate(fixWidth)); - - // apply box-model + min/max fixes - fixWidth(); - fixHeight(true); -}; - -// ========================================================================= -// ie7-graphics.js -// ========================================================================= - -// a small transparent image used as a placeholder -var BLANK_GIF = makePath("blank.gif", path); - -var ALPHA_IMAGE_LOADER = "DXImageTransform.Microsoft.AlphaImageLoader"; -var PNG_FILTER = "progid:" + ALPHA_IMAGE_LOADER + "(src='%1',sizingMethod='%2')"; - -// regular expression version of the above -var PNG; - -var filtered = []; - -function fixImage(element) { - if (PNG.test(element.src)) { - // we have to preserve width and height - var image = new Image(element.width, element.height); - image.onload = function() { - element.width = image.width; - element.height = image.height; - image = null; - }; - image.src = element.src; - // store the original url (we'll put it back when it's printed) - element.pngSrc = element.src; - // add the AlphaImageLoader thingy - addFilter(element); - } -}; - -if (appVersion >= 5.5 && appVersion < 7) { - // ** IE7 VARIABLE - // e.g. only apply the hack to files ending in ".png" - // IE7_PNG_SUFFIX = ".png"; - - // replace background(-image): url(..) .. with background(-image): .. ;filter: ..; - IE7.CSS.addFix(/background(-image)?\s*:\s*([^};]*)?url\(([^\)]+)\)([^;}]*)?/, function(match, $1, $2, url, $4) { - url = getString(url); - return PNG.test(url) ? "filter:" + format(PNG_FILTER, url, "crop") + - ";zoom:1;background" + ($1||"") + ":" + ($2||"") + "none" + ($4||"") : match; - }); - - // ----------------------------------------------------------------------- - // fix PNG transparency (HTML images) - // ----------------------------------------------------------------------- - - IE7.HTML.addRecalc("img,input", function(element) { - if (element.tagName == "INPUT" && element.type != "image") return; - fixImage(element); - addEventHandler(element, "onpropertychange", function() { - if (!printing && event.propertyName == "src" && - element.src.indexOf(BLANK_GIF) == -1) fixImage(element); - }); - }); - - // assume that background images should not be printed - // (if they are not transparent then they'll just obscure content) - // but we'll put foreground images back... - var printing = false; - addEventHandler(window, "onbeforeprint", function() { - printing = true; - for (var i = 0; i < filtered.length; i++) removeFilter(filtered[i]); - }); - addEventHandler(window, "onafterprint", function() { - for (var i = 0; i < filtered.length; i++) addFilter(filtered[i]); - printing = false; - }); -} - -// apply a filter -function addFilter(element, sizingMethod) { - var filter = element.filters[ALPHA_IMAGE_LOADER]; - if (filter) { - filter.src = element.src; - filter.enabled = true; - } else { - element.runtimeStyle.filter = format(PNG_FILTER, element.src, sizingMethod || "scale"); - filtered.push(element); - } - // remove the real image - element.src = BLANK_GIF; -}; - -function removeFilter(element) { - element.src = element.pngSrc; - element.filters[ALPHA_IMAGE_LOADER].enabled = false; -}; - -// ========================================================================= -// ie7-fixed.js -// ========================================================================= - -new function(_) { - if (appVersion >= 7) return; - - // some things to consider for this hack. - // the document body requires a fixed background. even if - // it is just a blank image. - // you have to use setExpression instead of onscroll, this - // together with a fixed body background helps avoid the - // annoying screen flicker of other solutions. - - IE7.CSS.addRecalc("position", "fixed", _positionFixed, "absolute"); - IE7.CSS.addRecalc("background(-attachment)?", "[^};]*fixed", _backgroundFixed); - - // scrolling is relative to the documentElement (HTML tag) when in - // standards mode, otherwise it's relative to the document body - var $viewport = quirksMode ? "body" : "documentElement"; - - function _fixBackground() { - // this is required by both position:fixed and background-attachment:fixed. - // it is necessary for the document to also have a fixed background image. - // we can fake this with a blank image if necessary - if (body.currentStyle.backgroundAttachment != "fixed") { - if (body.currentStyle.backgroundImage == "none") { - body.runtimeStyle.backgroundRepeat = "no-repeat"; - body.runtimeStyle.backgroundImage = "url(" + BLANK_GIF + ")"; // dummy - } - body.runtimeStyle.backgroundAttachment = "fixed"; - } - _fixBackground = Undefined; - }; - - var _tmp = createTempElement("img"); - - function _isFixed(element) { - return element ? isFixed(element) || _isFixed(element.parentElement) : false; - }; - - function _setExpression(element, propertyName, expression) { - setTimeout("document.all." + element.uniqueID + ".runtimeStyle.setExpression('" + propertyName + "','" + expression + "')", 0); - }; - - // ----------------------------------------------------------------------- - // backgroundAttachment: fixed - // ----------------------------------------------------------------------- - - function _backgroundFixed(element) { - if (register(_backgroundFixed, element, element.currentStyle.backgroundAttachment == "fixed" && !element.contains(body))) { - _fixBackground(); - bgLeft(element); - bgTop(element); - _backgroundPosition(element); - } - }; - - function _backgroundPosition(element) { - _tmp.src = element.currentStyle.backgroundImage.slice(5, -2); - var parentElement = element.canHaveChildren ? element : element.parentElement; - parentElement.appendChild(_tmp); - setOffsetLeft(element); - setOffsetTop(element); - parentElement.removeChild(_tmp); - }; - - function bgLeft(element) { - element.style.backgroundPositionX = element.currentStyle.backgroundPositionX; - if (!_isFixed(element)) { - _setExpression(element, "backgroundPositionX", "(parseInt(runtimeStyle.offsetLeft)+document." + $viewport + ".scrollLeft)||0"); - } - }; - eval(rotate(bgLeft)); - - function setOffsetLeft(element) { - var propertyName = _isFixed(element) ? "backgroundPositionX" : "offsetLeft"; - element.runtimeStyle[propertyName] = - getOffsetLeft(element, element.style.backgroundPositionX) - - element.getBoundingClientRect().left - element.clientLeft + 2; - }; - eval(rotate(setOffsetLeft)); - - function getOffsetLeft(element, position) { - switch (position) { - case "left": - case "top": - return 0; - case "right": - case "bottom": - return viewport.clientWidth - _tmp.offsetWidth; - case "center": - return (viewport.clientWidth - _tmp.offsetWidth) / 2; - default: - if (PERCENT.test(position)) { - return parseInt((viewport.clientWidth - _tmp.offsetWidth) * parseFloat(position) / 100); - } - _tmp.style.left = position; - return _tmp.offsetLeft; - } - }; - eval(rotate(getOffsetLeft)); - - // ----------------------------------------------------------------------- - // position: fixed - // ----------------------------------------------------------------------- - - function _positionFixed(element) { - if (register(_positionFixed, element, isFixed(element))) { - setOverrideStyle(element, "position", "absolute"); - setOverrideStyle(element, "left", element.currentStyle.left); - setOverrideStyle(element, "top", element.currentStyle.top); - _fixBackground(); - IE7.Layout.fixRight(element); - _foregroundPosition(element); - } - }; - - function _foregroundPosition(element, recalc) { - positionTop(element, recalc); - positionLeft(element, recalc, true); - if (!element.runtimeStyle.autoLeft && element.currentStyle.marginLeft == "auto" && - element.currentStyle.right != "auto") { - var left = viewport.clientWidth - getPixelWidth(element, element.currentStyle.right) - - getPixelWidth(element, element.runtimeStyle._left) - element.clientWidth; - if (element.currentStyle.marginRight == "auto") left = parseInt(left / 2); - if (_isFixed(element.offsetParent)) element.runtimeStyle.pixelLeft += left; - else element.runtimeStyle.shiftLeft = left; - } - clipWidth(element); - clipHeight(element); - }; - - function clipWidth(element) { - var fixWidth = element.runtimeStyle.fixWidth; - element.runtimeStyle.borderRightWidth = ""; - element.runtimeStyle.width = fixWidth ? getPixelWidth(element, fixWidth) : ""; - if (element.currentStyle.width != "auto") { - var rect = element.getBoundingClientRect(); - var width = element.offsetWidth - viewport.clientWidth + rect.left - 2; - if (width >= 0) { - element.runtimeStyle.borderRightWidth = "0px"; - width = Math.max(getPixelValue(element, element.currentStyle.width) - width, 0); - setOverrideStyle(element, "width", width); - return width; - } - } - }; - eval(rotate(clipWidth)); - - function positionLeft(element, recalc) { - // if the element's width is in % units then it must be recalculated - // with respect to the viewport - if (!recalc && PERCENT.test(element.currentStyle.width)) { - element.runtimeStyle.fixWidth = element.currentStyle.width; - } - if (element.runtimeStyle.fixWidth) { - element.runtimeStyle.width = getPixelWidth(element, element.runtimeStyle.fixWidth); - } - //if (recalc) { - // // if the element is fixed on the right then no need to recalculate - // if (!element.runtimeStyle.autoLeft) return; - //} else { - element.runtimeStyle.shiftLeft = 0; - element.runtimeStyle._left = element.currentStyle.left; - // is the element fixed on the right? - element.runtimeStyle.autoLeft = element.currentStyle.right != "auto" && - element.currentStyle.left == "auto"; - //} - // reset the element's "left" value and get it's natural position - element.runtimeStyle.left = ""; - element.runtimeStyle.screenLeft = getScreenLeft(element); - element.runtimeStyle.pixelLeft = element.runtimeStyle.screenLeft; - // if the element is contained by another fixed element then there is no need to - // continually recalculate it's left position - if (!recalc && !_isFixed(element.offsetParent)) { - // onsrcoll produces jerky movement, so we use an expression - _setExpression(element, "pixelLeft", "runtimeStyle.screenLeft+runtimeStyle.shiftLeft+document." + $viewport + ".scrollLeft"); - } - }; - // clone this function so we can do "top" - eval(rotate(positionLeft)); - - // I've forgotten how this works... - function getScreenLeft(element) { // thanks to kevin newman (captainn) - var screenLeft = element.offsetLeft, nested = 1; - if (element.runtimeStyle.autoLeft) { - screenLeft = viewport.clientWidth - element.offsetWidth - getPixelWidth(element, element.currentStyle.right); - } - // accommodate margins - if (element.currentStyle.marginLeft != "auto") { - screenLeft -= getPixelWidth(element, element.currentStyle.marginLeft); - } - while (element = element.offsetParent) { - if (element.currentStyle.position != "static") nested = -1; - screenLeft += element.offsetLeft * nested; - } - return screenLeft; - }; - eval(rotate(getScreenLeft)); - - function getPixelWidth(element, value) { - return PERCENT.test(value) ? parseInt(parseFloat(value) / 100 * viewport.clientWidth) : getPixelValue(element, value); - }; - eval(rotate(getPixelWidth)); - - // ----------------------------------------------------------------------- - // capture window resize - // ----------------------------------------------------------------------- - - function _resize() { - // if the window has been resized then some positions need to be - // recalculated (especially those aligned to "right" or "top" - var elements = _backgroundFixed.elements; - for (var i in elements) _backgroundPosition(elements[i]); - elements = _positionFixed.elements; - for (i in elements) { - _foregroundPosition(elements[i], true); - // do this twice to be sure - hackish, I know :-) - _foregroundPosition(elements[i], true); - } - _timer = 0; - }; - - // use a timer for some reason. - // (sometimes this is a good way to prevent resize loops) - var _timer; - addResize(function() { - if (!_timer) _timer = setTimeout(_resize, 0); - }); -}; - -// ========================================================================= -// ie7-oveflow.js -// ========================================================================= - -/* --------------------------------------------------------------------- - - This module alters the structure of the document. - It may adversely affect other CSS rules. Be warned. - ---------------------------------------------------------------------- */ - -var WRAPPER_STYLE = { - backgroundColor: "transparent", - backgroundImage: "none", - backgroundPositionX: null, - backgroundPositionY: null, - backgroundRepeat: null, - borderTopWidth: 0, - borderRightWidth: 0, - borderBottomWidth: 0, - borderLeftStyle: "none", - borderTopStyle: "none", - borderRightStyle: "none", - borderBottomStyle: "none", - borderLeftWidth: 0, - height: null, - marginTop: 0, - marginBottom: 0, - marginRight: 0, - marginLeft: 0, - width: "100%" -}; - -IE7.CSS.addRecalc("overflow", "visible", function(element) { - // don't do this again - if (element.parentNode.ie7_wrapped) return; - - // if max-height is applied, makes sure it gets applied first - if (IE7.Layout && element.currentStyle["max-height"] != "auto") { - IE7.Layout.maxHeight(element); - } - - if (element.currentStyle.marginLeft == "auto") element.style.marginLeft = 0; - if (element.currentStyle.marginRight == "auto") element.style.marginRight = 0; - - var wrapper = document.createElement(ANON); - wrapper.ie7_wrapped = element; - for (var propertyName in WRAPPER_STYLE) { - wrapper.style[propertyName] = element.currentStyle[propertyName]; - if (WRAPPER_STYLE[propertyName] != null) { - element.runtimeStyle[propertyName] = WRAPPER_STYLE[propertyName]; - } - } - wrapper.style.display = "block"; - wrapper.style.position = "relative"; - element.runtimeStyle.position = "absolute"; - element.parentNode.insertBefore(wrapper, element); - wrapper.appendChild(element); -}); - -// ========================================================================= -// ie7-quirks.js -// ========================================================================= - -function ie7Quirks() { - var FONT_SIZES = "xx-small,x-small,small,medium,large,x-large,xx-large".split(","); - for (var i = 0; i < FONT_SIZES.length; i++) { - FONT_SIZES[FONT_SIZES[i]] = FONT_SIZES[i - 1] || "0.67em"; - } - - IE7.CSS.addFix(/(font(-size)?\s*:\s*)([\w.-]+)/, function(match, label, size, value) { - return label + (FONT_SIZES[value] || value); - }); - - if (appVersion < 6) { - var NEGATIVE = /^\-/, LENGTH = /(em|ex)$/i; - var EM = /em$/i, EX = /ex$/i; - - getPixelValue = function(element, value) { - if (PIXEL.test(value)) return parseInt(value)||0; - var scale = NEGATIVE.test(value)? -1 : 1; - if (LENGTH.test(value)) scale *= getFontScale(element); - temp.style.width = (scale < 0) ? value.slice(1) : value; - body.appendChild(temp); - // retrieve pixel width - value = scale * temp.offsetWidth; - // remove the temporary element - temp.removeNode(); - return parseInt(value); - }; - - var temp = createTempElement(); - function getFontScale(element) { - var scale = 1; - temp.style.fontFamily = element.currentStyle.fontFamily; - temp.style.lineHeight = element.currentStyle.lineHeight; - //temp.style.fontSize = ""; - while (element != body) { - var fontSize = element.currentStyle["ie7-font-size"]; - if (fontSize) { - if (EM.test(fontSize)) scale *= parseFloat(fontSize); - else if (PERCENT.test(fontSize)) scale *= (parseFloat(fontSize) / 100); - else if (EX.test(fontSize)) scale *= (parseFloat(fontSize) / 2); - else { - temp.style.fontSize = fontSize; - return 1; - } - } - element = element.parentElement; - } - return scale; - }; - - // cursor:pointer (IE5.x) - IE7.CSS.addFix(/cursor\s*:\s*pointer/, "cursor:hand"); - // display:list-item (IE5.x) - IE7.CSS.addFix(/display\s*:\s*list-item/, "display:block"); - } - - // ----------------------------------------------------------------------- - // margin:auto - // ----------------------------------------------------------------------- - - function fixMargin(element) { - if (appVersion < 5.5) IE7.Layout.boxSizing(element.parentElement); - var parent = element.parentElement; - var margin = parent.offsetWidth - element.offsetWidth - getPaddingWidth(parent); - var autoRight = (element.currentStyle["ie7-margin"] && element.currentStyle.marginRight == "auto") || - element.currentStyle["ie7-margin-right"] == "auto"; - switch (parent.currentStyle.textAlign) { - case "right": - margin = autoRight ? parseInt(margin / 2) : 0; - element.runtimeStyle.marginRight = margin + "px"; - break; - case "center": - if (autoRight) margin = 0; - default: - if (autoRight) margin /= 2; - element.runtimeStyle.marginLeft = parseInt(margin) + "px"; - } - }; - - function getPaddingWidth(element) { - return getPixelValue(element, element.currentStyle.paddingLeft) + - getPixelValue(element, element.currentStyle.paddingRight); - }; - - IE7.CSS.addRecalc("margin(-left|-right)?", "[^};]*auto", function(element) { - if (register(fixMargin, element, - element.parentElement && - element.currentStyle.display == "block" && - element.currentStyle.marginLeft == "auto" && - element.currentStyle.position != "absolute")) { - fixMargin(element); - } - }); - - addResize(function() { - for (var i in fixMargin.elements) { - var element = fixMargin.elements[i]; - element.runtimeStyle.marginLeft = - element.runtimeStyle.marginRight = ""; - fixMargin(element); - } - }); -}; - - -// ========================================================================= -// ie8-cssQuery.js -// ========================================================================= - -IE7._isEmpty = function(element) { - element = element.firstChild; - while (element) { - if (element.nodeType == 3 || (element.nodeType == 1 && element.nodeName != "!")) return false; - element = element.nextSibling; - } - return true; -}; - -IE7._isLang = function(element, code) { - while (element && !element.getAttribute("lang")) element = element.parentNode; - return element && new RegExp("^" + rescape(code), "i").test(element.getAttribute("lang")); -}; - -function _nthChild(match, args, position, last) { - // ugly but it works... - last = /last/i.test(match) ? last + "+1-" : ""; - if (!isNaN(args)) args = "0n+" + args; - else if (args == "even") args = "2n"; - else if (args == "odd") args = "2n+1"; - args = args.split("n"); - var a = args[0] ? (args[0] == "-") ? -1 : parseInt(args[0]) : 1; - var b = parseInt(args[1]) || 0; - var negate = a < 0; - if (negate) { - a = -a; - if (a == 1) b++; - } - var query = format(a == 0 ? "%3%7" + (last + b) : "(%4%3-%2)%6%1%70%5%4%3>=%2", a, b, position, last, "&&", "%", "=="); - if (negate) query = "!(" + query + ")"; - return query; -}; - -_PSEUDO_CLASSES = { - "link": "e%1.currentStyle['ie7-link']=='link'", - "visited": "e%1.currentStyle['ie7-link']=='visited'", - "checked": "e%1.checked", - "contains": "e%1.innerText.indexOf('%2')!=-1", - "disabled": "e%1.isDisabled", - "empty": "IE7._isEmpty(e%1)", - "enabled": "e%1.disabled===false", - "first-child": "!IE7._getPreviousElementSibling(e%1)", - "lang": "IE7._isLang(e%1,'%2')", - "last-child": "!IE7._getNextElementSibling(e%1)", - "only-child": "!IE7._getPreviousElementSibling(e%1)&&!IE7._getNextElementSibling(e%1)", - "target": "e%1.id==location.hash.slice(1)", - "indeterminate": "e%1.indeterminate" -}; - - -// register a node and index its children -IE7._register = function(element) { - if (element.rows) { - element.ie7_length = element.rows.length; - element.ie7_lookup = "rowIndex"; - } else if (element.cells) { - element.ie7_length = element.cells.length; - element.ie7_lookup = "cellIndex"; - } else if (element.ie7_indexed != IE7._indexed) { - var index = 0; - var child = element.firstChild; - while (child) { - if (child.nodeType == 1 && child.nodeName != "!") { - child.ie7_index = ++index; - } - child = child.nextSibling; - } - element.ie7_length = index; - element.ie7_lookup = "ie7_index"; - } - element.ie7_indexed = IE7._indexed; - return element; -}; - -var keys = cssParser[_KEYS]; -var pseudoClass = keys[keys.length - 1]; -keys.length--; - -cssParser.merge({ - ":not\\((\\*|[\\w-]+)?([^)]*)\\)": function(match, tagName, filters) { // :not pseudo class - var replacement = (tagName && tagName != "*") ? format("if(e%1.nodeName=='%2'){", _index, tagName.toUpperCase()) : ""; - replacement += cssParser.exec(filters); - return "if(!" + replacement.slice(2, -1).replace(/\)\{if\(/g, "&&") + "){"; - }, - - ":nth(-last)?-child\\(([^)]+)\\)": function(match, last, args) { // :nth-child pseudo classes - _wild = false; - last = format("e%1.parentNode.ie7_length", _index); - var replacement = "if(p%1!==e%1.parentNode)p%1=IE7._register(e%1.parentNode);"; - replacement += "var i=e%1[p%1.ie7_lookup];if(p%1.ie7_lookup!='ie7_index')i++;if("; - return format(replacement, _index) + _nthChild(match, args, "i", last) + "){"; - } -}); - -keys.push(pseudoClass); - -// ========================================================================= -// ie8-css.js -// ========================================================================= - -var BRACKETS = "\\([^)]*\\)"; - -if (IE7.CSS.pseudoClasses) IE7.CSS.pseudoClasses += "|"; -IE7.CSS.pseudoClasses += "before|after|last\\-child|only\\-child|empty|root|" + - "not|nth\\-child|nth\\-last\\-child|contains|lang".split("|").join(BRACKETS + "|") + BRACKETS; - -// pseudo-elements can be declared with a double colon -encoder.add(/::/, ":"); - -// ----------------------------------------------------------------------- -// dynamic pseudo-classes -// ----------------------------------------------------------------------- - -var Focus = new DynamicPseudoClass("focus", function(element) { - var instance = arguments; - - IE7.CSS.addEventHandler(element, "onfocus", function() { - Focus.unregister(instance); // in case it starts with focus - Focus.register(instance); - }); - - IE7.CSS.addEventHandler(element, "onblur", function() { - Focus.unregister(instance); - }); - - // check the active element for initial state - if (element == document.activeElement) { - Focus.register(instance) - } -}); - -var Active = new DynamicPseudoClass("active", function(element) { - var instance = arguments; - IE7.CSS.addEventHandler(element, "onmousedown", function() { - Active.register(instance); - }); -}); - -// globally trap the mouseup event (thanks Martijn!) -addEventHandler(document, "onmouseup", function() { - var instances = Active.instances; - for (var i in instances) Active.unregister(instances[i]); -}); - -// :checked -var Checked = new DynamicPseudoClass("checked", function(element) { - if (typeof element.checked != "boolean") return; - var instance = arguments; - IE7.CSS.addEventHandler(element, "onpropertychange", function() { - if (event.propertyName == "checked") { - if (element.checked) Checked.register(instance); - else Checked.unregister(instance); - } - }); - // check current checked state - if (element.checked) Checked.register(instance); -}); - -// :enabled -var Enabled = new DynamicPseudoClass("enabled", function(element) { - if (typeof element.disabled != "boolean") return; - var instance = arguments; - IE7.CSS.addEventHandler(element, "onpropertychange", function() { - if (event.propertyName == "disabled") { - if (!element.isDisabled) Enabled.register(instance); - else Enabled.unregister(instance); - } - }); - // check current disabled state - if (!element.isDisabled) Enabled.register(instance); -}); - -// :disabled -var Disabled = new DynamicPseudoClass("disabled", function(element) { - if (typeof element.disabled != "boolean") return; - var instance = arguments; - IE7.CSS.addEventHandler(element, "onpropertychange", function() { - if (event.propertyName == "disabled") { - if (element.isDisabled) Disabled.register(instance); - else Disabled.unregister(instance); - } - }); - // check current disabled state - if (element.isDisabled) Disabled.register(instance); -}); - -// :indeterminate (Kevin Newman) -var Indeterminate = new DynamicPseudoClass("indeterminate", function(element) { - if (typeof element.indeterminate != "boolean") return; - var instance = arguments; - IE7.CSS.addEventHandler(element, "onpropertychange", function() { - if (event.propertyName == "indeterminate") { - if (element.indeterminate) Indeterminate.register(instance); - else Indeterminate.unregister(instance); - } - }); - IE7.CSS.addEventHandler(element, "onclick", function() { - Indeterminate.unregister(instance); - }); - // clever Kev says no need to check this up front -}); - -// :target -var Target = new DynamicPseudoClass("target", function(element) { - var instance = arguments; - // if an element has a tabIndex then it can become "active". - // The default is zero anyway but it works... - if (!element.tabIndex) element.tabIndex = 0; - // this doesn't detect the back button. I don't know how to do that :-( - IE7.CSS.addEventHandler(document, "onpropertychange", function() { - if (event.propertyName == "activeElement") { - if (element.id && element.id == location.hash.slice(1)) Target.register(instance); - else Target.unregister(instance); - } - }); - // check the current location - if (element.id && element.id == location.hash.slice(1)) Target.register(instance); -}); - -// ----------------------------------------------------------------------- -// IE7 pseudo elements -// ----------------------------------------------------------------------- - -// constants -var ATTR = /^attr/; -var URL = /^url\s*\(\s*([^)]*)\)$/; -var POSITION_MAP = { - before0: "beforeBegin", - before1: "afterBegin", - after0: "afterEnd", - after1: "beforeEnd" -}; - -var PseudoElement = IE7.PseudoElement = Rule.extend({ - constructor: function(selector, position, cssText) { - // initialise object properties - this.position = position; - var content = cssText.match(PseudoElement.CONTENT), match, entity; - if (content) { - content = content[1]; - match = content.split(/\s+/); - for (var i = 0; (entity = match[i]); i++) { - match[i] = ATTR.test(entity) ? {attr: entity.slice(5, -1)} : - (entity.charAt(0) == "'") ? getString(entity) : decode(entity); - } - content = match; - } - this.content = content; - // CSS text needs to be decoded immediately - this.base(selector, decode(cssText)); - }, - - init: function() { - // execute the underlying css query for this class - this.match = cssQuery(this.selector); - for (var i = 0; i < this.match.length; i++) { - var runtimeStyle = this.match[i].runtimeStyle; - if (!runtimeStyle[this.position]) runtimeStyle[this.position] = {cssText:""}; - runtimeStyle[this.position].cssText += ";" + this.cssText; - if (this.content != null) runtimeStyle[this.position].content = this.content; - } - }, - - create: function(target) { - var generated = target.runtimeStyle[this.position]; - if (generated) { - // copy the array of values - var content = [].concat(generated.content || ""); - for (var j = 0; j < content.length; j++) { - if (typeof content[j] == "object") { - content[j] = target.getAttribute(content[j].attr); - } - } - content = content.join(""); - var url = content.match(URL); - var cssText = "overflow:hidden;" + generated.cssText.replace(/'/g, '"'); - if (target.currentStyle.styleFloat != "none") { - //cssText = cssText.replace(/display\s*:\s*block/, "display:inline-block"); - } - var position = POSITION_MAP[this.position + Number(target.canHaveChildren)]; - var id = 'ie7_pseudo' + PseudoElement.count++; - target.insertAdjacentHTML(position, format(PseudoElement.ANON, this.className, id, cssText, url ? "" : content)); - if (url) { - var pseudoElement = document.getElementById(id); - pseudoElement.src = getString(url[1]); - addFilter(pseudoElement, "crop"); - } - target.runtimeStyle[this.position] = null; - } - }, - - recalc: function() { - if (this.content == null) return; - for (var i = 0; i < this.match.length; i++) { - this.create(this.match[i]); - } - }, - - toString: function() { - return "." + this.className + "{display:inline}"; - } -}, { - CONTENT: /content\s*:\s*([^;]*)(;|$)/, - ANON: "%4", - MATCH: /(.*):(before|after).*/, - - count: 0 -}); - -// ========================================================================= -// ie8-html.js -// ========================================================================= - -var UNSUCCESSFUL = /^(submit|reset|button)$/; - -// ----------------------------------------------------------------------- -// -// ----------------------------------------------------------------------- - -// IE bug means that innerText is submitted instead of "value" -IE7.HTML.addRecalc("button,input", function(button) { - if (button.tagName == "BUTTON") { - var match = button.outerHTML.match(/ value="([^"]*)"/i); - button.runtimeStyle.value = (match) ? match[1] : ""; - } - // flag the button/input that was used to submit the form - if (button.type == "submit") { - addEventHandler(button, "onclick", function() { - button.runtimeStyle.clicked = true; - setTimeout("document.all." + button.uniqueID + ".runtimeStyle.clicked=false", 1); - }); - } -}); - -// ----------------------------------------------------------------------- -// -// ----------------------------------------------------------------------- - -// only submit "successful controls -IE7.HTML.addRecalc("form", function(form) { - addEventHandler(form, "onsubmit", function() { - for (var element, i = 0; element = form[i]; i++) { - if (UNSUCCESSFUL.test(element.type) && !element.disabled && !element.runtimeStyle.clicked) { - element.disabled = true; - setTimeout("document.all." + element.uniqueID + ".disabled=false", 1); - } else if (element.tagName == "BUTTON" && element.type == "submit") { - setTimeout("document.all." + element.uniqueID + ".value='" + - element.value + "'", 1); - element.value = element.runtimeStyle.value; - } - } - }); -}); - -// ----------------------------------------------------------------------- -// -// ----------------------------------------------------------------------- - -// get rid of the spurious tooltip produced by the alt attribute on images -IE7.HTML.addRecalc("img", function(img) { - if (img.alt && !img.title) img.title = ""; -}); - -// ========================================================================= -// ie8-layout.js -// ========================================================================= - -IE7.CSS.addRecalc("border-spacing", NUMERIC, function(element) { - if (element.currentStyle.borderCollapse != "collapse") { - element.cellSpacing = getPixelValue(element, element.currentStyle["border-spacing"]); - } -}); -IE7.CSS.addRecalc("box-sizing", "content-box", IE7.Layout.boxSizing); -IE7.CSS.addRecalc("box-sizing", "border-box", IE7.Layout.borderBox); - -// ========================================================================= -// ie8-graphics.js -// ========================================================================= - -IE7.CSS.addFix(/opacity\s*:\s*([\d.]+)/, function(match, value) { - return "zoom:1;filter:Alpha(opacity=" + ((value * 100) || 1) + ")"; -}); - -// fix object[type=image/*] -var IMAGE = /^image/i; -IE7.HTML.addRecalc("object", function(element) { - if (IMAGE.test(element.type)) { - element.body.style.cssText = "margin:0;padding:0;border:none;overflow:hidden"; - return element; - } -}); - -// ----------------------------------------------------------------------- -// initialisation -// ----------------------------------------------------------------------- - -IE7.loaded = true; - -(function() { - try { - // http://javascript.nwbox.com/IEContentLoaded/ - documentElement.doScroll("left"); - } catch (e) { - setTimeout(arguments.callee, 1); - return; - } - // execute the inner text of the IE7 script - try { - eval(script.innerHTML); - } catch (e) { - // ignore errors - } - PNG = new RegExp(rescape(typeof IE7_PNG_SUFFIX == "string" ? IE7_PNG_SUFFIX : "-trans.png") + "$", "i"); - - // frequently used references - body = document.body; - viewport = quirksMode ? body : documentElement; - - // classes - body.className += " ie7_body"; - documentElement.className += " ie7_html"; - - if (quirksMode) ie7Quirks(); - - IE7.CSS.init(); - IE7.HTML.init(); - - IE7.HTML.apply(); - IE7.CSS.apply(); - - IE7.recalc(); -})(); - - -})(); diff --git a/lib/galaxy/webapps/reports/static/scripts/ie7-recalc.js b/lib/galaxy/webapps/reports/static/scripts/ie7-recalc.js deleted file mode 100644 index c9e74506d8c..00000000000 --- a/lib/galaxy/webapps/reports/static/scripts/ie7-recalc.js +++ /dev/null @@ -1,166 +0,0 @@ - -// ========================================================================= -// ie7-recalc.js -// ========================================================================= - -(function() { - /* --------------------------------------------------------------------- - - This allows refreshing of IE7 style rules. If you modify the DOM - you can update IE7 by calling document.recalc(). - - This should be the LAST module included. - - --------------------------------------------------------------------- */ - - if (!IE7.loaded) return; - - // remove all IE7 classes from an element - CLASSES = /\sie7_class\d+/g; - - IE7.CSS.extend({ - // store for elements that have style properties calculated - elements: {}, - handlers: [], - - // clear IE7 classes and styles - reset: function() { - this.removeEventHandlers(); - // reset IE7 classes here - var elements = this.elements; - for (var i in elements) elements[i].runtimeStyle.cssText = ""; - this.elements = {}; - // reset runtimeStyle here - var elements = IE7.Rule.elements; - for (var i in elements) { - with (elements[i]) className = className.replace(CLASSES, ""); - } - IE7.Rule.elements = {}; - }, - - reload: function() { - this.rules = []; - this.getInlineStyles(); - this.screen.load(); - if (this.print) this.print.load(); - this.refresh(); - this.trash(); - }, - - addRecalc: function(propertyName, test, handler, replacement) { - // call the ancestor method to add a wrapped recalc method - this.base(propertyName, test, function(element) { - // execute the original recalc method - handler(element); - // store a reference to this element so we can clear its style later - IE7.CSS.elements[element.uniqueID] = element; - }, replacement); - }, - - recalc: function() { - // clear IE7 styles and classes - this.reset(); - // execute the ancestor method to perform recalculations - this.base(); - }, - - addEventHandler: function(element, type, handler) { - element.attachEvent(type, handler); - // store the handler so it can be detached later - this.handlers.push(arguments); - }, - - removeEventHandlers: function() { - var handler; - while (handler = this.handlers.pop()) { - handler[0].detachEvent(handler[1], handler[2]); - } - }, - - getInlineStyles: function() { - // load inline styles - var styleSheets = document.getElementsByTagName("style"), styleSheet; - for (var i = styleSheets.length - 1; (styleSheet = styleSheets[i]); i--) { - if (!styleSheet.disabled && !styleSheet.ie7) { - var cssText = styleSheet.cssText || styleSheet.innerHTML; - this.styles.push(cssText); - styleSheet.cssText = cssText; - } - } - }, - - trash: function() { - // trash the old style sheets - var styleSheets = document.styleSheets, styleSheet, i; - for (i = 0; i < styleSheets.length; i++) { - styleSheet = styleSheets[i]; - if (!styleSheet.ie7 && !styleSheet.cssText) { - styleSheet.cssText = styleSheet.cssText; - } - } - this.base(); - }, - - getText: function(styleSheet) { - return styleSheet.cssText || this.base(styleSheet); - } - }); - - // remove event handlers (they eat memory) - IE7.CSS.addEventHandler(window, "onunload", function() { - IE7.CSS.removeEventHandlers(); - }); - - // store all elements with an IE7 class assigned - IE7.Rule.elements = {}; - - IE7.Rule.prototype.extend({ - add: function(element) { - // execute the ancestor "add" method - this.base(element); - // store a reference to this element so we can clear its classes later - IE7.Rule.elements[element.uniqueID] = element; - } - }); - - // store created pseudo elements - if (IE7.PseudoElement) { - IE7.PseudoElement.hash = {}; - - IE7.PseudoElement.prototype.extend({ - create: function(target) { - var key = this.selector + ":" + target.uniqueID; - if (!IE7.PseudoElement.hash[key]) { - IE7.PseudoElement.hash[key] = true; - this.base(target); - } - } - }); - } - - IE7.HTML.extend({ - elements: {}, - - addRecalc: function(selector, handler) { - // call the ancestor method to add a wrapped recalc method - this.base(selector, function(element) { - if (!this.elements[element.uniqueID]) { - // execute the original recalc method - handler(element); - // store a reference to this element so that - // it is not "fixed" again - this.elements[element.uniqueID] = element; - } - }); - } - }); - - // allow refreshing of IE7 fixes - document.recalc = function(reload) { - if (IE7.CSS.screen) { - if (reload) IE7.CSS.reload(); - IE7.recalc(); - } - }; - -})(); diff --git a/lib/galaxy/webapps/reports/templates/base_panels.mako b/lib/galaxy/webapps/reports/templates/base_panels.mako deleted file mode 100644 index 69cc3b899bb..00000000000 --- a/lib/galaxy/webapps/reports/templates/base_panels.mako +++ /dev/null @@ -1,55 +0,0 @@ -## This needs to be on the first line, otherwise IE6 goes into quirks mode - - -## Default title -<%def name="title()">Galaxy Reports%def> - -## Default stylesheets -<%def name="stylesheets()"> - -%def> - -## Default javascripts -<%def name="javascripts()"> - -%def> - -## Default late-load javascripts -<%def name="late_javascripts()"> -%def> - -## Masthead -<%def name="masthead()"> - -%def> - -## Document - - - ${self.title()} - - ${self.javascripts()} - ${self.stylesheets()} - - - ## Background displays first - - ## Layer masthead iframe over background - - ${self.masthead()} - - ## Display main report body - - ${self.main_body()} - - ## Allow other body level elements - ${next.body()} - - ## Scripts can be loaded later since they progressively add features to - ## the panels, but do not change layout - ${self.late_javascripts()} - diff --git a/lib/galaxy/webapps/reports/templates/index.mako b/lib/galaxy/webapps/reports/templates/index.mako deleted file mode 100644 index b069b51bcb6..00000000000 --- a/lib/galaxy/webapps/reports/templates/index.mako +++ /dev/null @@ -1,88 +0,0 @@ -<%inherit file="/base_panels.mako"/> -<%def name="main_body()"> - ## Display the available reports - - Galaxy Reports - - Job Information - - - - Number of jobs today - displays the total number of jobs for today - - - - - - - Number of jobs per day for current month - displays days of the current month with the total number of jobs for each day - - - - - - - Number of jobs in error per day for current month - displays days of the current month with the total number of jobs in error for each day - - - - - - - All unfinished jobs - displays jobs that are currently in a "new" state, a "queued" state or a "running" state - - - - - - - Number of jobs per month - displays a list of months with the total number of jobs for each month - - - - - - - Number of jobs in error per month - displays a list of months with the total number of jobs in error for each month - - - - - - - Number of jobs per user - displays users sorted in descending order by the number of jobs they have submitted - - - - - - - Number of jobs per tool - displays tools sorted in alphabetical order by tool id and the number of jobs created by the tool - - - - - - - User Information - - - - Users - displays information about registered users - - - - - - - System Information - - - - Disk space, old histories and datasets - displays history and dataset information including disk space allocation where datasets are stored - - - - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_all_unfinished.mako b/lib/galaxy/webapps/reports/templates/jobs_all_unfinished.mako deleted file mode 100644 index 08103f51fba..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_all_unfinished.mako +++ /dev/null @@ -1,89 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - All Unfinished Jobs - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no unfinished jobs - %else: - %for job in jobs: - <% - state = job[0] - if state == 'new': - rowdef = '' - elif state == 'waiting': - rowdef = '' - elif state == 'queued': - rowdef = '' - elif state == 'running': - rowdef = '' - elif state == 'upload': - rowdef = '' - else: - rowdef = '' - %> - ${rowdef} - State - Job Id - Create Time - Update Time - Session Id - - - ${job[0]} - ${job[1]} - ${job[2]} - ${job[3]} - ${job[4]} - - - Tool - User - - - ${job[5]} - ${job[6]} - - - Remote Host - - - ${job[7]} - - - Command Line - - - ${job[8]} - - - Stderr - - - ${job[9]} - - - Stack Trace - - - ${job[10]} - - - Info - - - ${job[11]} - - - - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_per_domain.mako b/lib/galaxy/webapps/reports/templates/jobs_per_domain.mako deleted file mode 100644 index ffa2155072f..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_per_domain.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs Per Domain - This report does not account for unauthenticated users. - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs - %else: - - Domain - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_per_month_all.mako b/lib/galaxy/webapps/reports/templates/jobs_per_month_all.mako deleted file mode 100644 index fe2776a173a..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_per_month_all.mako +++ /dev/null @@ -1,39 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs Per Month - Click Month to view the number of jobs for each day of that month - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs - %else: - - Month - User Jobs - Monitor Jobs - Total - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[4]} ${job[5]} - ${job[1]} - ${job[2]} - ${job[3]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_per_month_in_error.mako b/lib/galaxy/webapps/reports/templates/jobs_per_month_in_error.mako deleted file mode 100644 index 92b8158330e..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_per_month_in_error.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs In Error Per Month - Click Month to view the number of jobs in error for each day of that month - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs in the error state - %else: - - Month - Jobs In Error - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[2]} ${job[3]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_per_tool.mako b/lib/galaxy/webapps/reports/templates/jobs_per_tool.mako deleted file mode 100644 index 76af8ed8a63..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_per_tool.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs Per Tool - Click Tool Id to view jobs per month for that tool - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs - %else: - - Tool id - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_per_user.mako b/lib/galaxy/webapps/reports/templates/jobs_per_user.mako deleted file mode 100644 index e2e7668579c..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_per_user.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs Per User - Click User to view jobs per month for that user - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs - %else: - - User - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_specified_date_all.mako b/lib/galaxy/webapps/reports/templates/jobs_specified_date_all.mako deleted file mode 100644 index 25ad667c35d..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_specified_date_all.mako +++ /dev/null @@ -1,95 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - All Jobs for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %else: - %for job in jobs: - <% - state = job[0] - if state == 'new': - rowdef = '' - elif state == 'waiting': - rowdef = '' - elif state == 'queued': - rowdef = '' - elif state == 'running': - rowdef = '' - elif state == 'error': - rowdef = '' - elif state == 'deleted': - rowdef = '' - elif state == 'upload': - rowdef = '' - elif state == 'ok': - rowdef = '' - else: - rowdef = '' - %> - ${rowdef} - State - Job Id - Create Time - Update Time - Session Id - - - ${job[0]} - ${job[1]} - ${job[2]} - ${job[3]} - ${job[4]} - - - Tool - User - - - ${job[5]} - ${job[6]} - - - Remote Host - - - ${job[7]} - - - Command Line - - - ${job[8]} - - - Stderr - - - ${job[9]} - - - Stack Trace - - - ${job[10]} - - - Info - - - ${job[11]} - - - - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_specified_date_in_error.mako b/lib/galaxy/webapps/reports/templates/jobs_specified_date_in_error.mako deleted file mode 100644 index e260baeeec6..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_specified_date_in_error.mako +++ /dev/null @@ -1,81 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - All Jobs in Error for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs in the error state for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %else: - %for job in jobs: - <% - state = job[0] - if state == 'error': - rowdef = '' - else: - rowdef = '' - %> - ${rowdef} - State - Job Id - Create Time - Update Time - Session Id - - - ${job[0]} - ${job[1]} - ${job[2]} - ${job[3]} - ${job[4]} - - - Tool - User - - - ${job[5]} - ${job[6]} - - - Remote Host - - - ${job[7]} - - - Command Line - - - ${job[8]} - - - Stderr - - - ${job[9]} - - - Stack Trace - - - ${job[10]} - - - Info - - - ${job[11]} - - - - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_specified_month_all.mako b/lib/galaxy/webapps/reports/templates/jobs_specified_month_all.mako deleted file mode 100644 index ec5b61c127d..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_specified_month_all.mako +++ /dev/null @@ -1,41 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - All Jobs for ${month_label} ${year_label} - Click Total Jobs to see jobs for that day - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for ${month_label} ${year_label} - %else: - - Day - Date - User Jobs - Monitor Jobs - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${month_label} ${job[5]}, ${year_label} - ${job[2]} - ${job[3]} - ${job[4]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_specified_month_in_error.mako b/lib/galaxy/webapps/reports/templates/jobs_specified_month_in_error.mako deleted file mode 100644 index 1bca33cef29..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_specified_month_in_error.mako +++ /dev/null @@ -1,37 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs in Error for ${month_label} ${year_label} - Click Jobs in Error to view jobs in error for that day - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs in the error state for ${month_label} ${year_label} - %else: - - Day - Date - Jobs in Error - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${month_label} ${job[3]}, ${year_label} - ${job[2]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_today_all.mako b/lib/galaxy/webapps/reports/templates/jobs_today_all.mako deleted file mode 100644 index b43fe3a0ec8..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_today_all.mako +++ /dev/null @@ -1,41 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - All Jobs for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - Click Total Jobs to see jobs for today - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %else: - - Day - Date - User Jobs - Monitor Jobs - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[0]} - ${month_label} ${job[5]}, ${year_label} - ${job[2]} - ${job[3]} - ${job[4]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_tool_for_month.mako b/lib/galaxy/webapps/reports/templates/jobs_tool_for_month.mako deleted file mode 100644 index ed759a2920d..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_tool_for_month.mako +++ /dev/null @@ -1,95 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs for tool "${tool_id}" during ${month_label} ${year_label} - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for ${tool_id} during ${month_label} ${year_label} - %else: - %for job in jobs: - <% - state = job[0] - if state == 'new': - rowdef = '' - elif state == 'waiting': - rowdef = '' - elif state == 'queued': - rowdef = '' - elif state == 'running': - rowdef = '' - elif state == 'error': - rowdef = '' - elif state == 'deleted': - rowdef = '' - elif state == 'upload': - rowdef = '' - elif state == 'ok': - rowdef = '' - else: - rowdef = '' - %> - ${rowdef} - State - Job Id - Create Time - Update Time - Session Id - - - ${job[0]} - ${job[1]} - ${job[2]} - ${job[3]} - ${job[4]} - - - Tool - User - - - ${job[5]} - ${job[6]} - - - Remote Host - - - ${job[7]} - - - Command Line - - - ${job[8]} - - - Stderr - - - ${job[9]} - - - Stack Trace - - - ${job[10]} - - - Info - - - ${job[11]} - - - - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_tool_per_month.mako b/lib/galaxy/webapps/reports/templates/jobs_tool_per_month.mako deleted file mode 100644 index bbb74e8cc41..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_tool_per_month.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs per month for tool "${tool_id}" - Click Total Jobs to see the tool's jobs for that month - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for tool "${tool_id}" - %else: - - Month - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[2]} ${job[3]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_user_for_month.mako b/lib/galaxy/webapps/reports/templates/jobs_user_for_month.mako deleted file mode 100644 index 316652439d5..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_user_for_month.mako +++ /dev/null @@ -1,95 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs for user "${email}" during ${month_label} ${year_label} - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for user "${email}" during ${month_label} ${year_label} - %else: - %for job in jobs: - <% - state = job[0] - if state == 'new': - rowdef = '' - elif state == 'waiting': - rowdef = '' - elif state == 'queued': - rowdef = '' - elif state == 'running': - rowdef = '' - elif state == 'error': - rowdef = '' - elif state == 'deleted': - rowdef = '' - elif state == 'upload': - rowdef = '' - elif state == 'ok': - rowdef = '' - else: - rowdef = '' - %> - ${rowdef} - State - Job Id - Create Time - Update Time - Session Id - - - ${job[0]} - ${job[1]} - ${job[2]} - ${job[3]} - ${job[4]} - - - Tool - User - - - ${job[5]} - ${job[6]} - - - Remote Host - - - ${job[7]} - - - Command Line - - - ${job[8]} - - - Stderr - - - ${job[9]} - - - Stack Trace - - - ${job[10]} - - - Info - - - ${job[11]} - - - - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/jobs_user_per_month.mako b/lib/galaxy/webapps/reports/templates/jobs_user_per_month.mako deleted file mode 100644 index 4220462b8bd..00000000000 --- a/lib/galaxy/webapps/reports/templates/jobs_user_per_month.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Jobs per month for user "${email}" - Click Total Jobs to see the user's jobs for that month - %if msg: - - ${msg} - - %endif - - %if len( jobs ) == 0: - There are no jobs for user "${email}" - %else: - - Month - Total Jobs - - <% ctr = 0 %> - %for job in jobs: - %if ctr % 2 == 1: - - %else: - - %endif - ${job[2]} ${job[3]} - ${job[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/masthead.mako b/lib/galaxy/webapps/reports/templates/masthead.mako deleted file mode 100644 index f4a335f3cbe..00000000000 --- a/lib/galaxy/webapps/reports/templates/masthead.mako +++ /dev/null @@ -1,29 +0,0 @@ - - - - Galaxy - - - - - - - - - - - - Galaxy${brand} - - Info: report bugs - | wiki - | screencasts - | blog - - Galaxy Reports Home - - - - - - diff --git a/lib/galaxy/webapps/reports/templates/registered_users.mako b/lib/galaxy/webapps/reports/templates/registered_users.mako deleted file mode 100644 index 1f4d73783ad..00000000000 --- a/lib/galaxy/webapps/reports/templates/registered_users.mako +++ /dev/null @@ -1,21 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - Registered Users - Click Number of Registered Users to see the number of user registrations per month - %if msg: - - ${msg} - - %endif - - %if num_users == 0: - There are no registered users - %else: - Number of Registered Users - ${num_users} - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/registered_users_per_month.mako b/lib/galaxy/webapps/reports/templates/registered_users_per_month.mako deleted file mode 100644 index e95a2bfda9b..00000000000 --- a/lib/galaxy/webapps/reports/templates/registered_users_per_month.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - User Registrations Per Month - Click Month to view the number of user registrations for each day of that month - %if msg: - - ${msg} - - %endif - - %if len( users ) == 0: - There are no registered users - %else: - - Month - Number of Registrations - - <% ctr = 0 %> - %for user in users: - %if ctr % 2 == 1: - - %else: - - %endif - ${user[2]} ${user[3]} - ${user[1]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/registered_users_specified_date.mako b/lib/galaxy/webapps/reports/templates/registered_users_specified_date.mako deleted file mode 100644 index f02952076ea..00000000000 --- a/lib/galaxy/webapps/reports/templates/registered_users_specified_date.mako +++ /dev/null @@ -1,32 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - User Registrations for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %if msg: - - ${msg} - - %endif - - %if len( users ) == 0: - There are no user registrations for ${day_label}, ${month_label} ${day_of_month}, ${year_label} - %else: - - Email - - <% ctr = 0 %> - %for user in users: - %if ctr % 2 == 1: - - %else: - - %endif - ${user} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/registered_users_specified_month.mako b/lib/galaxy/webapps/reports/templates/registered_users_specified_month.mako deleted file mode 100644 index 71a16d4a1fe..00000000000 --- a/lib/galaxy/webapps/reports/templates/registered_users_specified_month.mako +++ /dev/null @@ -1,35 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - - User Registrations for ${month_label} ${year_label} - Click Day to see user registrations for that day - %if msg: - - ${msg} - - %endif - - %if len( users ) == 0: - There are no user registrations for ${month_label} ${year_label} - %else: - - Day - New Registrations - - <% ctr = 0 %> - %for user in users: - %if ctr % 2 == 1: - - %else: - - %endif - ${user[3]}, ${month_label} ${user[1]}, ${year_label} - ${user[2]} - - <% ctr += 1 %> - %endfor - %endif - - -%def> diff --git a/lib/galaxy/webapps/reports/templates/system.mako b/lib/galaxy/webapps/reports/templates/system.mako deleted file mode 100644 index 57fc5d4f960..00000000000 --- a/lib/galaxy/webapps/reports/templates/system.mako +++ /dev/null @@ -1,82 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - Old Histories and Datasets - %if msg: - - ${msg} - - %endif - - - - - - Number of Histories - that are not associate with a user and were last updated more than - - days ago. - - - Number of Histories - that were deleted more than - - days ago but have not yet been purged. - - - Number of Datasets - that were deleted more than - - days ago but have not yet been purged. - - - - - - - Current Disk Space Where Datasets are Stored - - Disk Usage for ${file_path} - - File System - Disk Size - Used - Available - Percent Used - - - ${disk_usage[0]} - ${disk_usage[1]} - ${disk_usage[2]} - ${disk_usage[3]} - ${disk_usage[4]} - - %if len( datasets ) == 0: - There are no datasets larger than ${file_size_str} - %else: - ${len( datasets )} largest datasets over ${file_size_str} - - File - Last Updated - History ID - Deleted - Size on Disk - - <% ctr = 0 %> - %for dataset in datasets: - %if ctr % 2 == 1: - - %else: - - %endif - dataset_${dataset[0]}.dat - ${dataset[1]} - ${dataset[2]} - ${dataset[3]} - ${dataset[4]} - - <% ctr += 1 %> - %endfor - %endif - -%def> diff --git a/lib/galaxy/webapps/reports/templates/users.mako b/lib/galaxy/webapps/reports/templates/users.mako deleted file mode 100644 index eed2d58d1be..00000000000 --- a/lib/galaxy/webapps/reports/templates/users.mako +++ /dev/null @@ -1,29 +0,0 @@ -<%inherit file="/base_panels.mako"/> - -<%def name="main_body()"> - Registered Users - %if msg: - - ${msg} - - %endif - - - - - Registered Users - displays the number of registered users - - - - - - - - - - Date of Last Login - displays users sorted by date of last login - - - - -%def> diff --git a/reports_wsgi.ini.sample b/reports_wsgi.ini.sample index 1eceb9c6819..9107ef5ae5d 100644 --- a/reports_wsgi.ini.sample +++ b/reports_wsgi.ini.sample @@ -19,16 +19,13 @@ log_level = DEBUG # Database connection #database_file = database/universe.sqlite # You may use a SQLAlchemy connection string to specify an external database instead -database_connection = postgres:///galaxy_test?host=/var/run/postgresql +# database_connection = postgres:///galaxy_test?user=postgres&password=postgres # Where dataset files are saved file_path = database/files # Temporary storage for additional datasets, this should be shared through the cluster new_file_path = database/tmp -# Where templates are stored -template_path = lib/galaxy/webapps/reports/templates - # Session support (beaker) use_beaker_session = True session_type = memory @@ -36,19 +33,13 @@ session_data_dir = %(here)s/database/beaker_sessions session_key = galaxysessions session_secret = changethisinproduction -# Galaxy session security -id_secret = changethisinproductiontoo - # Configuration for debugging middleware -debug = true +# debug = true use_lint = false # NEVER enable this on a public site (even test or QA) # use_interactive = true -# Force everyone to log in (disable anonymous access) -require_login = False - # path to sendmail sendmail_path = /usr/sbin/sendmail @@ -61,15 +52,19 @@ mailing_join_addr = galaxy-user-join@bx.psu.edu # Profiling middleware (cProfile based) ## use_profile = True +# Mail +# smtp_server = yourserver@yourfacility.edu +# error_email_to = your_bugs@bx.psu.edu + # Use the new iframe / javascript based layout use_new_layout = true # Serving static files (needed if running standalone) static_enabled = True static_cache_time = 360 -static_dir = lib/galaxy/webapps/reports/static -static_images_dir = lib/galaxy/webapps/reports/static/images -static_favicon_dir = lib/galaxy/webapps/reports/static/favicon.ico -static_scripts_dir = lib/galaxy/webapps/reports/static/scripts -static_style_dir = lib/galaxy/webapps/reports/static/january_2008_style/blue +static_dir = %(here)s/static/ +static_images_dir = %(here)s/static/images +static_favicon_dir = %(here)s/static/favicon.ico +static_scripts_dir = %(here)s/static/scripts/ +static_style_dir = %(here)s/static/june_2007_style/blue diff --git a/templates/webapps/reports/base_panels.mako b/templates/webapps/reports/base_panels.mako new file mode 100644 index 00000000000..278ad9b50c9 --- /dev/null +++ b/templates/webapps/reports/base_panels.mako @@ -0,0 +1,38 @@ +<%inherit file="/base_panels.mako"/> + +## Default title +<%def name="title()">Galaxy Reports%def> + +## Masthead +<%def name="masthead()"> + ## Tab area, fills entire width + + + + <%def name="tab( id, display, href, target='_parent', visible=True, extra_class='' )"> + <% + cls = "tab" + if extra_class: + cls += " " + extra_class + if self.active_view == id: + cls += " active" + style = "" + if not visible: + style = "display: none;" + %> + ${display} + %def> + + + + ## Logo, layered over tabs to be clickable + + + + Galaxy Reports + %if app.config.brand: + / ${app.config.brand} + %endif + + +%def> diff --git a/templates/webapps/reports/grid.mako b/templates/webapps/reports/grid.mako new file mode 100644 index 00000000000..6a41b688c5e --- /dev/null +++ b/templates/webapps/reports/grid.mako @@ -0,0 +1 @@ +<%inherit file="/grid_base.mako"/> diff --git a/templates/webapps/reports/index.mako b/templates/webapps/reports/index.mako new file mode 100644 index 00000000000..651bb585888 --- /dev/null +++ b/templates/webapps/reports/index.mako @@ -0,0 +1,115 @@ +<%inherit file="/webapps/reports/base_panels.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +<%def name="init()"> + <% + self.has_left_panel=True + self.has_right_panel=False + self.active_view="reports" + %> +%def> + +<%def name="stylesheets()"> + ${parent.stylesheets()} + ## TODO: Clean up these styles and move into panel_layout.css (they are + ## used here and in the editor). + +%def> + +<%def name="left_panel()"> + + Reports + + + + + + + Jobs + + + + Number of jobs today + Number of jobs per day for current month + Number of jobs in error per day for current month + All unfinished jobs + Number of jobs per month + Number of jobs in error per month + Number of jobs per user + Number of jobs per tool + + + + + + Users + + + + Registered users + Date of last login + + + + + + System + + + + Disk space, old histories and datasets + + + + + +%def> + +<%def name="center_panel()"> + <% center_url = h.url_for( controller='jobs', action='today_all' ) %> + +%def> diff --git a/templates/webapps/reports/job_info.mako b/templates/webapps/reports/job_info.mako new file mode 100644 index 00000000000..b3525df1f69 --- /dev/null +++ b/templates/webapps/reports/job_info.mako @@ -0,0 +1,75 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, 'done' )} +%endif + + + + Job Information + + + State + Job Id + Create Time + Update Time + Session Id + + + ${job_info.state} + ## TODO for some reason, job_info.id is not the job.id + ${job_id} + ${job_info.create_time} + ${job_info.update_time} + ${job_info.session_id} + + + Tool + User + + + ${job_info.tool_id} + + %if job_info.email: + ${job_info.email} + %else: + anonymous + %endif + + + + Remote Host + + + ${job_info.remote_host} + + + Command Line + + + ${job_info.command_line} + + + Stderr + + + ${job_info.stderr} + + + Stack Trace + + + ${job_info.traceback} + + + Info + + + ${job_info.info} + + + + + + diff --git a/templates/webapps/reports/jobs_per_domain.mako b/templates/webapps/reports/jobs_per_domain.mako new file mode 100644 index 00000000000..97057a22c4e --- /dev/null +++ b/templates/webapps/reports/jobs_per_domain.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs Per Domain + This report does not account for unauthenticated users. + + %if len( jobs ) == 0: + There are no jobs + %else: + + Domain + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[0]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_per_month_all.mako b/templates/webapps/reports/jobs_per_month_all.mako new file mode 100644 index 00000000000..c7a7e3d4772 --- /dev/null +++ b/templates/webapps/reports/jobs_per_month_all.mako @@ -0,0 +1,39 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs Per Month + Click Month to view the number of jobs for each day of that month + + %if len( jobs ) == 0: + There are no jobs + %else: + + Month + User Jobs + Monitor Jobs + Total + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[4]} ${job[5]} + ${job[1]} + ${job[2]} + ${job[3]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_per_month_in_error.mako b/templates/webapps/reports/jobs_per_month_in_error.mako new file mode 100644 index 00000000000..bc4da5a4830 --- /dev/null +++ b/templates/webapps/reports/jobs_per_month_in_error.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs In Error Per Month + Click Month to view the number of jobs in error for each day of that month + + %if len( jobs ) == 0: + There are no jobs in the error state + %else: + + Month + Jobs In Error + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[2]} ${job[3]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_per_tool.mako b/templates/webapps/reports/jobs_per_tool.mako new file mode 100644 index 00000000000..264e1c29d5a --- /dev/null +++ b/templates/webapps/reports/jobs_per_tool.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs Per Tool + Click Tool Id to view jobs per month for that tool + + %if len( jobs ) == 0: + There are no jobs + %else: + + Tool id + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[0]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_per_user.mako b/templates/webapps/reports/jobs_per_user.mako new file mode 100644 index 00000000000..d396b698c90 --- /dev/null +++ b/templates/webapps/reports/jobs_per_user.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs Per User + Click User to view jobs per month for that user + + %if len( jobs ) == 0: + There are no jobs + %else: + + User + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[0]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_specified_month_all.mako b/templates/webapps/reports/jobs_specified_month_all.mako new file mode 100644 index 00000000000..227e4072c7c --- /dev/null +++ b/templates/webapps/reports/jobs_specified_month_all.mako @@ -0,0 +1,41 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + All Jobs for ${month_label} ${year_label} + Click Total Jobs to see jobs for that day + + %if len( jobs ) == 0: + There are no jobs for ${month_label} ${year_label} + %else: + + Day + Date + User Jobs + Monitor Jobs + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[0]} + ${month_label} ${job[5]}, ${year_label} + ${job[2]} + ${job[3]} + ${job[4]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_specified_month_in_error.mako b/templates/webapps/reports/jobs_specified_month_in_error.mako new file mode 100644 index 00000000000..c2a5c58b78b --- /dev/null +++ b/templates/webapps/reports/jobs_specified_month_in_error.mako @@ -0,0 +1,37 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs in Error for ${month_label} ${year_label} + Click Jobs in Error to view jobs in error for that day + + %if len( jobs ) == 0: + There are no jobs in the error state for ${month_label} ${year_label} + %else: + + Day + Date + Jobs in Error + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[0]} + ${month_label} ${job[3]}, ${year_label} + ${job[2]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_tool_per_month.mako b/templates/webapps/reports/jobs_tool_per_month.mako new file mode 100644 index 00000000000..eacdc11e2fb --- /dev/null +++ b/templates/webapps/reports/jobs_tool_per_month.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs per month for tool "${tool_id}" + Click Total Jobs to see the tool's jobs for that month + + %if len( jobs ) == 0: + There are no jobs for tool "${tool_id}" + %else: + + Month + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[2]} ${job[3]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/jobs_user_per_month.mako b/templates/webapps/reports/jobs_user_per_month.mako new file mode 100644 index 00000000000..cad4016f966 --- /dev/null +++ b/templates/webapps/reports/jobs_user_per_month.mako @@ -0,0 +1,37 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +<% from galaxy import util %> + +%if message: + ${render_msg( message, status )} +%endif + + + + Jobs per month for user "${util.restore_text( email )}" + Click Total Jobs to see the user's jobs for that month + + %if len( jobs ) == 0: + There are no jobs for user "${email}" + %else: + + Month + Total Jobs + + <% ctr = 0 %> + %for job in jobs: + %if ctr % 2 == 1: + + %else: + + %endif + ${job[2]} ${job[3]} + ${job[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/registered_users.mako b/templates/webapps/reports/registered_users.mako new file mode 100644 index 00000000000..8ead6e1982b --- /dev/null +++ b/templates/webapps/reports/registered_users.mako @@ -0,0 +1,21 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + + + + Registered Users + Click Number of Registered Users to see the number of user registrations per month + + %if num_users == 0: + There are no registered users + %else: + Number of Registered Users + ${num_users} + %endif + + + diff --git a/templates/webapps/reports/registered_users_per_month.mako b/templates/webapps/reports/registered_users_per_month.mako new file mode 100644 index 00000000000..53776078aca --- /dev/null +++ b/templates/webapps/reports/registered_users_per_month.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, 'done' )} +%endif + + + + User Registrations Per Month + Click Month to view the number of user registrations for each day of that month + + %if len( users ) == 0: + There are no registered users + %else: + + Month + Number of Registrations + + <% ctr = 0 %> + %for user in users: + %if ctr % 2 == 1: + + %else: + + %endif + ${user[2]} ${user[3]} + ${user[1]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/registered_users_specified_date.mako b/templates/webapps/reports/registered_users_specified_date.mako new file mode 100644 index 00000000000..6fcc85bd4ff --- /dev/null +++ b/templates/webapps/reports/registered_users_specified_date.mako @@ -0,0 +1,32 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, 'done' )} +%endif + + + + User Registrations for ${day_label}, ${month_label} ${day_of_month}, ${year_label} + + %if len( users ) == 0: + There are no user registrations for ${day_label}, ${month_label} ${day_of_month}, ${year_label} + %else: + + Email + + <% ctr = 0 %> + %for user in users: + %if ctr % 2 == 1: + + %else: + + %endif + ${user} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/registered_users_specified_month.mako b/templates/webapps/reports/registered_users_specified_month.mako new file mode 100644 index 00000000000..183226cf7e6 --- /dev/null +++ b/templates/webapps/reports/registered_users_specified_month.mako @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, 'done' )} +%endif + + + + User Registrations for ${month_label} ${year_label} + Click Day to see user registrations for that day + + %if len( users ) == 0: + There are no user registrations for ${month_label} ${year_label} + %else: + + Day + New Registrations + + <% ctr = 0 %> + %for user in users: + %if ctr % 2 == 1: + + %else: + + %endif + ${user[3]}, ${month_label} ${user[1]}, ${year_label} + ${user[2]} + + <% ctr += 1 %> + %endfor + %endif + + + diff --git a/templates/webapps/reports/system.mako b/templates/webapps/reports/system.mako new file mode 100644 index 00000000000..afee1a245cf --- /dev/null +++ b/templates/webapps/reports/system.mako @@ -0,0 +1,82 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, 'done' )} +%endif + + + Old Histories and Datasets + + + + + + Number of Histories + that are not associate with a user and were last updated more than + + days ago. + + + Number of Histories + that were deleted more than + + days ago but have not yet been purged. + + + Number of Datasets + that were deleted more than + + days ago but have not yet been purged. + + + + + + + Current Disk Space Where Datasets are Stored + + Disk Usage for ${file_path} + + File System + Disk Size + Used + Available + Percent Used + + + ${disk_usage[0]} + ${disk_usage[1]} + ${disk_usage[2]} + ${disk_usage[3]} + ${disk_usage[4]} + + %if len( datasets ) == 0: + There are no datasets larger than ${file_size_str} + %else: + ${len( datasets )} largest datasets over ${file_size_str} + + File + Last Updated + History ID + Deleted + Size on Disk + + <% ctr = 0 %> + %for dataset in datasets: + %if ctr % 2 == 1: + + %else: + + %endif + dataset_${dataset[0]}.dat + ${dataset[1]} + ${dataset[2]} + ${dataset[3]} + ${dataset[4]} + + <% ctr += 1 %> + %endfor + %endif + + diff --git a/lib/galaxy/webapps/reports/templates/users_last_access_date.mako b/templates/webapps/reports/users_last_access_date.mako similarity index 86% rename from lib/galaxy/webapps/reports/templates/users_last_access_date.mako rename to templates/webapps/reports/users_last_access_date.mako index 12a4c642bda..6873ff4a8e3 100644 --- a/lib/galaxy/webapps/reports/templates/users_last_access_date.mako +++ b/templates/webapps/reports/users_last_access_date.mako @@ -1,13 +1,13 @@ -<%inherit file="/base_panels.mako"/> +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> -<%def name="main_body()"> +%if message: + ${render_msg( message, status )} +%endif + + Date of Last Galaxy Login Listed in descending order by access date ( oldest date first ) - %if msg: - - ${msg} - - %endif @@ -48,4 +48,4 @@ All users have logged in to Galaxy within the past ${not_logged_in_for_days} days %endif -%def> +
${job[9]}
${job[10]}
- Number of Histories - that are not associate with a user and were last updated more than - - days ago. -
- Number of Histories - that were deleted more than - - days ago but have not yet been purged. -
- Number of Datasets - that were deleted more than - - days ago but have not yet been purged. -
${job_info.stderr}
${job_info.traceback}
+ Number of Histories + that are not associate with a user and were last updated more than + + days ago. +
+ Number of Histories + that were deleted more than + + days ago but have not yet been purged. +
+ Number of Datasets + that were deleted more than + + days ago but have not yet been purged. +