     
     func textViewDidChange(textView: UITextView) {
         let height = max(textView.contentSize.height, editorTextViewMinHeight) + editorTextViewMargin
+        
         var frame = textView.frame
         frame.size.height = height
         textView.frame = frame
-        self.editorTextViewHeightConstraint.constant = height
+        
+        editorTextViewHeightConstraint.constant = height
     }
     
     func handleKeyboardWillShowNotification(notification: NSNotification) {
-        NSLog("handleKeyboardWillShowNotification")
-        
         let userInfo = notification.userInfo!
         let animationDuration: NSTimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as NSNumber).doubleValue
         let keyboardScreenEndFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
         
         let orientation: UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation
         if (orientation.isLandscape) {
-            self.editorViewButtomConstraint.constant = keyboardScreenEndFrame.size.width
+            editorViewButtomConstraint.constant = keyboardScreenEndFrame.size.width
         } else {
-            self.editorViewButtomConstraint.constant = keyboardScreenEndFrame.size.height
+            editorViewButtomConstraint.constant = keyboardScreenEndFrame.size.height
         }
         
         self.view.setNeedsUpdateConstraints()

    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.editorTextView.delegate = self
        UIButton.appearance().setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
        editorTextViewMinHeight = Int(self.editorTextViewHeightConstraint.constant) - editorTextViewMargin
    }
    
    override func didReceiveMemoryWarning() {

    }
    
    func handleKeyboardWillHideNotification(notification: NSNotification) {
        let userInfo = notification.userInfo!
        let animationDuration: NSTimeInterval = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as NSNumber).doubleValue
        
        editorViewButtomConstraint.constant = 0
        
        UIView.animateWithDuration(animationDuration, delay: 0, options: .BeginFromCurrentState, animations: {
            self.editorView.alpha = 0
            self.view.layoutIfNeeded()
        }, completion: { finished in
            self.editorView.hidden = true
        })
    }
    
    func closeEditor() {
        editorTextView.text = ""
        editorTextViewHeightConstraint.constant = editorTextViewMinHeight + editorTextViewMargin
        
        if (editorTextView.isFirstResponder()) {
            editorTextView.resignFirstResponder()
        } else {
            editorView.hidden = true
        }
    }
    
    @IBAction func signInButtonClick(sender: UIButton) {
    }
    
    @IBAction func closeEditorButtonClick(sender: UIButton) {
        closeEditor()
    }
    
    @IBAction func writeButtonClick(sender: UIButton) {
        if (editorView.hidden) {
            editorView.hidden = false
            editorView.alpha = 0
            editorTextView.becomeFirstResponder()
        }
    }
}
