-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d44a09
commit b1a71fd
Showing
17 changed files
with
362 additions
and
26 deletions.
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
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
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,20 @@ | ||
'use strict'; | ||
|
||
let jwt = require('jwt-simple'); | ||
|
||
let payload = { | ||
"d": { | ||
"uid": "SALES_AGENT", | ||
"isAdmin": true | ||
}, | ||
"v": 0, | ||
// "iat": (new Date()).getTime()/1000 | ||
"iat": 1462700502 | ||
}; | ||
|
||
let secret = 'B7ioKnRoaf6ORCU4p8qUeAETTVcqBVykYIbeSEpF'; | ||
|
||
var token = jwt.encode(payload, secret); | ||
|
||
var decoded = jwt.decode(token, secret); | ||
console.log(decoded, token); |
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
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
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
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,9 @@ | ||
'use strict'; | ||
|
||
module.exports = function ($scope) { | ||
"ngInject"; | ||
$scope.times = function(num) { | ||
return new Array(num); | ||
} | ||
|
||
} |
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
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,155 @@ | ||
"use strict"; | ||
|
||
module.exports = function() { | ||
|
||
let controller = function($scope, $document) { | ||
"ngInject"; | ||
let editor = this; | ||
const TOOLBAR_DEFAULT_POS = {x: -99999, y: -99999}; | ||
|
||
$scope.toggleToolbarOnTextSelect = toggleToolbarOnTextSelect; | ||
editor.makeBold = makeBold; | ||
editor.makeItalic = makeItalic; | ||
editor.alignLeft = alignLeft; | ||
editor.alignRight = alignRight; | ||
editor.alignCenter = alignCenter; | ||
editor.showEditorTools = showEditorTools; | ||
editor.editorToolPosition = { | ||
x: TOOLBAR_DEFAULT_POS.x, | ||
y: TOOLBAR_DEFAULT_POS.y | ||
}; | ||
|
||
|
||
function save() { | ||
|
||
} | ||
|
||
function toggleToolbarOnTextSelect($event) { | ||
var text = ""; | ||
if (window.getSelection) { | ||
text = window.getSelection().toString(); | ||
} else if (document.selection && document.selection.type != "Control") { | ||
text = document.selection.createRange().text; | ||
} | ||
if(text.length) { | ||
editor.showEditorTools(true); | ||
} else { | ||
editor.showEditorTools(false); | ||
} | ||
} | ||
|
||
function showEditorTools(flag) { | ||
let coords = null; | ||
if (!flag) { | ||
coords = { | ||
x: TOOLBAR_DEFAULT_POS.x, | ||
y: TOOLBAR_DEFAULT_POS.y | ||
} | ||
} else { | ||
coords = getSelectionCoords(); | ||
} | ||
editor.editorToolPosition = { | ||
x: coords.x, | ||
y: coords.y | ||
} | ||
} | ||
|
||
function getToolbarWidth() { | ||
return angular.element(document.querySelectorAll(".simple-editor-toolbar")[0])[0].clientWidth | ||
} | ||
|
||
function getSelectionCoords() { | ||
var selection = window.getSelection(); | ||
var range = selection.getRangeAt(0); | ||
var boundary = range.getBoundingClientRect(); | ||
return { | ||
x: (boundary.left + boundary.right)/2 - getToolbarWidth()/2, | ||
y: boundary.top - 45 + window.pageYOffset | ||
}; | ||
} | ||
|
||
// function _getSelectionCoords(win) { | ||
// win = win || window; | ||
// var doc = win.document; | ||
// var sel = doc.selection, range, rects, rect; | ||
// var x = 0, y = 0; | ||
// if (sel) { | ||
// if (sel.type != "Control") { | ||
// range = sel.createRange(); | ||
// range.collapse(true); | ||
// x = range.boundingLeft; | ||
// y = range.boundingTop; | ||
// } | ||
// } else if (win.getSelection) { | ||
// sel = win.getSelection(); | ||
// if (sel.rangeCount) { | ||
// range = sel.getRangeAt(0).cloneRange(); | ||
// if (range.getClientRects) { | ||
// range.collapse(true); | ||
// rects = range.getClientRects(); | ||
// if (rects.length > 0) { | ||
// rect = rects[0]; | ||
// } | ||
// x = rect.left; | ||
// y = rect.top; | ||
// } | ||
// if (x == 0 && y == 0) { | ||
// var span = doc.createElement("span"); | ||
// if (span.getClientRects) { | ||
// span.appendChild( doc.createTextNode("\u200b") ); | ||
// range.insertNode(span); | ||
// rect = span.getClientRects()[0]; | ||
// x = rect.left; | ||
// y = rect.top; | ||
// var spanParent = span.parentNode; | ||
// spanParent.removeChild(span); | ||
|
||
// spanParent.normalize(); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// return { x: x, y: y }; | ||
// } | ||
|
||
function makeBold() { | ||
document.execCommand('bold', false, ''); | ||
} | ||
|
||
function makeItalic() { | ||
document.execCommand('italic', false, ''); | ||
} | ||
|
||
function alignLeft() { | ||
document.execCommand('justifyLeft', false, ''); | ||
toggleToolbarOnTextSelect(); | ||
} | ||
|
||
function alignRight() { | ||
document.execCommand('justifyRight', false, ''); | ||
toggleToolbarOnTextSelect(); | ||
} | ||
|
||
function alignCenter() { | ||
document.execCommand('justifyCenter', false, ''); | ||
toggleToolbarOnTextSelect(); | ||
} | ||
|
||
function makeLink() { | ||
|
||
} | ||
|
||
function makeHeader() { | ||
|
||
} | ||
|
||
}; | ||
|
||
return { | ||
restrict: 'E', | ||
controller: controller, | ||
controllerAs: 'editor', | ||
templateUrl: "./dist/templates/simple-editor-toolbar.html" | ||
} | ||
} | ||
|
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,6 @@ | ||
'use strict'; | ||
|
||
var module = 'poem.directives'; | ||
|
||
angular.module(module, []) | ||
.directive('simpleEditor', require('./editor')); |
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
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,45 @@ | ||
simple-editor { | ||
[contenteditable="true"]:active, [contenteditable="true"]:focus { | ||
border:none; | ||
outline:none; | ||
} | ||
|
||
// [contenteditable=true]:empty:before { | ||
// content: attr(placeholder); | ||
// display: block; /* For Firefox */ | ||
// } | ||
|
||
.simple-editor-heading { | ||
padding: 20px 10px; | ||
font-size: 25px; | ||
text-align: center; | ||
} | ||
|
||
.simple-editor-toolbar { | ||
background-color: rgba(256,256,256,0.8); | ||
position: absolute; | ||
border-radius: 3px; | ||
border: #dadada 1px solid; | ||
z-index: 1; | ||
|
||
button { | ||
min-width: 50px; | ||
margin: 0; | ||
border-radius: 0; | ||
} | ||
} | ||
md-card { | ||
// position: relative; | ||
height: 100%; | ||
outline: none; | ||
|
||
md-card-content { | ||
font-size: 18px; | ||
height: 100%; | ||
line-height: 150%; | ||
} | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.