beautified all static js files

This commit is contained in:
Peter 'Pita' Martischka 2011-07-07 18:59:34 +01:00
parent 2fa1d8768b
commit 271ee1776b
36 changed files with 9456 additions and 6035 deletions

View file

@ -1,12 +1,12 @@
/**
* Copyright 2009 Google Inc.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -15,15 +15,20 @@
*/
var padeditor = (function(){
var padeditor = (function()
{
var self = {
ace: null, // this is accessed directly from other files
ace: null,
// this is accessed directly from other files
viewZoom: 100,
init: function(readyFunc, initialViewOptions) {
init: function(readyFunc, initialViewOptions)
{
function aceReady() {
function aceReady()
{
$("#editorloadingbox").hide();
if (readyFunc) {
if (readyFunc)
{
readyFunc();
}
}
@ -31,7 +36,8 @@ var padeditor = (function(){
self.ace = new Ace2Editor();
self.ace.init("editorcontainer", "", aceReady);
self.ace.setProperty("wraps", true);
if (pad.getIsDebugEnabled()) {
if (pad.getIsDebugEnabled())
{
self.ace.setProperty("dmesg", pad.dmesg);
}
self.initViewOptions();
@ -41,22 +47,25 @@ var padeditor = (function(){
self.initViewZoom();
$("#viewbarcontents").show();
},
initViewOptions: function() {
padutils.bindCheckboxChange($("#options-linenoscheck"), function() {
pad.changeViewOption('showLineNumbers',
padutils.getCheckbox($("#options-linenoscheck")));
initViewOptions: function()
{
padutils.bindCheckboxChange($("#options-linenoscheck"), function()
{
pad.changeViewOption('showLineNumbers', padutils.getCheckbox($("#options-linenoscheck")));
});
padutils.bindCheckboxChange($("#options-colorscheck"), function() {
pad.changeViewOption('showAuthorColors',
padutils.getCheckbox("#options-colorscheck"));
padutils.bindCheckboxChange($("#options-colorscheck"), function()
{
pad.changeViewOption('showAuthorColors', padutils.getCheckbox("#options-colorscheck"));
});
$("#viewfontmenu").change(function() {
pad.changeViewOption('useMonospaceFont',
$("#viewfontmenu").val() == 'monospace');
$("#viewfontmenu").change(function()
{
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
});
},
setViewOptions: function(newOptions) {
function getOption(key, defaultValue) {
setViewOptions: function(newOptions)
{
function getOption(key, defaultValue)
{
var value = String(newOptions[key]);
if (value == "true") return true;
if (value == "false") return false;
@ -73,52 +82,59 @@ var padeditor = (function(){
padutils.setCheckbox($("#options-colorscheck"), v);
v = getOption('useMonospaceFont', false);
self.ace.setProperty("textface",
(v ? "monospace" : "Arial, sans-serif"));
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
$("#viewfontmenu").val(v ? "monospace" : "normal");
},
initViewZoom: function() {
initViewZoom: function()
{
var viewZoom = Number(padcookie.getPref('viewZoom'));
if ((! viewZoom) || isNaN(viewZoom)) {
if ((!viewZoom) || isNaN(viewZoom))
{
viewZoom = 100;
}
self.setViewZoom(viewZoom);
$("#viewzoommenu").change(function(evt) {
$("#viewzoommenu").change(function(evt)
{
// strip initial 'z' from val
self.setViewZoom(Number($("#viewzoommenu").val().substring(1)));
});
},
setViewZoom: function(percent) {
if (! (percent >= 50 && percent <= 1000)) {
setViewZoom: function(percent)
{
if (!(percent >= 50 && percent <= 1000))
{
// percent is out of sane range or NaN (which fails comparisons)
return;
}
self.viewZoom = percent;
$("#viewzoommenu").val('z'+percent);
$("#viewzoommenu").val('z' + percent);
var baseSize = 13;
self.ace.setProperty('textsize',
Math.round(baseSize * self.viewZoom / 100));
self.ace.setProperty('textsize', Math.round(baseSize * self.viewZoom / 100));
padcookie.setPref('viewZoom', percent);
},
dispose: function() {
if (self.ace) {
dispose: function()
{
if (self.ace)
{
self.ace.destroy();
}
},
disable: function() {
if (self.ace) {
disable: function()
{
if (self.ace)
{
self.ace.setProperty("grayedOut", true);
self.ace.setEditable(false);
}
},
restoreRevisionText: function(dataFromServer) {
restoreRevisionText: function(dataFromServer)
{
pad.addHistoricalAuthors(dataFromServer.historicalAuthorData);
self.ace.importAText(dataFromServer.atext, dataFromServer.apool, true);
}
};
return self;
}());