Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[NXCM-5148] Install all icon styles for an iconcontainer instance int…

…o a single stylesheet (ie{8,9,?} have limitations on the # of these before it looses its shit)

Will need to optimize this further to allow all iconcontainer instances to share a single stylesheet so this can scale better past 31
Remove custom Ext.util.CSS implementation which was handling ie9 due to ^^^, but once ^^^ its not needed.
  • Loading branch information...
commit 40a985086ca4046fd2fdf61d3837e5f72fc9f9c1 1 parent 8e479a3
@jdillon jdillon authored
View
33 nexus-webapp/src/main/webapp/js/Nexus/util/IconContainer.js
@@ -93,11 +93,27 @@ NX.define('Nexus.util.IconContainer', {
],
/**
+ * Array of styles (Strings) for each defined icon.
+ *
+ * @private
+ * @type {Array}
+ */
+ styles: undefined,
+
+ /**
+ * Reference to installed stylesheet.
+ *
+ * @private
+ * @type {Stylesheet}
+ */
+ stylesheet: undefined,
+
+ /**
* Defined icons.
*
* @private
*/
- icons: {},
+ icons: undefined,
/**
* Base-path for images.
@@ -124,7 +140,8 @@ NX.define('Nexus.util.IconContainer', {
config = config || {},
icons;
- // if we don't do that, all instances will use the same object from this prototype
+ // assign values to fields to avoid using the prototype's storage
+ self.styles = [];
self.icons = {};
// apply defaults to configuration
@@ -147,6 +164,11 @@ NX.define('Nexus.util.IconContainer', {
self.loadIcon(key, value);
});
+ // TODO: Need to optimize this further, so that there is a shared stylesheet to avoid >31 limitation on IE{8,9,?}
+
+ // Install all icons styles into a single stylesheet for this container
+ self.stylesheet = Ext.util.CSS.createStyleSheet(self.styles.join(' '));
+
// TODO: Pre-load all icons into browser
self.logGroupEnd();
@@ -262,11 +284,8 @@ NX.define('Nexus.util.IconContainer', {
self.logDebug('Defining icon:', name, 'cls:', cls, 'path:', iconPath);
- // install stylesheet for icon
- Ext.util.CSS.createStyleSheet(
- '.' + cls + ' { background: url(' + iconPath + ') no-repeat !important; }',
- cls // use class as id
- );
+ // append style for icon, will be appended to icon containers stylesheet
+ self.styles.push('.' + cls + ' { background: url(' + iconPath + ') no-repeat !important; }');
/**
* Icon.
View
3  nexus-webapp/src/main/webapp/js/ext/util.js
@@ -13,8 +13,7 @@
/*global define*/
define('ext/util',
[
- 'ext/util/event',
- 'ext/util/CSS'
+ 'ext/util/event'
],
function(Ext) {
return Ext;
View
42 nexus-webapp/src/main/webapp/js/ext/util/CSS.js
@@ -1,42 +0,0 @@
-/*
- * Sonatype Nexus (TM) Open Source Version
- * Copyright (c) 2007-2012 Sonatype, Inc.
- * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
- *
- * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
- * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
- * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
- * Eclipse Foundation. All other trademarks are the property of their respective owners.
- */
-/*global define*/
-define('ext/util/CSS', ['extjs'], function(Ext) {
- var origFn = Ext.util.CSS.createStyleSheet;
- Ext.util.CSS.createStyleSheet = function(cssText, id) {
- // HACK
- // IE9 is apparently doing "the right thing", so original function would fail with it's exception for Ext.isIE
- if (Ext.isIE9) {
- // COPYPASTED FROM EXTJS 3.4.1
- var ss, head = document.getElementsByTagName("head")[0], rules = document.createElement("style");
- rules.setAttribute("type", "text/css");
- if (id) {
- rules.setAttribute("id", id);
- }
-
- try {
- rules.appendChild(document.createTextNode(cssText));
- }
- catch (error) {
- rules.cssText = cssText;
- }
- head.appendChild(rules);
- ss = rules.styleSheet || (rules.sheet || document.styleSheets[document.styleSheets.length - 1]);
-
- this.cacheStyleSheet(ss);
- return ss;
- }
-
- origFn.apply(this, arguments);
- };
-});
Please sign in to comment.
Something went wrong with that request. Please try again.