-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Horizontal Ruler Helper #40
Open
Creativenauts
wants to merge
7
commits into
foundation:master
Choose a base branch
from
Creativenauts:horizontal-ruler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
328d5f9
Horizontal Ruler Helper
Creativenauts c6e54c8
Update ruler.js
Creativenauts c9965f0
Added Comments & Optimized Variables
Creativenauts e7c4a6c
Updated spaces from tab 4 to tab 2
Creativenauts 8d2f686
Changed code spacing
Creativenauts c1f70c5
Added option to align the ruler
Creativenauts fd1dc0f
Eliminated spacer.gif
Creativenauts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Add a horizontal ruler to your email | ||
* | ||
* @example | ||
* {{{ruler color="#ec6225" width="60px" height="3px" spacing="15px"}}} | ||
* | ||
* Attribute Options | ||
* color: Must be hex color value | ||
* width: Can be percentage (50%) or pixel (50px) unit | ||
* height: Defaults to pixel unit | ||
* spacing: Default to pixel unit | ||
* | ||
*/ | ||
|
||
module.exports = function(options) { | ||
|
||
// Trim Non-Numberic Chracters | ||
String.prototype.trimUnit = function() { return this.replace(/\D/g, ''); } | ||
|
||
// Variables & Options | ||
var color = options.hash.color, | ||
spacing = options.hash.spacing.trimUnit(), | ||
height = options.hash.height.trimUnit(), | ||
width = options.hash.width, | ||
widthType = '', | ||
trimWidth = width.trimUnit(), | ||
spacer = ''; | ||
|
||
// Set Undefined Options | ||
if (typeof color === 'undefined') color = ''; | ||
if (typeof height === 'undefined') height = ''; | ||
if (typeof width === 'undefined') width = ''; | ||
if (typeof spacing === 'undefined') { | ||
spacer = ''; | ||
} else { | ||
spacer = '<tr height="'+spacing+'"><td height="'+spacing+'"></td></tr>'; | ||
}; | ||
|
||
// Set Width Variables | ||
if(width.match('%$')) { | ||
widthType = width = trimWidth+'%'; | ||
} else if (width.match('px$')) { | ||
widthType = trimWidth+'px'; | ||
width = trimWidth; | ||
} else { | ||
widthType = 'auto'; | ||
width = trimWidth; | ||
} | ||
|
||
// HTML Output | ||
var ruler = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="'+width+'" height="'+height+'" style="width:'+widthType+' !important; height: '+height+'px !important;">\ | ||
'+spacer+'\ | ||
<tr height="'+height+'"><td bgcolor="'+color+'" align="center" valign="top" width="'+width+'" height="'+height+'" style="font-size: 0%; line-height:'+height+'px; mso-line-height-rule:exactly;">\ | ||
<img src="https://spacergif.org/spacer.gif" width="'+width+'" height="'+height+'" />\ | ||
</td></tr>\ | ||
'+spacer+'\ | ||
</table>'; | ||
|
||
return ruler; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please Indent properly .... Indentation should have 2 line spaces only instead of a tab.
If you are using editor like sublime text or atom , you can make your line space from 4 to 2 by customizing it like this below example of sublime!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IamManchanda thanks, I just checked preferences and tab_size is already set to 2 and translate tabs to spaces is set to true as well.