Last active
May 5, 2016 15:08
-
-
Save brainysmurf/e92c80511ededff2685b69770bda37dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To use: | |
// Put the below in the <script> portion of your template | |
// Set awesometable config to use that template (see documentation for details) | |
function main() { | |
columns = { | |
1: // first column, not column A in the data sheet, the first column displayed in the table | |
{ | |
text: ['Yippee'], // changes title to "Yippee" | |
css: ['width', '10%'] // changes the width | |
}, | |
2: // second column, not column B! | |
{ | |
// not including text means the column name will not be changed | |
css: ['width','90%'] | |
} | |
}; | |
for (col in columns) { | |
for (attr in columns[col]) { | |
// derive the element and raw data we need to do the manipulation | |
var $el = $('.google-visualization-table-th:nth-child(' + col + ')'); | |
var params = columns[col][attr]; | |
// use javascript's apply function to set the data | |
$el[attr].apply($el, params); | |
} | |
} | |
} | |
(function() { | |
[ | |
'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js', | |
].forEach(function(src, index, arr) { | |
var tag = undefined; | |
if (src.endsWith('.js')) { | |
tag = document.createElement('script'); | |
tag.src = src; | |
tag.async = false; | |
} else if (src.endsWith('.css')) { | |
tag = document.createElement('link'); | |
tag.rel = "stylesheet"; | |
tag.href = src; | |
} | |
if (index === (arr.length-1)) { | |
tag.onload = function () { | |
$(function () { | |
$('iframe').ready(function () { | |
main(); | |
}); | |
}); | |
}; | |
} | |
document.head.appendChild(tag); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment