Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Fixed code style #191

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Source/FolioReaderWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ open class FolioReaderWebView: UIWebView {
} else {
if let textToShare = self.js("getSelectedText()") {
FolioReader.shared.readerCenter?.presentQuoteShare(textToShare)
self.isUserInteractionEnabled = false
self.isUserInteractionEnabled = true

self.clearTextSelection()
}
}
self.setMenuVisible(false)
Expand Down Expand Up @@ -108,9 +108,7 @@ open class FolioReaderWebView: UIWebView {
let startOffset = dic["startOffset"]!
let endOffset = dic["endOffset"]!

// Force remove text selection
isUserInteractionEnabled = false
isUserInteractionEnabled = true
self.clearTextSelection()

createMenu(options: true)
setMenuVisible(true, andRect: rect)
Expand All @@ -129,8 +127,8 @@ open class FolioReaderWebView: UIWebView {
let selectedText = js("getSelectedText()")

setMenuVisible(false)
isUserInteractionEnabled = false
isUserInteractionEnabled = true

self.clearTextSelection()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to use self here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but it's more consistent and clear this way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am personally going by this answer:

I would prefer to keep using self whenever I'm using a property to omit these misunderstandings.

What do you think?


let vc = UIReferenceLibraryViewController(term: selectedText! )
vc.view.tintColor = readerConfig.tintColor
Expand All @@ -140,10 +138,7 @@ open class FolioReaderWebView: UIWebView {
func play(_ sender: UIMenuController?) {
FolioReader.shared.readerAudioPlayer?.play()

// Force remove text selection
// @NOTE: this doesn't seem to always work
isUserInteractionEnabled = false
isUserInteractionEnabled = true
self.clearTextSelection()
}

func setYellow(_ sender: UIMenuController?) {
Expand Down Expand Up @@ -273,7 +268,15 @@ open class FolioReaderWebView: UIWebView {
return callback
}

// MARK: WebView direction config
// MARK: WebView

func clearTextSelection() {
// Forces text selection clearing
// @NOTE: this doesn't seem to always work

self.isUserInteractionEnabled = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to use self here.

self.isUserInteractionEnabled = true
}

func setupScrollDirection() {
switch readerConfig.scrollDirection {
Expand Down