mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
add edit modal & fix some features
This commit is contained in:
@@ -39,6 +39,11 @@ module.exports = {
|
||||
name:'angular-md5',
|
||||
src:'node_modules/angular-md5/angular-md5.js',
|
||||
cdn:'https://raw.githubusercontent.com/gdi2290/angular-md5/v0.1.7/angular-md5.min.js'
|
||||
},
|
||||
{
|
||||
name:'moment',
|
||||
src:'node_modules/moment/moment.js',
|
||||
cdn:'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"angular-sanitize": "^1.3.15",
|
||||
"angular-ui-router": "^0.2.15",
|
||||
"font-awesome": "^4.3.0",
|
||||
"moment": "^2.10.3",
|
||||
"satellizer": "^0.10.1",
|
||||
"ui-select": "^0.11.2"
|
||||
},
|
||||
|
||||
@@ -10,12 +10,14 @@ angular.module('codexen', [
|
||||
'templates',
|
||||
'codexen.config',
|
||||
'codexen.directives',
|
||||
'codexen.filters',
|
||||
'codexen.modals',
|
||||
'codexen.services',
|
||||
'codexen.states'])
|
||||
angular.module('templates', [])
|
||||
angular.module('codexen.config', [])
|
||||
angular.module('codexen.directives', [])
|
||||
angular.module('codexen.filters', [])
|
||||
angular.module('codexen.modals', [])
|
||||
angular.module('codexen.services', [])
|
||||
angular.module('codexen.states', [])
|
||||
|
||||
@@ -1,740 +1,2 @@
|
||||
angular.module('codexen.config')
|
||||
.constant('aceModes', [{
|
||||
"name": "ABAP",
|
||||
"mode": [
|
||||
"abap"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ABC",
|
||||
"mode": [
|
||||
"abc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ActionScript",
|
||||
"mode": [
|
||||
"as"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ADA",
|
||||
"mode": [
|
||||
"ada|adb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Apache_Conf",
|
||||
"mode": [
|
||||
"^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AsciiDoc",
|
||||
"mode": [
|
||||
"asciidoc|adoc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Assembly_x86",
|
||||
"mode": [
|
||||
"asm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AutoHotKey",
|
||||
"mode": [
|
||||
"ahk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "BatchFile",
|
||||
"mode": [
|
||||
"bat|cmd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "C9Search",
|
||||
"mode": [
|
||||
"c9search_results"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "C_Cpp",
|
||||
"mode": [
|
||||
"cpp|c|cc|cxx|h|hh|hpp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cirru",
|
||||
"mode": [
|
||||
"cirru|cr"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Clojure",
|
||||
"mode": [
|
||||
"clj|cljs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cobol",
|
||||
"mode": [
|
||||
"CBL|COB"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "coffee",
|
||||
"mode": [
|
||||
"coffee|cf|cson|^Cakefile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ColdFusion",
|
||||
"mode": [
|
||||
"cfm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CSharp",
|
||||
"mode": [
|
||||
"cs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CSS",
|
||||
"mode": [
|
||||
"css"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Curly",
|
||||
"mode": [
|
||||
"curly"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "D",
|
||||
"mode": [
|
||||
"d|di"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dart",
|
||||
"mode": [
|
||||
"dart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Diff",
|
||||
"mode": [
|
||||
"diff|patch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dockerfile",
|
||||
"mode": [
|
||||
"^Dockerfile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dot",
|
||||
"mode": [
|
||||
"dot"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Dummy",
|
||||
"mode": [
|
||||
"dummy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DummySyntax",
|
||||
"mode": [
|
||||
"dummy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Eiffel",
|
||||
"mode": [
|
||||
"e"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "EJS",
|
||||
"mode": [
|
||||
"ejs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Elixir",
|
||||
"mode": [
|
||||
"ex|exs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Elm",
|
||||
"mode": [
|
||||
"elm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Erlang",
|
||||
"mode": [
|
||||
"erl|hrl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Forth",
|
||||
"mode": [
|
||||
"frt|fs|ldr"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FTL",
|
||||
"mode": [
|
||||
"ftl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Gcode",
|
||||
"mode": [
|
||||
"gcode"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Gherkin",
|
||||
"mode": [
|
||||
"feature"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Gitignore",
|
||||
"mode": [
|
||||
"^.gitignore"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Glsl",
|
||||
"mode": [
|
||||
"glsl|frag|vert"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "golang",
|
||||
"mode": [
|
||||
"go"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Groovy",
|
||||
"mode": [
|
||||
"groovy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "HAML",
|
||||
"mode": [
|
||||
"haml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Handlebars",
|
||||
"mode": [
|
||||
"hbs|handlebars|tpl|mustache"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Haskell",
|
||||
"mode": [
|
||||
"hs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "haXe",
|
||||
"mode": [
|
||||
"hx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "HTML",
|
||||
"mode": [
|
||||
"html|htm|xhtml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "HTML_Ruby",
|
||||
"mode": [
|
||||
"erb|rhtml|html.erb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "INI",
|
||||
"mode": [
|
||||
"ini|conf|cfg|prefs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Io",
|
||||
"mode": [
|
||||
"io"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Jack",
|
||||
"mode": [
|
||||
"jack"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Jade",
|
||||
"mode": [
|
||||
"jade"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"mode": [
|
||||
"java"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "JavaScript",
|
||||
"mode": [
|
||||
"js|jsm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "JSON",
|
||||
"mode": [
|
||||
"json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "JSONiq",
|
||||
"mode": [
|
||||
"jq"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "JSP",
|
||||
"mode": [
|
||||
"jsp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "JSX",
|
||||
"mode": [
|
||||
"jsx"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Julia",
|
||||
"mode": [
|
||||
"jl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LaTeX",
|
||||
"mode": [
|
||||
"tex|latex|ltx|bib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lean",
|
||||
"mode": [
|
||||
"lean|hlean"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LESS",
|
||||
"mode": [
|
||||
"less"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Liquid",
|
||||
"mode": [
|
||||
"liquid"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lisp",
|
||||
"mode": [
|
||||
"lisp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LiveScript",
|
||||
"mode": [
|
||||
"ls"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LogiQL",
|
||||
"mode": [
|
||||
"logic|lql"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LSL",
|
||||
"mode": [
|
||||
"lsl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lua",
|
||||
"mode": [
|
||||
"lua"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LuaPage",
|
||||
"mode": [
|
||||
"lp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Lucene",
|
||||
"mode": [
|
||||
"lucene"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Makefile",
|
||||
"mode": [
|
||||
"^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Markdown",
|
||||
"mode": [
|
||||
"md|markdown"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Mask",
|
||||
"mode": [
|
||||
"mask"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MATLAB",
|
||||
"mode": [
|
||||
"matlab"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MEL",
|
||||
"mode": [
|
||||
"mel"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MUSHCode",
|
||||
"mode": [
|
||||
"mc|mush"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MySQL",
|
||||
"mode": [
|
||||
"mysql"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Nix",
|
||||
"mode": [
|
||||
"nix"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ObjectiveC",
|
||||
"mode": [
|
||||
"m|mm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OCaml",
|
||||
"mode": [
|
||||
"ml|mli"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Pascal",
|
||||
"mode": [
|
||||
"pas|p"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Perl",
|
||||
"mode": [
|
||||
"pl|pm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pgSQL",
|
||||
"mode": [
|
||||
"pgsql"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PHP",
|
||||
"mode": [
|
||||
"php|phtml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Powershell",
|
||||
"mode": [
|
||||
"ps1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Praat",
|
||||
"mode": [
|
||||
"praat|praatscript|psc|proc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Prolog",
|
||||
"mode": [
|
||||
"plg|prolog"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Properties",
|
||||
"mode": [
|
||||
"properties"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Protobuf",
|
||||
"mode": [
|
||||
"proto"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Python",
|
||||
"mode": [
|
||||
"py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "R",
|
||||
"mode": [
|
||||
"r"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RDoc",
|
||||
"mode": [
|
||||
"Rd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "RHTML",
|
||||
"mode": [
|
||||
"Rhtml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Ruby",
|
||||
"mode": [
|
||||
"rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Rust",
|
||||
"mode": [
|
||||
"rs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SASS",
|
||||
"mode": [
|
||||
"sass"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SCAD",
|
||||
"mode": [
|
||||
"scad"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Scala",
|
||||
"mode": [
|
||||
"scala"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Scheme",
|
||||
"mode": [
|
||||
"scm|rkt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SCSS",
|
||||
"mode": [
|
||||
"scss"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SH",
|
||||
"mode": [
|
||||
"sh|bash|^.bashrc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SJS",
|
||||
"mode": [
|
||||
"sjs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Smarty",
|
||||
"mode": [
|
||||
"smarty|tpl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "snippets",
|
||||
"mode": [
|
||||
"snippets"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Soy_Template",
|
||||
"mode": [
|
||||
"soy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Space",
|
||||
"mode": [
|
||||
"space"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SQL",
|
||||
"mode": [
|
||||
"sql"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SQLServer",
|
||||
"mode": [
|
||||
"sqlserver"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Stylus",
|
||||
"mode": [
|
||||
"styl|stylus"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SVG",
|
||||
"mode": [
|
||||
"svg"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tcl",
|
||||
"mode": [
|
||||
"tcl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Tex",
|
||||
"mode": [
|
||||
"tex"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Text",
|
||||
"mode": [
|
||||
"txt"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Textile",
|
||||
"mode": [
|
||||
"textile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Toml",
|
||||
"mode": [
|
||||
"toml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Twig",
|
||||
"mode": [
|
||||
"twig"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Typescript",
|
||||
"mode": [
|
||||
"ts|typescript|str"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Vala",
|
||||
"mode": [
|
||||
"vala"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "VBScript",
|
||||
"mode": [
|
||||
"vbs|vb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Velocity",
|
||||
"mode": [
|
||||
"vm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Verilog",
|
||||
"mode": [
|
||||
"v|vh|sv|svh"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "VHDL",
|
||||
"mode": [
|
||||
"vhd|vhdl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "XML",
|
||||
"mode": [
|
||||
"xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "XQuery",
|
||||
"mode": [
|
||||
"xq"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "YAML",
|
||||
"mode": [
|
||||
"yaml|yml"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Django",
|
||||
"mode": [
|
||||
"html"
|
||||
]
|
||||
}
|
||||
])
|
||||
.constant('aceModes', ["ABAP","ABC","ActionScript","ADA","Apache_Conf","AsciiDoc","Assembly_x86","AutoHotKey","BatchFile","C9Search","C_Cpp","Cirru","Clojure","Cobol","coffee","ColdFusion","CSharp","CSS","Curly","D","Dart","Diff","Dockerfile","Dot","Dummy","DummySyntax","Eiffel","EJS","Elixir","Elm","Erlang","Forth","FTL","Gcode","Gherkin","Gitignore","Glsl","golang","Groovy","HAML","Handlebars","Haskell","haXe","HTML","HTML_Ruby","INI","Io","Jack","Jade","Java","JavaScript","JSON","JSONiq","JSP","JSX","Julia","LaTeX","Lean","LESS","Liquid","Lisp","LiveScript","LogiQL","LSL","Lua","LuaPage","Lucene","Makefile","Markdown","Mask","MATLAB","MEL","MUSHCode","MySQL","Nix","ObjectiveC","OCaml","Pascal","Perl","pgSQL","PHP","Powershell","Praat","Prolog","Properties","Protobuf","Python","R","RDoc","RHTML","Ruby","Rust","SASS","SCAD","Scala","Scheme","SCSS","SH","SJS","Smarty","snippets","Soy_Template","Space","SQL","SQLServer","Stylus","SVG","Tcl","Tex","Text","Textile","Toml","Twig","Typescript","Vala","VBScript","Velocity","Verilog","VHDL","XML","XQuery","YAML","Django"])
|
||||
|
||||
18
src/directives/btn-edit-snippet.js
Normal file
18
src/directives/btn-edit-snippet.js
Normal file
@@ -0,0 +1,18 @@
|
||||
angular.module('codexen.directives')
|
||||
.directive('btnEditSnippet', function (editSnippetModal, $rootScope) {
|
||||
return {
|
||||
scope:{
|
||||
snippet: '=btnEditSnippet'
|
||||
},
|
||||
link: function (scope, el) {
|
||||
el.on('click', function () {
|
||||
editSnippetModal.open(scope.snippet)
|
||||
.result.then(function (snippet) {
|
||||
$rootScope.$broadcast('snippetUpdated', snippet)
|
||||
}, function () {
|
||||
console.log('edit snippet modal dismissed')
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -5,6 +5,7 @@ angular.module('codexen.directives')
|
||||
el.on('click', function () {
|
||||
newSnippetModal.open()
|
||||
.result.then(function (snippet) {
|
||||
console.log('event fire', snippet)
|
||||
$rootScope.$broadcast('snippetUpdated', snippet)
|
||||
}, function () {
|
||||
console.log('new snippet modal dismissed')
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<a ui-sref="snippets"><i class="fa fa-code"></i> Snippets</a>
|
||||
</li>
|
||||
<li ui-sref-active="active">
|
||||
<a ui-sref="clips"><i class="fa fa-paperclip"></i> Clips</a>
|
||||
<a><i class="fa fa-paperclip"></i> Clips(ready)</a>
|
||||
</li>
|
||||
<li class="divider"><hr></li>
|
||||
<li>
|
||||
|
||||
7
src/filters/from-now.js
Normal file
7
src/filters/from-now.js
Normal file
@@ -0,0 +1,7 @@
|
||||
/* global angular */
|
||||
angular.module('codexen.filters')
|
||||
.filter('fromNow', function() {
|
||||
return function(input) {
|
||||
return moment(input).fromNow()
|
||||
}
|
||||
})
|
||||
@@ -30,6 +30,7 @@
|
||||
<script src="vendor/select.js"></script>
|
||||
<script src="vendor/satellizer.js"></script>
|
||||
<script src="vendor/angular-md5.js"></script>
|
||||
<script src="vendor/moment.js"></script>
|
||||
|
||||
<% scripts.forEach(function(script){ %>
|
||||
<script src="<%=script %>"></script>
|
||||
|
||||
63
src/modals/edit-snippet-modal.js
Normal file
63
src/modals/edit-snippet-modal.js
Normal file
@@ -0,0 +1,63 @@
|
||||
angular.module('codexen.modals')
|
||||
.factory('editSnippetModal', function ($modal) {
|
||||
var open = function (snippet) {
|
||||
return $modal.open({
|
||||
resolve:{
|
||||
snippet: function () {
|
||||
return snippet
|
||||
}
|
||||
},
|
||||
templateUrl:'modals/edit-snippet-modal.tpl.html',
|
||||
controller:'EditSnippetModalController as vm'
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
open: open
|
||||
}
|
||||
})
|
||||
.controller('EditSnippetModalController', function ($modalInstance, aceModes, $log, Snippet, $rootScope, Tag, snippet){
|
||||
var vm = this
|
||||
|
||||
vm.aceModes = aceModes
|
||||
vm.snippet = snippet
|
||||
console.log(snippet)
|
||||
|
||||
vm.submit = function () {
|
||||
console.log('mode: ',vm.snippet.mode)
|
||||
var params = {
|
||||
description: vm.snippet.description,
|
||||
callSign: vm.snippet.callSign,
|
||||
mode: vm.snippet.mode==null?null:vm.snippet.mode.toLowerCase(),
|
||||
content: vm.snippet.content,
|
||||
tags: angular.isArray(vm.snippet.tags)?vm.snippet.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }):[]
|
||||
}
|
||||
|
||||
Snippet.update(vm.snippet._id, params)
|
||||
.success(function (data) {
|
||||
$modalInstance.close(data.snippet)
|
||||
console.log('snippet created!', data)
|
||||
})
|
||||
}
|
||||
|
||||
// vm.tags = []
|
||||
vm.tagCandidates = []
|
||||
vm.refreshTagCandidates = function (tagName) {
|
||||
if (tagName == null || tagName == '') return null
|
||||
return Tag.findByName(tagName)
|
||||
.success(function (data) {
|
||||
console.log('tags fetched!!', data)
|
||||
vm.tagCandidates = data.tags
|
||||
})
|
||||
}
|
||||
vm.transform = function (tagName) {
|
||||
return {
|
||||
_id:0,
|
||||
name:tagName
|
||||
}
|
||||
}
|
||||
|
||||
vm.cancel = function () {
|
||||
$modalInstance.dismiss()
|
||||
}
|
||||
})
|
||||
47
src/modals/edit-snippet-modal.tpl.html
Normal file
47
src/modals/edit-snippet-modal.tpl.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<div class="new-snippet-modal">
|
||||
<div class="modal-header">
|
||||
New Snippet
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<textarea ng-model="vm.snippet.description" name="description" class="form-control" placeholder="Description..."></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input ng-model="vm.snippet.callSign" type="text" name="callSign" class="inline-form-control" placeholder="Call sign">
|
||||
|
||||
<ui-select ng-model="vm.snippet.mode" style="display: inline-block;" theme="bootstrap">
|
||||
<ui-select-match placeholder="Select Type">{{$select.selected}}</ui-select-match>
|
||||
<ui-select-choices repeat="mode in vm.aceModes | filter:$select.search">
|
||||
<div ng-bind-html="mode | highlight: $select.search"></div>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div
|
||||
ui-ace="{
|
||||
mode: vm.snippet.mode.toLowerCase()
|
||||
|
||||
}"
|
||||
ng-model="vm.snippet.content"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<ui-select multiple tagging="vm.transform" tagging-tokens="SPACE|,|/" ng-model="vm.snippet.tags" theme="bootstrap">
|
||||
<ui-select-match placeholder="Write Tags">{{$item.name}}</ui-select-match>
|
||||
<ui-select-choices repeat="tag in vm.tagCandidates" refresh="vm.refreshTagCandidates($select.search)"
|
||||
refresh-delay="200">
|
||||
<div><span ng-bind-html="tag.name | highlight: $select.search"></span><span ng-if="tag.isTag">(new)</span></div>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button ng-click="vm.submit()" type="button" name="button" class="btn btn-primary">Submit</button>
|
||||
<button ng-click="vm.cancel()" type="button" name="button" class="btn btn-default">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -20,7 +20,7 @@ angular.module('codexen.modals')
|
||||
var params = {
|
||||
description: vm.description,
|
||||
callSign: vm.callSign,
|
||||
mode: vm.mode==null?null:vm.mode.name.toLowerCase(),
|
||||
mode: vm.mode==null?null:vm.mode.toLowerCase(),
|
||||
content: vm.content,
|
||||
tags: angular.isArray(vm.tags)?vm.tags.map(function (tag) { return {_id: tag._id, name: tag.name} }):[]
|
||||
}
|
||||
@@ -28,7 +28,6 @@ angular.module('codexen.modals')
|
||||
Snippet.create(params)
|
||||
.success(function(data){
|
||||
$modalInstance.close(data.snippet)
|
||||
console.log('snippet created!', data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
<input ng-model="vm.callSign" type="text" name="callSign" class="inline-form-control" placeholder="Call sign">
|
||||
|
||||
<ui-select ng-model="vm.mode" style="display: inline-block;" on-select="vm.log(vm.mode.name.toLowerCase())" theme="bootstrap">
|
||||
<ui-select-match placeholder="Select Type">{{$select.selected.name}}</ui-select-match>
|
||||
<ui-select-choices repeat="mode in vm.aceModes | filter: {name: $select.search}">
|
||||
<div ng-bind-html="mode.name | highlight: $select.search"></div>
|
||||
<ui-select-match placeholder="Select Type">{{$select.selected}}</ui-select-match>
|
||||
<ui-select-choices repeat="mode in vm.aceModes | filter: $select.search">
|
||||
<div ng-bind-html="mode | highlight: $select.search"></div>
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
</div>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="form-group">
|
||||
<div
|
||||
ui-ace="{
|
||||
mode: vm.mode.name.toLowerCase()
|
||||
mode: vm.mode.toLowerCase()
|
||||
|
||||
}"
|
||||
ng-model="vm.content"
|
||||
|
||||
@@ -22,6 +22,12 @@ angular.module('codexen.services')
|
||||
return $http.get(url)
|
||||
}
|
||||
|
||||
var update = function (id, params) {
|
||||
var url = apiUrl + 'snippets/id/' + id
|
||||
|
||||
return $http.put(url, params)
|
||||
}
|
||||
|
||||
var destroy = function (id) {
|
||||
var url = apiUrl + 'snippets/id/' + id
|
||||
|
||||
@@ -32,6 +38,7 @@ angular.module('codexen.services')
|
||||
findByUser: findByUser,
|
||||
create: create,
|
||||
show: show,
|
||||
delete: destroy
|
||||
delete: destroy,
|
||||
update: update
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,7 +17,6 @@ angular.module('codexen.states')
|
||||
Snippet.delete(vm.snippet._id)
|
||||
.success(function () {
|
||||
$rootScope.$broadcast('snippetDeleted')
|
||||
$state.go('snippets')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<div class="snippets-detail-state">
|
||||
|
||||
<div class="detail-header">
|
||||
<span class="detail-header-title"><small>call sign : </small><span ng-bind="vm.snippet.callSign"></span></span>
|
||||
<span class="detail-header-title">
|
||||
<span ng-bind="vm.snippet.callSign"></span>
|
||||
<small><span ng-bind="snippet.updatedAt|fromNow"></span> <i class="fa fa-clock-o"></i></small>
|
||||
</span>
|
||||
<span class="detail-header-control pull-right">
|
||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
||||
<button btn-edit-snippet="vm.snippet" type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
||||
<button ng-click="vm.delete()" type="button" name="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
@@ -18,17 +21,17 @@
|
||||
<div ng-if="vm.isLoaded" class="">
|
||||
<p ng-bind="vm.snippet.description"></p>
|
||||
<div tags="vm.snippet.tags"></div>
|
||||
<label>Content</label>
|
||||
<div ui-ace="{
|
||||
showGutter: false,
|
||||
useWrapMode : true,
|
||||
mode:vm.snippet.mode,
|
||||
mode:vm.snippet.mode.toLowerCase(),
|
||||
maxLines: -1,
|
||||
readOnly: true,
|
||||
rendererOptions: {
|
||||
maxLinks: Infinity
|
||||
}
|
||||
}" ng-model="vm.snippet.content"></div>
|
||||
}"
|
||||
readonly
|
||||
ng-model="vm.snippet.content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* global angular */
|
||||
angular.module('codexen.states')
|
||||
.controller('SnippetsListController', function ($auth, Snippet, $scope) {
|
||||
.controller('SnippetsListController', function ($auth, Snippet, $scope, $state) {
|
||||
var vm = this
|
||||
|
||||
vm.isLoaded = false
|
||||
|
||||
var laodSnippets = function () {
|
||||
var loadSnippets = function () {
|
||||
if ($auth.isAuthenticated) {
|
||||
console.log($auth.getPayload())
|
||||
var userId = $auth.getPayload().sub
|
||||
@@ -23,22 +23,38 @@ angular.module('codexen.states')
|
||||
}
|
||||
}
|
||||
|
||||
laodSnippets()
|
||||
loadSnippets()
|
||||
|
||||
$scope.$on('userSignIn', function () {
|
||||
laodSnippets()
|
||||
loadSnippets()
|
||||
})
|
||||
|
||||
$scope.$on('userSignOut', function () {
|
||||
laodSnippets()
|
||||
loadSnippets()
|
||||
})
|
||||
|
||||
$scope.$on('snippetUpdated', function () {
|
||||
laodSnippets()
|
||||
$scope.$on('snippetUpdated', function (e, snippet) {
|
||||
$state.go('snippets.detail', {id: snippet._id})
|
||||
loadSnippets()
|
||||
})
|
||||
|
||||
$scope.$on('snippetDeleted', function () {
|
||||
laodSnippets()
|
||||
if ($state.is('snippets.detail')) {
|
||||
var currentSnippetId = $state.params.id
|
||||
for (var i = 0; i < vm.snippets.length; i++) {
|
||||
if (vm.snippets[i]._id === currentSnippetId) {
|
||||
var targetSnippet = null
|
||||
|
||||
if (i === 0) targetSnippet = vm.snippets[i+1]
|
||||
else targetSnippet = vm.snippets[i-1]
|
||||
|
||||
console.log('target', targetSnippet)
|
||||
$state.go('snippets.detail', {id: targetSnippet._id})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
loadSnippets()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<div class="snippets-list-state">
|
||||
|
||||
<div class="left-pane">
|
||||
<div class="snippet-search">
|
||||
<input ng-model="vm.search" type="text" name="name" class="form-control" placeholder="Search ...">
|
||||
</div>
|
||||
<ul class="snippet-list">
|
||||
|
||||
<li ng-if="!vm.isLoaded" class="message-item">
|
||||
@@ -23,14 +26,19 @@
|
||||
<a ui-sref="auth.signin" class="btn btn-default"><i class="fa fa-signin"></i> Sign In</a>
|
||||
</li>
|
||||
|
||||
<li ng-repeat="snippet in vm.snippets" ui-sref="snippets.detail({id:snippet._id})">
|
||||
<li ng-repeat="snippet in vm.snippets | filter:vm.search" ui-sref="snippets.detail({id:snippet._id})" ui-sref-active="active">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<img width="25" height="25" src="http://www.gravatar.com/avatar/ea0b6ad1c11700120d1af08810caa19d" alt="" />
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h4 ng-bind="snippet.description"></h4>
|
||||
<p class="created-at">created at <span ng-bind="snippet.createdAt"></span></p>
|
||||
<p ng-bind="snippet.callSign" class="call-sign">
|
||||
</p>
|
||||
<p ng-bind="snippet.description">
|
||||
</p>
|
||||
<p class="created-at">
|
||||
<span ng-bind="snippet.updatedAt|fromNow"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div tags="snippet.tags"></div>
|
||||
|
||||
@@ -7,6 +7,8 @@ $left-pane-width: 275px;
|
||||
$pane-border-color: $border-color;
|
||||
$snippet-list-border-color: $border-color;
|
||||
$snippet-list-item-hover-bg: #EEE;
|
||||
$snippet-list-active-color: white;
|
||||
$snippet-list-active-bg: $brand-primary;
|
||||
|
||||
.snippets-list-state{
|
||||
position: absolute;
|
||||
@@ -20,13 +22,29 @@ $snippet-list-item-hover-bg: #EEE;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: $left-pane-width;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overflow:hidden;
|
||||
border-right: solid 1px $pane-border-color;
|
||||
.snippet-search{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 50px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
border-bottom: solid 1px $snippet-list-border-color;
|
||||
padding: 7px 5px;
|
||||
}
|
||||
.snippet-list{
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
li{
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
border-bottom: solid 1px $snippet-list-border-color;
|
||||
h4{
|
||||
@@ -38,6 +56,20 @@ $snippet-list-item-hover-bg: #EEE;
|
||||
p{
|
||||
margin:0;
|
||||
}
|
||||
p.call-sign{
|
||||
font-size:0.8em;
|
||||
}
|
||||
p.created-at{
|
||||
font-size:0.8em;
|
||||
opacity: 0.8;
|
||||
}
|
||||
&.active{
|
||||
color: $snippet-list-active-color;
|
||||
background-color: $snippet-list-active-bg;
|
||||
a{
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* global angular */
|
||||
angular.module('codexen.states')
|
||||
.config(function($stateProvider, $urlRouterProvider){
|
||||
.config(function ($stateProvider, $urlRouterProvider) {
|
||||
$urlRouterProvider
|
||||
.when('/auth', '/auth/register')
|
||||
.when('/auth/', '/auth/register')
|
||||
@@ -10,7 +10,7 @@ angular.module('codexen.states')
|
||||
/* Auth */
|
||||
.state('auth', {
|
||||
url: '/auth',
|
||||
views:{
|
||||
views: {
|
||||
'main-view': {
|
||||
templateUrl: 'states/auth/auth.tpl.html'
|
||||
}
|
||||
@@ -30,7 +30,7 @@ angular.module('codexen.states')
|
||||
/* Snippets */
|
||||
.state('snippets', {
|
||||
url: '/snippets',
|
||||
views:{
|
||||
views: {
|
||||
'main-view': {
|
||||
templateUrl: 'states/snippets/list.tpl.html',
|
||||
controller: 'SnippetsListController as vm'
|
||||
|
||||
Reference in New Issue
Block a user