cleanup more generated javascript code

This commit is contained in:
Jaime Pillora
2015-11-03 17:20:36 +11:00
parent 521514180d
commit b724df3b02
3 changed files with 26 additions and 17 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"browser": true
}
+20 -17
View File
@@ -92,7 +92,6 @@
}; };
var addStyle = function(name, def) { var addStyle = function(name, def) {
var cssText, elem, fields, ref;
if (!name) { if (!name) {
throw "Missing Style name"; throw "Missing Style name";
} }
@@ -102,7 +101,9 @@
if (!def.html) { if (!def.html) {
throw "Missing Style HTML"; throw "Missing Style HTML";
} }
if ((ref = styles[name]) != null ? ref.cssElem : void 0) { //remove existing style
var existing = styles[name];
if (existing && existing.cssElem) {
if (window.console) { if (window.console) {
console.warn(pluginName + ": overwriting style '" + name + "'"); console.warn(pluginName + ": overwriting style '" + name + "'");
} }
@@ -110,7 +111,7 @@
} }
def.name = name; def.name = name;
styles[name] = def; styles[name] = def;
cssText = ""; var cssText = "";
if (def.classes) { if (def.classes) {
$.each(def.classes, function(className, props) { $.each(def.classes, function(className, props) {
cssText += "." + pluginClassName + "-" + def.name + "-" + className + " {\n"; cssText += "." + pluginClassName + "-" + def.name + "-" + className + " {\n";
@@ -132,11 +133,11 @@
def.cssElem = insertCSS(cssText); def.cssElem = insertCSS(cssText);
def.cssElem.attr("id", "notify-" + def.name); def.cssElem.attr("id", "notify-" + def.name);
} }
fields = {}; var fields = {};
elem = $(def.html); var elem = $(def.html);
findFields("html", elem, fields); findFields("html", elem, fields);
findFields("text", elem, fields); findFields("text", elem, fields);
return def.fields = fields; def.fields = fields;
}; };
var insertCSS = function(cssText) { var insertCSS = function(cssText) {
@@ -146,8 +147,7 @@
$("head").append(elem); $("head").append(elem);
try { try {
elem.html(cssText); elem.html(cssText);
} catch (error) { } catch (_) {
e = error;
elem[0].styleSheet.cssText = cssText; elem[0].styleSheet.cssText = cssText;
} }
return elem; return elem;
@@ -165,7 +165,7 @@
if (!name) { if (!name) {
name = blankFieldName; name = blankFieldName;
} }
return fields[name] = type; fields[name] = type;
}); });
}; };
@@ -330,15 +330,16 @@
}; };
Notification.prototype.setGlobalPosition = function() { Notification.prototype.setGlobalPosition = function() {
var align, anchor, css, key, main, pAlign, pMain, ref; var p = this.getPosition();
ref = this.getPosition(), pMain = ref[0], pAlign = ref[1]; var pMain = p[0];
main = positions[pMain]; var pAlign = p[1];
align = positions[pAlign]; var main = positions[pMain];
key = pMain + "|" + pAlign; var align = positions[pAlign];
anchor = globalAnchors[key]; var key = pMain + "|" + pAlign;
var anchor = globalAnchors[key];
if (!anchor) { if (!anchor) {
anchor = globalAnchors[key] = createElem("div"); anchor = globalAnchors[key] = createElem("div");
css = {}; var css = {};
css[main] = 0; css[main] = 0;
if (align === "middle") { if (align === "middle") {
css.top = '45%'; css.top = '45%';
@@ -356,7 +357,9 @@
Notification.prototype.setElementPosition = function() { Notification.prototype.setElementPosition = function() {
var arrowColor, arrowCss, arrowSize, color, contH, contW, css, elemH, elemIH, elemIW, elemPos, elemW, gap, j, k, len, len1, mainFull, margin, opp, oppFull, pAlign, pArrow, pMain, pos, posFull, position, ref, wrapPos; var arrowColor, arrowCss, arrowSize, color, contH, contW, css, elemH, elemIH, elemIW, elemPos, elemW, gap, j, k, len, len1, mainFull, margin, opp, oppFull, pAlign, pArrow, pMain, pos, posFull, position, ref, wrapPos;
position = this.getPosition(); position = this.getPosition();
pMain = position[0], pAlign = position[1], pArrow = position[2]; pMain = position[0];
pAlign = position[1];
pArrow = position[2];
elemPos = this.elem.position(); elemPos = this.elem.position();
elemH = this.elem.outerHeight(); elemH = this.elem.outerHeight();
elemW = this.elem.outerWidth(); elemW = this.elem.outerWidth();
+3
View File
@@ -21,5 +21,8 @@
}, },
"dependencies": { "dependencies": {
"jquery": "^2.1.4" "jquery": "^2.1.4"
},
"devDependencies": {
"jshint": "^2.8.0"
} }
} }