From ed2fa06a26ad1f43dcf750133cd658638a0e9481 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 28 Aug 2013 16:52:12 +0200 Subject: reviewers comments --- core/js/placeholder.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ core/js/visualize.js | 52 ------------------------------------------- 2 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 core/js/placeholder.js delete mode 100644 core/js/visualize.js (limited to 'core/js') diff --git a/core/js/placeholder.js b/core/js/placeholder.js new file mode 100644 index 00000000000..6a1c653b587 --- /dev/null +++ b/core/js/placeholder.js @@ -0,0 +1,60 @@ +/** + * ownCloud + * + * @author Morris Jobke + * @copyright 2013 Morris Jobke + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * + */ + +/* + * Adds a background color to the element called on and adds the first charater + * of the passed in string. This string is also the seed for the generation of + * the background color. + * + * You have following HTML: + * + *
+ * + * And call this from Javascript: + * + * $('#albumart').placeholder('The Album Title'); + * + * Which will result in: + * + *
T
+ * + */ + +(function ($) { + $.fn.placeholder = function(seed) { + var hash = md5(seed), + maxRange = parseInt('ffffffffff', 16), + red = parseInt(hash.substr(0,10), 16) / maxRange * 256, + green = parseInt(hash.substr(10,10), 16) / maxRange * 256, + blue = parseInt(hash.substr(20,10), 16) / maxRange * 256, + rgb = [Math.floor(red), Math.floor(green), Math.floor(blue)]; + this.css('background-color', 'rgb(' + rgb.join(',') + ')'); + + // CSS rules + this.css('color', 'rgb(255, 255, 255)'); + this.css('font-weight', 'bold'); + this.css('text-align', 'center'); + + if(seed !== null && seed.length) { + this.html(seed[0].toUpperCase()); + } + }; +}(jQuery)); diff --git a/core/js/visualize.js b/core/js/visualize.js deleted file mode 100644 index d6891085ce2..00000000000 --- a/core/js/visualize.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * ownCloud - * - * @author Morris Jobke - * @copyright 2013 Morris Jobke - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see . - * - */ - -/* - * Adds a background color to the element called on and adds the first charater - * of the passed in string. This string is also the seed for the generation of - * the background color. - * - * You have following HTML: - * - *
- * - * And call this from Javascript: - * - * $('#albumart').visualize('The Album Title'); - * - * Which will result in: - * - *
T
- * - */ - -(function ($) { - $.fn.visualize = function(seed) { - var hash = md5(seed), - maxRange = parseInt('ffffffffff', 16), - red = parseInt(hash.substr(0,10), 16) / maxRange * 256, - green = parseInt(hash.substr(10,10), 16) / maxRange * 256, - blue = parseInt(hash.substr(20,10), 16) / maxRange * 256; - rgb = [Math.floor(red), Math.floor(green), Math.floor(blue)]; - this.css('background-color', 'rgb(' + rgb.join(',') + ')'); - this.html(seed[0].toUpperCase()); - }; -}(jQuery)); \ No newline at end of file -- cgit v1.2.3