From 538e64c572220bba43960a3073468c0ce3dc5f4c Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 18 Dec 2013 14:57:35 -0500
Subject: [PATCH] Fix Closure-compiler warnings, small code improvements

---
 program/js/list.js                       |    6 +-----
 program/include/rcmail_output_html.php   |   20 +++++++++++++++++---
 plugins/password/password.js             |   16 ++++++++--------
 plugins/archive/archive.js               |    2 +-
 plugins/help/help.js                     |    2 +-
 plugins/vcard_attachments/vcardattach.js |    3 ++-
 6 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js
index 6ed4f97..8130334 100644
--- a/plugins/archive/archive.js
+++ b/plugins/archive/archive.js
@@ -1,4 +1,4 @@
-/*
+/**
  * Archive plugin script
  * @version 2.1
  */
diff --git a/plugins/help/help.js b/plugins/help/help.js
index 59a93c5..03edb7a 100644
--- a/plugins/help/help.js
+++ b/plugins/help/help.js
@@ -1,4 +1,4 @@
-/*
+/**
  * Help plugin client script
  * @version 1.4
  */
diff --git a/plugins/password/password.js b/plugins/password/password.js
index 12c9074..1bfb2a0 100644
--- a/plugins/password/password.js
+++ b/plugins/password/password.js
@@ -1,4 +1,4 @@
-/*
+/**
  * Password plugin script
  * @version @package_version@
  */
@@ -8,17 +8,17 @@
 
     // register command handler
     rcmail.register_command('plugin.password-save', function() { 
-      var input_curpasswd = rcube_find_object('_curpasswd');
-      var input_newpasswd = rcube_find_object('_newpasswd');
-          var input_confpasswd = rcube_find_object('_confpasswd');
-    
-      if (input_curpasswd && input_curpasswd.value=='') {
+      var input_curpasswd = rcube_find_object('_curpasswd'),
+        input_newpasswd = rcube_find_object('_newpasswd'),
+        input_confpasswd = rcube_find_object('_confpasswd');
+
+      if (input_curpasswd && input_curpasswd.value == '') {
           alert(rcmail.gettext('nocurpassword', 'password'));
           input_curpasswd.focus();
-      } else if (input_newpasswd && input_newpasswd.value=='') {
+      } else if (input_newpasswd && input_newpasswd.value == '') {
           alert(rcmail.gettext('nopassword', 'password'));
           input_newpasswd.focus();
-      } else if (input_confpasswd && input_confpasswd.value=='') {
+      } else if (input_confpasswd && input_confpasswd.value == '') {
           alert(rcmail.gettext('nopassword', 'password'));
           input_confpasswd.focus();
       } else if (input_newpasswd && input_confpasswd && input_newpasswd.value != input_confpasswd.value) {
diff --git a/plugins/vcard_attachments/vcardattach.js b/plugins/vcard_attachments/vcardattach.js
index 29bc1a6..b287acd 100644
--- a/plugins/vcard_attachments/vcardattach.js
+++ b/plugins/vcard_attachments/vcardattach.js
@@ -1,4 +1,4 @@
-/*
+/**
  * vcard_attachments plugin script
  * @version @package_version@
  */
@@ -13,6 +13,7 @@
 function plugin_vcard_insertrow(data)
 {
   var ctype = data.row.ctype;
+
   if (ctype == 'text/vcard' || ctype == 'text/x-vcard' || ctype == 'text/directory') {
     $('#rcmrow'+data.uid+' > td.attachment').html('<img src="'+rcmail.env.vcard_icon+'" alt="" />');
   }
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 6db826e..7ff85e0 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -45,6 +45,7 @@
     protected $footer = '';
     protected $body = '';
     protected $base_path = '';
+    protected $devel_mode = false;
 
     // deprecated names of templates used before 0.5
     protected $deprecated_templates = array(
@@ -63,6 +64,8 @@
     public function __construct($task = null, $framed = false)
     {
         parent::__construct();
+
+        $this->devel_mode = $this->config->get('devel_mode');
 
         //$this->framed = $framed;
         $this->set_env('task', $task);
@@ -658,8 +661,19 @@
         }
 
         // add file modification timestamp
-        if (preg_match('/\.(js|css)$/', $file)) {
-            if ($fs = @filemtime($file)) {
+        if (preg_match('/\.(js|css)$/', $file, $m)) {
+            $fs  = false;
+            $ext = $m[1];
+
+            // use minified file if exists (not in development mode)
+            if (!$this->devel_mode && !preg_match('/\.min\.' . $ext . '$/', $file)) {
+                $minified_file = substr($file, 0, strlen($ext) * -1) . 'min.' . $ext;
+                if ($fs = @filemtime($minified_file)) {
+                    $file = $minified_file . '?s=' . $fs;
+                }
+            }
+
+            if (!$fs && ($fs = @filemtime($file))) {
                 $file .= '?s=' . $fs;
             }
         }
@@ -971,7 +985,7 @@
                   $content = html::quote($this->get_pagetitle());
                 }
                 else if ($object == 'pagetitle') {
-                    if ($this->config->get('devel_mode') && !empty($_SESSION['username']))
+                    if ($this->devel_mode && !empty($_SESSION['username']))
                         $title = $_SESSION['username'].' :: ';
                     else if ($prod_name = $this->config->get('product_name'))
                         $title = $prod_name . ' :: ';
diff --git a/program/js/list.js b/program/js/list.js
index 6c0fbc2..54daa98 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -20,7 +20,7 @@
 
 /**
  * Roundcube List Widget class
- * @contructor
+ * @constructor
  */
 function rcube_list_widget(list, p)
 {
@@ -32,10 +32,6 @@
   this.list = list ? list : null;
   this.tagname = this.list ? this.list.nodeName.toLowerCase() : 'table';
   this.id_regexp = /^rcmrow([a-z0-9\-_=\+\/]+)/i;
-  this.thead;
-  this.tbody;
-  this.fixed_header;
-  this.frame = null;
   this.rows = {};
   this.selection = [];
   this.rowcount = 0;

--
Gitblit v1.9.1