From 7aa0f0f08b64382be87bd5d06ed831f8d0477028 Mon Sep 17 00:00:00 2001 From: steve wirts Date: Thu, 26 Mar 2015 16:15:02 -0400 Subject: [PATCH] added hyperlinks --- Gruntfile.js | 31 +- README.md | 40 + demo.html | 23 +- fin-hypergrid.dev.html | 31841 ++++++++++++++++ fin-hypergrid.min.html | 31578 +-------------- index.html | 1 + .../fin-hypergrid-behavior-default.css | 7 + .../behaviors/fin-hypergrid-behavior-gol.css | 7 + .../fin-hypergrid-behavior-in-memory.css | 7 + .../behaviors/fin-hypergrid-behavior-json.css | 7 + .../behaviors/fin-hypergrid-behavior-q.css | 7 + .../fin-hypergrid-behavior-qtree.css | 7 + .../fin-hypergrid-cell-editor-base.css | 7 + .../fin-hypergrid-cell-editor-choice.css | 7 + .../fin-hypergrid-cell-editor-color.css | 7 + .../fin-hypergrid-cell-editor-date.css | 7 + .../fin-hypergrid-cell-editor-simple.css | 7 + .../fin-hypergrid-cell-editor-slider.css | 7 + .../fin-hypergrid-cell-editor-spinner.css | 7 + .../fin-hypergrid-cell-editor-textfield.css | 7 + polymer/css/data.css | 7 + .../features/fin-hypergrid-feature-base.css | 7 + .../fin-hypergrid-feature-cell-click.css | 7 + .../fin-hypergrid-feature-cell-editing.css | 7 + .../fin-hypergrid-feature-cell-selection.css | 7 + .../fin-hypergrid-feature-column-moving.css | 7 + .../fin-hypergrid-feature-column-resizing.css | 7 + .../fin-hypergrid-feature-column-sorting.css | 7 + .../fin-hypergrid-feature-on-hover.css | 7 + .../fin-hypergrid-feature-overlay.css | 7 + .../fin-hypergrid-feature-row-resizing.css | 7 + ...hypergrid-feature-thumbwheel-scrolling.css | 7 + polymer/css/fin-hypergrid-cell-provider.css | 7 + polymer/css/fin-hypergrid-excel.css | 7 + polymer/css/fin-hypergrid-renderer.css | 7 + polymer/css/fin-hypergrid-selection-model.css | 7 + polymer/css/fin-hypergrid.css | 7 + .../fin-hypergrid-behavior-default.html | 1 + .../fin-hypergrid-feature-cell-click.html | 10 + .../fin-hypergrid-behavior-default.js | 6 +- .../fin-hypergrid-feature-cell-click.js | 14 + .../fin-hypergrid-feature-on-hover.js | 18 +- polymer/js/fin-hypergrid-cell-provider.js | 21 +- polymer/js/fin-hypergrid.js | 34 +- .../fin-hypergrid-feature-cell-click.js | 16 + test/index.html | 1 + 46 files changed, 32243 insertions(+), 31609 deletions(-) create mode 100644 fin-hypergrid.dev.html create mode 100644 polymer/css/features/fin-hypergrid-feature-cell-click.css create mode 100644 polymer/html/features/fin-hypergrid-feature-cell-click.html create mode 100644 polymer/js/features/fin-hypergrid-feature-cell-click.js create mode 100644 test/features/fin-hypergrid-feature-cell-click.js diff --git a/Gruntfile.js b/Gruntfile.js index 511e08183..f4d8f4e11 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -36,15 +36,15 @@ module.exports = function(grunt) { watch: { polymerjs: { files: files.polymerjs, - tasks: ['jshint', 'polymer-component-sync', 'jsbeautifier', 'wct-test', 'vulcanize:default'], + tasks: ['jshint', 'polymer-component-sync', 'jsbeautifier', 'wct-test', 'vulcanize-both'], }, polymercss: { files: files.polymercss, - tasks: ['csslint:default', 'cssbeautifier', 'vulcanize:default'], + tasks: ['csslint:default', 'cssbeautifier', 'vulcanize-both'], }, polymerhtml: { files: files.polymerhtml, - tasks: ['htmllint', 'prettify', 'vulcanize:default'], + tasks: ['htmllint', 'prettify', 'vulcanize-both'], }, livereloadflag: { files: ['abc.html'], @@ -58,7 +58,17 @@ module.exports = function(grunt) { }, }, vulcanize: { - default: { + min: { + options: { + inline: true, + strip: true, + abspath: '../../' + }, + files: { + //see below as this key value pair is set programmatically + } + }, + dev: { options: { inline: true, strip: false, @@ -181,18 +191,18 @@ module.exports = function(grunt) { } }, - }; //we need to dynamicaly set the name of this property - myConfig.vulcanize.default.files[elementName + '.min.html'] = myConfig['polymer-component-sync'].default.html + delimeter + elementName + '.html'; + myConfig.vulcanize.min.files[elementName + '.min.html'] = myConfig['polymer-component-sync'].default.html + delimeter + elementName + '.html'; + myConfig.vulcanize.dev.files[elementName + '.dev.html'] = myConfig['polymer-component-sync'].default.html + delimeter + elementName + '.html'; grunt.initConfig(myConfig); grunt.loadNpmTasks('web-component-tester'); grunt.registerTask('test', ['build', 'wct-test']); + grunt.registerTask('vulcanize-both', ['vulcanize:min', 'vulcanize:dev']); grunt.registerTask('default', ['build']); - grunt.registerTask('build', [ 'polymer-component-sync', 'jshint', @@ -202,9 +212,8 @@ module.exports = function(grunt) { 'htmllint', 'prettify', 'wct-test', - 'vulcanize:default' + 'vulcanize-both' ]); - grunt.registerTask('serve', function() { return grunt.task.run([ 'express', @@ -213,8 +222,6 @@ module.exports = function(grunt) { 'watch' ]); }); - - //these functions need to be moved into a yeoman subgenerator function createIndexHtml(files) { var strVar='\n'; @@ -421,7 +428,6 @@ module.exports = function(grunt) { console.log('creating test/index.html'); grunt.file.write('test/index.html', testhtml); }); - grunt.registerTask('polymer','create a new polymer component', function() { var elName = this.args[0]; var shortName = elName.split(delimeter).reverse()[0]; @@ -431,5 +437,4 @@ module.exports = function(grunt) { grunt.task.run('polymer-component-sync'); console.log('created boilerplate ' + jsDir + delimeter + elName + '.js file and accompanying pre/post/css files'); }); - }; diff --git a/README.md b/README.md index 377dea8e4..ae10b01d0 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,46 @@ Hypergrid has a column picker that allows you to drag and drop columns for confi press alt/option to open the column picker, you can press alt/option or esc to close it screenshot +Cells as Links +====================== +Hypergrid supports clickable link cells, to achieve this you need to... + +1. register a listener to the table for 'fin-cell-click' +``` +jsonGrid.addFinEventListener('fin-cell-click', function(e){ + var cell = e.detail.cell; + if (cell.x !== 0) { + return; + } + alert('fin-cell-click at (' + cell.x + ', ' + cell.y + ')'); +}); +``` +2. override the getCursorAt method on behavior to be a function that returns the string of the name of the cursor for the column with the links +``` +jsonModel.getCursorAt = function(x,y) { + if (x === 0) { + return 'pointer' + } else { + return null; + } +}; +``` +3. override the cell-provider to return the linkRenderer for the desired link columns +``` +cellProvider.getCell = function(config) { + var renderer = cellProvider.cellCache.simpleCellRenderer; + config.halign = 'left'; + var x = config.x; + if (x === 0) { + renderer = cellProvider.cellCache.linkCellRenderer; + } else if (x === 2) { + ... + ... + ... +``` + +see the 'Last Name' column of the JSON tab in the main example; + Hypergrid Excel Integration ====================== diff --git a/demo.html b/demo.html index ffa1119fa..b8c7ba33a 100644 --- a/demo.html +++ b/demo.html @@ -472,7 +472,9 @@

fin-hypergrid-behavior-gol

This element is another custom Polymer web c var renderer = cellProvider.cellCache.simpleCellRenderer; config.halign = 'left'; var x = config.x; - if (x === 2) { + if (x === 0) { + renderer = cellProvider.cellCache.linkCellRenderer; + } else if (x === 2) { config.halign = 'center'; } else if (x === 3) { config.halign = 'center'; @@ -512,11 +514,26 @@

fin-hypergrid-behavior-gol

This element is another custom Polymer web c return cellEditor; }; + jsonModel.getCursorAt = function(x,y) { + if (x === 0) { + return 'pointer' + } else { + return null; + } + }; + + jsonGrid.addFinEventListener('fin-cell-click', function(e){ + var cell = e.detail.cell; + if (cell.x !== 0) { + return; + } + alert('fin-cell-click at (' + cell.x + ', ' + cell.y + ')'); + }); jsonGrid.addFinEventListener('fin-scroll-x', function(e){ - console.log('x', e); + console.log('fin-scroll-x', e); }); jsonGrid.addFinEventListener('fin-scroll-y', function(e){ - console.log('y', e); + console.log('fin-scroll-y', e); }); }); })(); diff --git a/fin-hypergrid.dev.html b/fin-hypergrid.dev.html new file mode 100644 index 000000000..b56dc5b2f --- /dev/null +++ b/fin-hypergrid.dev.html @@ -0,0 +1,31841 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fin-hypergrid.min.html b/fin-hypergrid.min.html index 22b27f915..6cde0d0dc 100644 --- a/fin-hypergrid.min.html +++ b/fin-hypergrid.min.html @@ -14,31572 +14,18 @@ @group OpenFin hypergrid @element fin-hypergrid @homepage http://github.com/openfin/fin-hypergrid ---> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/index.html b/index.html index fc7bdff3f..1fa0f0816 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@ './polymer/html/cell-editors/fin-hypergrid-cell-editor-textfield.html', './polymer/html/data.html', './polymer/html/features/fin-hypergrid-feature-base.html', + './polymer/html/features/fin-hypergrid-feature-cell-click.html', './polymer/html/features/fin-hypergrid-feature-cell-editing.html', './polymer/html/features/fin-hypergrid-feature-cell-selection.html', './polymer/html/features/fin-hypergrid-feature-column-moving.html', diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-default.css b/polymer/css/behaviors/fin-hypergrid-behavior-default.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-default.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-default.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-gol.css b/polymer/css/behaviors/fin-hypergrid-behavior-gol.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-gol.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-gol.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-in-memory.css b/polymer/css/behaviors/fin-hypergrid-behavior-in-memory.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-in-memory.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-in-memory.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-json.css b/polymer/css/behaviors/fin-hypergrid-behavior-json.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-json.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-json.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-q.css b/polymer/css/behaviors/fin-hypergrid-behavior-q.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-q.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-q.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/behaviors/fin-hypergrid-behavior-qtree.css b/polymer/css/behaviors/fin-hypergrid-behavior-qtree.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/behaviors/fin-hypergrid-behavior-qtree.css +++ b/polymer/css/behaviors/fin-hypergrid-behavior-qtree.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-base.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-base.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-base.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-base.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-choice.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-choice.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-choice.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-choice.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-color.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-color.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-color.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-color.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-date.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-date.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-date.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-date.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-simple.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-simple.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-simple.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-simple.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-slider.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-slider.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-slider.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-slider.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-spinner.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-spinner.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-spinner.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-spinner.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/cell-editors/fin-hypergrid-cell-editor-textfield.css b/polymer/css/cell-editors/fin-hypergrid-cell-editor-textfield.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/cell-editors/fin-hypergrid-cell-editor-textfield.css +++ b/polymer/css/cell-editors/fin-hypergrid-cell-editor-textfield.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/data.css b/polymer/css/data.css index c60a194be..7a4a76847 100644 --- a/polymer/css/data.css +++ b/polymer/css/data.css @@ -26,6 +26,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-base.css b/polymer/css/features/fin-hypergrid-feature-base.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-base.css +++ b/polymer/css/features/fin-hypergrid-feature-base.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-cell-click.css b/polymer/css/features/fin-hypergrid-feature-cell-click.css new file mode 100644 index 000000000..286d746f6 --- /dev/null +++ b/polymer/css/features/fin-hypergrid-feature-cell-click.css @@ -0,0 +1,7 @@ +:host { + display: block; + position: relative; +} + + + diff --git a/polymer/css/features/fin-hypergrid-feature-cell-editing.css b/polymer/css/features/fin-hypergrid-feature-cell-editing.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-cell-editing.css +++ b/polymer/css/features/fin-hypergrid-feature-cell-editing.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-cell-selection.css b/polymer/css/features/fin-hypergrid-feature-cell-selection.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-cell-selection.css +++ b/polymer/css/features/fin-hypergrid-feature-cell-selection.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-column-moving.css b/polymer/css/features/fin-hypergrid-feature-column-moving.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-column-moving.css +++ b/polymer/css/features/fin-hypergrid-feature-column-moving.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-column-resizing.css b/polymer/css/features/fin-hypergrid-feature-column-resizing.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-column-resizing.css +++ b/polymer/css/features/fin-hypergrid-feature-column-resizing.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-column-sorting.css b/polymer/css/features/fin-hypergrid-feature-column-sorting.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-column-sorting.css +++ b/polymer/css/features/fin-hypergrid-feature-column-sorting.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-on-hover.css b/polymer/css/features/fin-hypergrid-feature-on-hover.css index fc1e656a8..7c84fde33 100644 --- a/polymer/css/features/fin-hypergrid-feature-on-hover.css +++ b/polymer/css/features/fin-hypergrid-feature-on-hover.css @@ -6,3 +6,10 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-overlay.css b/polymer/css/features/fin-hypergrid-feature-overlay.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-overlay.css +++ b/polymer/css/features/fin-hypergrid-feature-overlay.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-row-resizing.css b/polymer/css/features/fin-hypergrid-feature-row-resizing.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-row-resizing.css +++ b/polymer/css/features/fin-hypergrid-feature-row-resizing.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/features/fin-hypergrid-feature-thumbwheel-scrolling.css b/polymer/css/features/fin-hypergrid-feature-thumbwheel-scrolling.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/features/fin-hypergrid-feature-thumbwheel-scrolling.css +++ b/polymer/css/features/fin-hypergrid-feature-thumbwheel-scrolling.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/fin-hypergrid-cell-provider.css b/polymer/css/fin-hypergrid-cell-provider.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/fin-hypergrid-cell-provider.css +++ b/polymer/css/fin-hypergrid-cell-provider.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/fin-hypergrid-excel.css b/polymer/css/fin-hypergrid-excel.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/fin-hypergrid-excel.css +++ b/polymer/css/fin-hypergrid-excel.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/fin-hypergrid-renderer.css b/polymer/css/fin-hypergrid-renderer.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/fin-hypergrid-renderer.css +++ b/polymer/css/fin-hypergrid-renderer.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/fin-hypergrid-selection-model.css b/polymer/css/fin-hypergrid-selection-model.css index ebbe5b7a4..394e076fb 100644 --- a/polymer/css/fin-hypergrid-selection-model.css +++ b/polymer/css/fin-hypergrid-selection-model.css @@ -76,6 +76,13 @@ + + + + + + + diff --git a/polymer/css/fin-hypergrid.css b/polymer/css/fin-hypergrid.css index 7d154e198..4d29ae8aa 100644 --- a/polymer/css/fin-hypergrid.css +++ b/polymer/css/fin-hypergrid.css @@ -142,6 +142,13 @@ fin-vampire-bar { + + + + + + + diff --git a/polymer/html/behaviors/fin-hypergrid-behavior-default.html b/polymer/html/behaviors/fin-hypergrid-behavior-default.html index 949297ee6..3615b65a9 100644 --- a/polymer/html/behaviors/fin-hypergrid-behavior-default.html +++ b/polymer/html/behaviors/fin-hypergrid-behavior-default.html @@ -5,6 +5,7 @@ @homepage http://github.com/openfin/fin-hypergrid --> + diff --git a/polymer/html/features/fin-hypergrid-feature-cell-click.html b/polymer/html/features/fin-hypergrid-feature-cell-click.html new file mode 100644 index 000000000..1345d9356 --- /dev/null +++ b/polymer/html/features/fin-hypergrid-feature-cell-click.html @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/polymer/js/behaviors/fin-hypergrid-behavior-default.js b/polymer/js/behaviors/fin-hypergrid-behavior-default.js index 3bc847515..a58d0927d 100644 --- a/polymer/js/behaviors/fin-hypergrid-behavior-default.js +++ b/polymer/js/behaviors/fin-hypergrid-behavior-default.js @@ -100,6 +100,7 @@ }, initializeFeatureChain: function(grid) { + this.setNextFeature(document.createElement('fin-hypergrid-feature-cell-click')); this.setNextFeature(document.createElement('fin-hypergrid-feature-overlay')); this.setNextFeature(document.createElement('fin-hypergrid-feature-column-resizing')); this.setNextFeature(document.createElement('fin-hypergrid-feature-row-resizing')); @@ -374,7 +375,7 @@ }, setCursor: function(grid) { - grid.beCursor('default'); + grid.setDefaultCursor(); this.featureChain.setCursor(grid); }, @@ -581,6 +582,9 @@ style.height = '90%'; style.whiteSpace = 'nowrap'; }, + getCursorAt: function( /* x, y */ ) { + return null; + } }); diff --git a/polymer/js/features/fin-hypergrid-feature-cell-click.js b/polymer/js/features/fin-hypergrid-feature-cell-click.js new file mode 100644 index 000000000..5756a4319 --- /dev/null +++ b/polymer/js/features/fin-hypergrid-feature-cell-click.js @@ -0,0 +1,14 @@ +'use strict'; + +(function() { + + Polymer('fin-hypergrid-feature-cell-click', { /* jshint ignore:line */ + handleTap: function(grid, event) { + grid.fireCellClickEvent(event); + if (this.next) { + this.next.handleTap(grid, event); + } + } + }); + +})(); diff --git a/polymer/js/features/fin-hypergrid-feature-on-hover.js b/polymer/js/features/fin-hypergrid-feature-on-hover.js index 1540bd5cd..f15c151a8 100644 --- a/polymer/js/features/fin-hypergrid-feature-on-hover.js +++ b/polymer/js/features/fin-hypergrid-feature-on-hover.js @@ -20,13 +20,19 @@ this.next.handleMouseMove(grid, event); } } - }, - handleMouseEnter: function(grid, event) { - console.log('mouse enter', event); - }, - handleMouseExit: function(grid, event) { - console.log('mouse exit', event); } }); })(); /* jshint ignore:line */ + + +// handleMouseMove: function(grid, event) { +// if (this.isFixedRow(grid, event) && !this.isFixedColumn(grid, event)) { +// this.cursor = 'pointer'; +// } else { +// this.cursor = null; +// } +// if (this.next) { +// this.next.handleMouseMove(grid, event); +// } +// } diff --git a/polymer/js/fin-hypergrid-cell-provider.js b/polymer/js/fin-hypergrid-cell-provider.js index 11ee2e810..20d468128 100644 --- a/polymer/js/fin-hypergrid-cell-provider.js +++ b/polymer/js/fin-hypergrid-cell-provider.js @@ -4,7 +4,7 @@ var noop = function() {}; (function() { - var underline = function(ctx, text, x, y, size, thickness, offset) { + var underline = function(ctx, text, x, y, thickness) { var width = ctx.measureText(text).width; switch (ctx.textAlign) { @@ -16,8 +16,6 @@ var noop = function() {}; break; } - y += size + offset; - ctx.beginPath(); ctx.lineWidth = thickness; ctx.moveTo(x + 0.5, y + 0.5); @@ -94,12 +92,10 @@ var noop = function() {}; cell.config = config; return cell; }, - //This is the default cell rendering function for rendering a vanilla cell. Great care was taken in crafting this function as it needs to perform extremely fast. Reads on the gc object are expensive but not quite as expensive as writes to it. We do our best to avoid writes, then avoid reads. Clipping bounds are not set here as this is also an expensive operation. Instead, we truncate overflowing text and content by filling a rectangle with background color column by column instead of cell by cell. This column by column fill happens higher up on the stack in a calling function from OFGridRenderer. Take note we do not do cell by cell border renderering as that is expensive. Instead we render many fewer gridlines after all cells are rendered. + defaultCellPaint: function(gc, x, y, width, height, isLink) { - defaultCellPaint: function(gc, x, y, width, height) { - - + isLink = isLink || false; var colHEdgeOffset = this.config.properties.cellPadding, halignOffset = 0, valignOffset = this.config.voffset, @@ -151,14 +147,14 @@ var noop = function() {}; } gc.fillText(this.config.value, x + halignOffset, y + valignOffset); - if (isHovered) { + if (isLink && isHovered) { //gc.fillStyle = this.config.isSelected ? this.config.bgSelColor : this.config.bgColor; // var prevLW = gc.lineWidth; // var prevSS = gc.strokeStyle; gc.strokeStyle = theColor; // gc.lineWidth = 3; gc.rect(x + 2, y + 2, width - 4, height - 4); - underline(gc, this.config.value, x + halignOffset, y, valignOffset + Math.floor(fontMetrics.height / 2), 1, 1, 0); + underline(gc, this.config.value, x + halignOffset, y + valignOffset + Math.floor(fontMetrics.height / 2), 1); gc.stroke(); //gc.lineWidth = prevLW; // gc.strokeStyle = prevSS; @@ -270,6 +266,7 @@ var noop = function() {}; //default cellRenderers are initialized here. you can augment the visible on your cellProvider instance: field ```myCellProviderInstance.cellCache.myCellRendererName = myCellRenderer``` initializeCells: function() { + var self = this; this.cellCache.simpleCellRenderer = { paint: this.defaultCellPaint }; @@ -288,6 +285,12 @@ var noop = function() {}; this.cellCache.emptyCellRenderer = { paint: this.emptyCellRenderer }; + this.cellCache.linkCellRenderer = { + paint: function(gc, x, y, width, height) { + self.config = this.config; + self.defaultCellPaint(gc, x, y, width, height, true); + }, + }; }, }); diff --git a/polymer/js/fin-hypergrid.js b/polymer/js/fin-hypergrid.js index e4989d6a2..585a82dfc 100644 --- a/polymer/js/fin-hypergrid.js +++ b/polymer/js/fin-hypergrid.js @@ -1111,17 +1111,6 @@ this.style.cursor = cursorName; }, - /** - * . - * . - * turn on the column resize cursor - * - * @method beColumnResizeCursor() - */ - beDefaultCursor: function() { - this.style.cursor = 'default'; - }, - delegateWheelMoved: function(event) { var behavior = this.getBehavior(); behavior.onWheelMoved(this, event); @@ -1498,6 +1487,21 @@ this.synchronizeScrollingBoundries(); }, + fireCellClickEvent: function(event) { + var behavior = this.getBehavior(); + var hovered = this.getHoverCell(); + var x = behavior.translateColumnIndex(hovered.x + this.getHScrollValue()); + hovered = rectangles.point.create(x, hovered.y + this.getVScrollValue()); + var clickEvent = new CustomEvent('fin-cell-click', { + detail: { + cell: hovered, + event: event, + time: Date.now() + } + }); + this.canvas.dispatchEvent(clickEvent); + }, + /** * . * . @@ -2093,6 +2097,14 @@ }, resolveCellEditor: function(name) { return this.cellEditors[name]; + }, + setDefaultCursor: function() { + var behavior = this.getBehavior(); + var hoverCell = this.hoverCell; + var x = hoverCell.x + this.getHScrollValue(); + x = behavior.translateColumnIndex(x); + var cursor = hoverCell ? behavior.getCursorAt(x, hoverCell.y + this.getVScrollValue()) : behavior.getCursorAt(-1, -1); + this.beCursor(cursor); } }); diff --git a/test/features/fin-hypergrid-feature-cell-click.js b/test/features/fin-hypergrid-feature-cell-click.js new file mode 100644 index 000000000..25357df23 --- /dev/null +++ b/test/features/fin-hypergrid-feature-cell-click.js @@ -0,0 +1,16 @@ +/* globals describe, it, assert */ + +'use strict'; + +var customElement = document.querySelector('fin-hypergrid-feature-cell-click'); + +describe('', function() { + + describe('features/fin-hypergrid-feature-cell-click.js', function() { + it('should have real tests filled out', function() { + assert.equal(customElement, customElement); + }); + + }); + +}); diff --git a/test/index.html b/test/index.html index ba6f0b473..e484ec9ad 100644 --- a/test/index.html +++ b/test/index.html @@ -28,6 +28,7 @@ 'cell-editors/fin-hypergrid-cell-editor-textfield.js', 'data.js', 'features/fin-hypergrid-feature-base.js', + 'features/fin-hypergrid-feature-cell-click.js', 'features/fin-hypergrid-feature-cell-editing.js', 'features/fin-hypergrid-feature-cell-selection.js', 'features/fin-hypergrid-feature-column-moving.js',