diff options
author | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-07-07 18:59:34 +0100 |
---|---|---|
committer | Peter 'Pita' Martischka <petermartischka@googlemail.com> | 2011-07-07 18:59:34 +0100 |
commit | 271ee1776b6900d90d138d6770fe288768162ca1 (patch) | |
tree | b6996fed98a30d24bb6cad2b3b60e5367b180858 /static/js/cssmanager.js | |
parent | 2fa1d8768b52ebf7483a4ecb41c2a0ad007efaef (diff) | |
download | etherpad-lite-271ee1776b6900d90d138d6770fe288768162ca1.zip |
beautified all static js files
Diffstat (limited to 'static/js/cssmanager.js')
-rw-r--r-- | static/js/cssmanager.js | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/static/js/cssmanager.js b/static/js/cssmanager.js index a5c549ba..feaef67a 100644 --- a/static/js/cssmanager.js +++ b/static/js/cssmanager.js @@ -1,5 +1,3 @@ - - /** * Copyright 2009 Google Inc. * @@ -16,20 +14,24 @@ * limitations under the License. */ -function makeCSSManager(emptyStylesheetTitle) { +function makeCSSManager(emptyStylesheetTitle) +{ - function getSheetByTitle(title) { + function getSheetByTitle(title) + { var allSheets = document.styleSheets; - for(var i=0;i<allSheets.length;i++) { + for (var i = 0; i < allSheets.length; i++) + { var s = allSheets[i]; - if (s.title == title) { - return s; + if (s.title == title) + { + return s; } } return null; } - /*function getSheetTagByTitle(title) { +/*function getSheetTagByTitle(title) { var allStyleTags = document.getElementsByTagName("style"); for(var i=0;i<allStyleTags.length;i++) { var t = allStyleTags[i]; @@ -42,29 +44,43 @@ function makeCSSManager(emptyStylesheetTitle) { var browserSheet = getSheetByTitle(emptyStylesheetTitle); //var browserTag = getSheetTagByTitle(emptyStylesheetTitle); - function browserRules() { return (browserSheet.cssRules || browserSheet.rules); } - function browserDeleteRule(i) { + + + function browserRules() + { + return (browserSheet.cssRules || browserSheet.rules); + } + + function browserDeleteRule(i) + { if (browserSheet.deleteRule) browserSheet.deleteRule(i); else browserSheet.removeRule(i); } - function browserInsertRule(i, selector) { - if (browserSheet.insertRule) browserSheet.insertRule(selector+' {}', i); + + function browserInsertRule(i, selector) + { + if (browserSheet.insertRule) browserSheet.insertRule(selector + ' {}', i); else browserSheet.addRule(selector, null, i); } var selectorList = []; - function indexOfSelector(selector) { - for(var i=0;i<selectorList.length;i++) { - if (selectorList[i] == selector) { - return i; + function indexOfSelector(selector) + { + for (var i = 0; i < selectorList.length; i++) + { + if (selectorList[i] == selector) + { + return i; } } return -1; } - function selectorStyle(selector) { + function selectorStyle(selector) + { var i = indexOfSelector(selector); - if (i < 0) { + if (i < 0) + { // add selector browserInsertRule(0, selector); selectorList.splice(0, 0, selector); @@ -73,16 +89,22 @@ function makeCSSManager(emptyStylesheetTitle) { return browserRules().item(i).style; } - function removeSelectorStyle(selector) { + function removeSelectorStyle(selector) + { var i = indexOfSelector(selector); - if (i >= 0) { + if (i >= 0) + { browserDeleteRule(i); selectorList.splice(i, 1); } } - return {selectorStyle:selectorStyle, removeSelectorStyle:removeSelectorStyle, - info: function() { - return selectorList.length+":"+browserRules().length; - }}; + return { + selectorStyle: selectorStyle, + removeSelectorStyle: removeSelectorStyle, + info: function() + { + return selectorList.length + ":" + browserRules().length; + } + }; } |