diff --git a/VERSION b/VERSION
index 8bbb6e4..6ceb272 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.10.1
+2.11.1
diff --git a/docker-compose.yml b/docker-compose.yml
index 1cdcf89..693f89b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -61,11 +61,12 @@ services:
# useful to run api for development
prod-api-compiler-bk:
- container_name: prod-api-compiler-bk
extends: prod-api-build-bk
+ container_name: prod-api-compiler-bk
volumes:
- /var/lib/mageddo/bookmarks-node/db:/opt/bookmarks/db
command: bash -c "go install -v bk-api/vendor/github.com/mattn/go-sqlite3 && tail -f /dev/null"
+ working_dir: /go/src/bk-api
hostname: bk-api.dev
# run app for development
diff --git a/public/css/mobile/style.css b/public/css/mobile/style.css
new file mode 100644
index 0000000..d962fab
--- /dev/null
+++ b/public/css/mobile/style.css
@@ -0,0 +1,18 @@
+.ipt-name {
+ flex: 100;
+ width: auto;
+ display: inline-block;
+ margin-right: 5px;
+}
+
+
+.btn-public-link {
+ flex: 1;
+}
+
+.editor-panel {
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ margin: 5px 5px;
+}
diff --git a/public/css/style.css b/public/css/style.css
index b38e63c..e116563 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -1,27 +1,17 @@
-.white-popup{
- background: #FFF;
- margin: 20px auto;
- padding: 20px;
- position: relative;
- width: auto;
-}
-.popuparea .modal-dialog{
- margin-top: 0;
-}
.select2-close-mask{
z-index: 2099;
}
.select2-dropdown{
z-index: 3051;
}
-.navbar .mg-menu{
+.navbar .mg-menu {
background: white;
border: 1px solid #EEE;
left: 0;
overflow: auto;
position: absolute;
}
-.navbar .menu-expand{
+.navbar .menu-expand {
background-color: transparent;
background-image: none;
border: 1px solid transparent;
@@ -56,6 +46,7 @@ ul li img{
.switch input{
display: none;
}
+
.slider{
background-color: #ccc;
bottom: 0;
@@ -106,7 +97,7 @@ input:checked + .slider:before{
text-align: center;
}
-#text-editor, #editor-mb {
+#text-editor, #md-editor {
width: 100%;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
font-size: 13px;
@@ -114,30 +105,49 @@ input:checked + .slider:before{
tab-size: 2;
outline: none;
line-height: 150%;
+ border: 1px solid #CCC;
+ border-left: 0px;
+ border-right: 0px;
}
-.mobile-full-screen-modal {
- position: fixed;
- top: 0px;
- left: 0px;
- z-index: 3000;
- background: #ffffff;
- width: 100%;
- padding: 10px 5px;
- height: 100%;
+#bookmarkForm {
+ display: flex;
+ flex-direction: column;
}
-.mobile-full-screen-modal .editor-panel {
- height: 90%;
+
+.ipt-name {
+ flex: 100;
+ width: auto;
+ display: inline-block;
+ margin-right: 5px;
}
-.mobile-full-screen-modal textarea {
- min-height: 100%;
+
+.btn-public-link {
+ flex: 1;
}
+
+.md-toolbar {
+ border: none;
+}
+
+.editor-panel {
+ margin: 5px 5px;
+}
+
+.btn-editor-panel {
+ margin-top: 2px;
+}
+
+.editor-panel textarea {
+ width: 100%;
+ flex: 1;
+ resize: none;
+}
+
.editor-preview {
- border: 1px solid #CECBCB;
margin: 10px 0px;
padding: 5px;
- max-height: 100%;
- overflow-y: auto;
+ word-break: break-word;
}
.editor-common {
@@ -202,3 +212,48 @@ pre {
background-color: #e6e6e6
}
+
+/**
+ * New area
+ */
+.modal-editor {
+ display: block;
+ position: fixed;
+ background: white;
+ top: 0;
+ left: 0;
+ z-index: 1030;
+ width: 100%;
+ height: 100%;
+ overflow-y: auto;
+}
+
+/**
+ * Tags combo
+ */
+.select2-dropdown {
+ z-index: 1031;
+}
+
+.select2-container--focus .select2-selection {
+ border: 1px solid #66afe9!important;
+ box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6)
+}
+
+.select2-selection {
+ border: 1px solid #CCC!important;
+}
+
+.btn-fab {
+ position: fixed !important;
+ right: 20px;
+ bottom: 20px;
+ border-radius: 50%;
+ padding: 10px;
+ z-index: 1;
+}
+
+.bookmarkNew .glyphicon {
+ font-size: 24px;
+ padding: 5px;
+}
diff --git a/public/js/core.js b/public/js/core.js
index 81414cc..224bc77 100644
--- a/public/js/core.js
+++ b/public/js/core.js
@@ -79,6 +79,21 @@
$(container).html("Error on load " + url + "
" + error);
});
}
+
+ mg.popUpScreen2 = function(url, options, container){
+ container = container || ".modal-editor";
+ options = options || {};
+ options.url = url;
+ $.ajax(options).done(function(data){
+ $(container)
+ .html(data)
+ .removeClass("hidden");
+ }).error(function(error){
+ // TODO EFS fazer isso buscar de um template
+ $(container).html("Error on load " + url + "
" + error);
+ });
+ }
+
mg.clearSelection = function() {
if(document.selection && document.selection.empty) {
document.selection.empty();
@@ -111,8 +126,7 @@
}
};
- mg.insertAtCaret = function(selec, text) {
- var txtarea = $(selec).get(0);
+ mg.insertAtCaret = function(txtarea, text) {
if (!txtarea) { return; }
console.debug('m=insertAtCaret, status=begin');
var scrollPos = txtarea.scrollTop;
diff --git a/public/js/ct/bookmarkEdit.js b/public/js/ct/bookmarkEdit.js
index 9568c50..b3d1186 100644
--- a/public/js/ct/bookmarkEdit.js
+++ b/public/js/ct/bookmarkEdit.js
@@ -1,339 +1,32 @@
-function cb(editMode){
+(function(items){
- window.onbeforeunload = function(){return "";};
+ var edition = new BookmarkEdition(items), ctx = edition.ctx;
+ items = edition.items;
- var isMobile = mg.isMobile,
- st = getSt(editMode),
- editorEl = $("#txtDescription"),
- combo = $(".js-data-example-ajax"),
- frm = $("#frmBookmarkEdit").submit(function(e){
- st.save.call(this, e);
- });
-
- universal();
- if(isMobile){
- mobile();
- }else{
- web();
- }
- var originalData = JSON.stringify(getFormData());
-
- function web(){
-
- var ed = editorEl.markdownEditor({
- preview: true,
- theme: "ace/theme/tomorrow_night",
- onPreview: function (content, callback) {
- callback(parseCode(content, callback));
- $(".md-preview a").not('.skipped').click(function(e){
- e.stopPropagation();
- this.target = "_blank";
- });
- }
- }),
- session = ed.editor.getSession();
- session.setUseSoftTabs(false);
- session.setTabSize(2);
- ed.focus(function(){
- ed.editor.focus();
- });
- if(editMode){
- ed.find(".btn-preview").trigger("click");
- }
- }
-
- function mobile(){
- var text = editorEl.text();
- editorEl.empty();
- editorEl.append(getMobileEditor("text-editor", "editor-preview", "btn-visualize", "btn-edit", "btn-fullscren", "btn-linewrap", text, false));
-
- var editorMb = $(".mobile-full-screen-modal");
- editorMb.html(getMobileEditor("editor-mb", "editor-preview", "btn-visualize-mb", "btn-edit-mb", "btn-fullscren-mb", "btn-linewrap", text, true));
-
- $("#text-editor").height(($(window).height() - $(".header-editor-container").height()) + "px");
-
- $(".btn-fullscren").click(function(){
- editorMb.show();
- window.modalCloseClick = true;
- $('#modal').modal('toggle');
- });
- $(".btn-fullscren-mb").click(function(){
- $("#text-editor").val($("#editor-mb").val());
- $('#modal').modal('toggle');
- editorMb.hide();
- });
- $('.btn-bk-save').click(function(e){
- var mbText = $("#editor-mb").val();
- $("#text-editor").val(mbText);
- st.save.call(this, e);
- });
- }
-
- function universal(){
-
- $("body").on('click', '.close', function(){
- window.modalCloseClick = true;
- });
-
- combo.select2({
- tags: true, tokenSeparators: [',', '\t', ' '],
- ajax: {
- url: "/api/tag/search",
- dataType: 'json',
- delay: 340,
- data: function (params) {
- return {
- q: params.term,
- page: params.page
- };
- },
- processResults: function (data, page) {
- return {
- results: data.map(function(o){
- o.text = o.name;
- o.id = o.name;
- return o;
- })
- };
- },
- cache: true
- }
- });
- combo.val(tagsToEdit).trigger("change");
- var i = combo.next().find(".select2-selection ul");
- i.mousedown(function(){
- this.hasClick = true;
- });
- i.focus(function(e){
- if(!this.hasClick){
- combo.select2("open");
- }
- this.hasClick = false;
- });
- i.attr("tabindex", '3');
-
- setTimeout(function(){
- $(".btn-fullscren").trigger("click");
- $('#editor-mb').trigger('focus').selectRange(0).scrollTop(0);
- }, 200);
-
- mg.modal.close(function(){
- console.debug('m=modal-close-cb, modalCloseClicked=%s', window.modalCloseClick);
- if(!window.modalCloseClick){
- if((!editMode && getEditorValue())){
- frm.trigger("submit");
- }else if(editMode){
- if(originalData != JSON.stringify(getFormData())){
- console.debug('m=save-trigger, status=different-values, original=%s, current=%s', originalData, JSON.stringify(getFormData()));
- frm.trigger("submit");
- }
- }
- }
- window.modalCloseClick = false;
- });
-
- }
-
- /*
- Mount mobile panel
- */
- function getMobileEditor(editorId, editorPreviewSlc, btnVisualizeSlc, btnEditSlc, btnFullScreenSlc, btnLineWrap, text, fullscreen){
- var editorPanel = $('
'),
- btnEditorPanel = $('');
-
- editorPanel.append(btnEditorPanel);
- btnEditorPanel.append('');
- btnEditorPanel.append(' ');
- btnEditorPanel.append('');
- btnEditorPanel.append(' ');
- btnEditorPanel.append('');
- btnEditorPanel.append(' ');
- btnEditorPanel.append('');
- btnEditorPanel.append(' ');
- btnEditorPanel.append('');
- if(fullscreen){
- btnEditorPanel.append('');
+ items.editorPanel = items.editor.markdownEditor({
+ preview: true,
+ theme: "ace/theme/tomorrow_night",
+ onPreview: function (content, callback) {
+ callback(parseCode(content, callback));
}
- editorPanel.append('');
-
- var editor = editorPanel.find("#" + editorId);
- var btnVisualize = btnEditorPanel.find("." + btnVisualizeSlc);
- var btnLineWrap = btnEditorPanel.find("." + btnLineWrap);
- var btnEdit = btnEditorPanel.find("." + btnEditSlc);
-
-
- editor.val(text);
-
- btnEdit.click(function(){
- $(".btn-edit-common").addClass("active");
- $(".btn-visualize-common").removeClass("active");
- $(".editor-common").show();
- $("." + editorPreviewSlc).hide();
- }).trigger("click");
-
- btnVisualize.click(function(){
- $(".btn-edit-common").removeClass("active");
- $(".btn-visualize-common").addClass("active");
- $("." + editorPreviewSlc).html(parseCode(editor.val()));
-
- $(".editor-common").hide();
- $("." + editorPreviewSlc).show();
- });
-
- btnLineWrap.click(function(){
-
- if(editor.hasClass("line-wrap-on")){
- editor.removeClass("line-wrap-on")
- editor.addClass("line-wrap-off")
- }else{
- editor.removeClass("line-wrap-off")
- editor.addClass("line-wrap-on")
- }
- $(this).toggleClass("png-active");
-
- });
-
- btnEditorPanel.find('.btn-fullscren-common').bind('click', function(){
- $(".btn-fullscren-common").toggleClass("active");
- $("." + editorPreviewSlc).html(parseCode(editor.val()));
- $(".editor-common").val(editor.val());
- });
-
- btnEditorPanel.find('.btn-tab').click(function(e){
- e.preventDefault();
- mg.insertAtCaret('#' + editorId, '\t');
- })
-
- return editorPanel;
- }
-
+ });
- function getFormData(){
- var data = $("#frmBookmarkEdit").serializeArray();
- data.push({
- name: "html",
- value: getEditorValue()
- });
- return data;
- }
- function getEditorValue(){
- var mobileValue = $("#text-editor").val(), value = $("#txtDescription").markdownEditor('content');
- console.debug('m=getEditorValue, isMobile=%s', isMobile);
- if(isMobile){
- return mobileValue;
- }
- return value;
- }
- function setEditorValue(val){
- return $("#txtDescription").markdownEditor('setContent', val);
- }
- function successEvent(editMode){
- if(editMode)
- mg.notify.info('Bookmark salvo com sucesso');
- else
- mg.notify.success('Bookmark cadastrado com sucesso');
+ items.preview = $(".md-preview");
+ items.btnVisualize = items.editorPanel.find(".btn-preview");
- refreshBookmarkList();
+ edition.getEditorValue = function(){
+ console.debug('m=getEditorValue');
+ return this.items.editor.markdownEditor('content');
}
- function getSt(editMode){
-
- // public link
- $("#visible").change(function(){
- var formData = getFormData();
- var linkSpan = $(".public-link");
- if(this.checked && editMode){
- linkSpan.html('bookmark');
- } else {
- linkSpan.html('bookmark');
- }
- }).trigger('change');
-
- var title = mg.modal.modal().find(".title");
- if(editMode){
- title.html("Edit");
- }else{
- title.html("New");
- }
- return editMode ? {
- save: function(e){
- var submitBtn = $("#frmBookmarkEdit *[type=submit]")
- .prop("disabled", true);
- e.preventDefault();
- $.ajax({
- url: "/api/bookmark",
- type: 'POST',
- data: getFormData(),
- success: function () {
- successEvent(1);
- console.debug("editado");
- originalData = JSON.stringify(getFormData());
- }
- }).always(function(){
- submitBtn.prop("disabled", false);
- })
- }
- } : {
- save: function(e){
- e.preventDefault();
- var submitBtn = $("#frmBookmarkEdit *[type=submit]")
- .prop("disabled", true);
+ edition.setup();
- $.ajax({
- url: "/api/bookmark",
- type: 'PUT',
- data: getFormData(),
- success: function (id) {
- st = getSt(editMode = true);
- console.debug("cadastrado");
- frm.prop("id").value = id;
- successEvent();
- originalData = JSON.stringify(getFormData());
- }
- }).always(function(){
- submitBtn.prop("disabled", false);
- })
- }
- };
- };
-
- $('body').off('click', '.painel-acoes li .toggle-scroll').on('click', '.painel-acoes li .toggle-scroll', function(e){
- $(this).parent().toggleClass("active");
- $(this).parents(".mg-code").find('pre').toggleClass("with-scroll");
- e.preventDefault();
- e.stopPropagation();
+ var session = items.editorPanel.editor.getSession();
+ session.setUseSoftTabs(false);
+ session.setTabSize(2);
+ items.editorPanel.focus(function(){
+ items.editorPanel.editor.focus();
});
-// if you change here maybe also want to change src/controller/BookmarkController.js#306
-var languagesMap = null;
-function parseCode(content){
-
- if(languagesMap == null){
- languagesMap = {};
- hljs.listLanguages().forEach(lang => languagesMap[lang] = true)
- }
- var renderer = new marked.Renderer();
- renderer.code = function(code, lang){
- var parsedCode = languagesMap[lang] ? hljs.highlight(lang, code) : {value: code, plain: true}; // MG-40 hljs.highlightAuto(code) it is slow (1-2 seconds to parse)
- return Mustache.render($('#tplCodeBlock').html(), {
- lang: lang, code: parsedCode.value, plain: parsedCode.plain,
- overflown: parsedCode.value.split(/\r\n|\r|\n/).length > 7
- });
- }
- renderer.table = function(header, body) {
- return '\n'
- + '\n'
- + header
- + '\n'
- + '\n'
- + body
- + '\n'
- + '
\n';
- }
-
- return marked(content, {
- renderer: renderer
- })
-}
-};cb($(".ctBookmarkNew").data("edit-mode"));
+})(new function(){});
diff --git a/public/js/ct/bookmarkEditCommon.js b/public/js/ct/bookmarkEditCommon.js
new file mode 100644
index 0000000..aeff05b
--- /dev/null
+++ b/public/js/ct/bookmarkEditCommon.js
@@ -0,0 +1,154 @@
+function BookmarkEdition(items){
+ this.items = items = Object.assign(this.getItems(), items);
+ this.ctx = {
+ editMode: items.form.data('edit-mode')
+ };
+}
+
+BookmarkEdition.prototype.setup = function(){
+
+ var items = this.items, that = this;
+ var ctx = this.ctx;
+
+ items.btnCloseEditor.on('dblclick' + (mg.defaults.debug ? ' click' : ''), function(){
+ console.debug('closing');
+ items.modal.addClass("hidden");
+ });
+
+ // tag search
+ var combo = $(".js-data-example-ajax")
+ combo.select2({
+ tags: true, tokenSeparators: [',', '\t', ' '],
+ ajax: {
+ url: "/api/tag/search",
+ dataType: 'json',
+ delay: 340,
+ data: function (params) {
+ return {
+ q: params.term,
+ page: params.page
+ };
+ },
+ processResults: function (data, page) {
+ return {
+ results: data.map(function(o){
+ o.text = o.name;
+ o.id = o.name;
+ return o;
+ })
+ };
+ },
+ cache: true
+ }
+ })
+
+ combo.val(tagsToEdit).trigger("change");
+ var i = combo.next().find(".select2-selection ul");
+ i.mousedown(function(){
+ this.hasClick = true;
+ });
+ i.focus(function(e){
+ if(!this.hasClick){
+ combo.select2("open");
+ }
+ this.hasClick = false;
+ });
+ i.attr("tabindex", '3');
+
+ if(ctx.editMode){
+ items.btnVisualize.trigger("click");
+ editionMode();
+ }
+
+ items.form.submit(function(e){
+
+ e.preventDefault();
+ var submitBtn = items.form.find("*[type=submit]").prop("disabled", true);
+ (ctx.editMode ? function(e){
+
+ e.preventDefault();
+ $.ajax({
+ url: "/api/bookmark",
+ type: 'POST',
+ data: that.getFormData(),
+ success: function () {
+ successEvent(true);
+ editionMode();
+ console.debug("editado");
+ }
+ }).always(function(){
+ submitBtn.prop("disabled", false);
+ })
+ } : function(e){
+
+ $.ajax({
+ url: "/api/bookmark",
+ type: 'PUT',
+ data: that.getFormData(),
+ success: function (id) {
+ console.debug("cadastrado");
+ items.form.prop("id").value = id;
+ successEvent(false);
+
+ items.btnFullScreen.trigger("click");
+ editionMode();
+ }
+ }).always(function(){
+ submitBtn.prop("disabled", false);
+ })
+ })(e)
+ });
+
+ items.preview.find("a").not('.skipped').on('click', function(e){
+ e.stopPropagation();
+ this.target = "_blank";
+ });
+
+ function editionMode(){
+
+ ctx.editMode = true;
+ var formData = that.getFormData();
+
+ if(items.iptVisible.prop("checked")){
+ items.btnLink.removeClass('hidden');
+ items.btnLink.prop("href", '/bookmark/' + formData[0].value + '/' + (formData[1].value.replace(/\s/g, '-')))
+ }else{
+ items.btnLink.addClass('hidden');
+ }
+ }
+
+ function successEvent(editMode){
+ if(editMode)
+ mg.notify.info('Bookmark salvo com sucesso');
+ else
+ mg.notify.success('Bookmark cadastrado com sucesso');
+
+ refreshBookmarkList();
+ }
+}
+
+BookmarkEdition.prototype.getFormData = function(){
+ var data = this.items.form.serializeArray();
+ data.push({
+ name: "html",
+ value: this.getEditorValue()
+ });
+ return data;
+}
+
+BookmarkEdition.prototype.getEditorValue = function(){
+ return this.items.editor.val();
+}
+
+BookmarkEdition.prototype.getItems = function getItems(){
+ return new function(){
+ this.editor = $("#md-editor")
+ this.preview = $(".editor-preview")
+ this.form = $("#bookmarkForm")
+ this.modal = $(".modal-editor")
+ this.btnCloseEditor = this.modal.find(".btn-close-modal")
+ this.linkContainer = this.modal.find(".link-container")
+ this.btnLink = this.modal.find(".btn-public-link")
+ this.iptVisible = this.form.find("#visible")
+ }
+}
diff --git a/public/js/ct/bookmarkHome.js b/public/js/ct/bookmarkHome.js
index 5f8388e..c8dd229 100644
--- a/public/js/ct/bookmarkHome.js
+++ b/public/js/ct/bookmarkHome.js
@@ -51,7 +51,11 @@ $(window).resize(function(){
})
$(".bookmarkNew").click(function(e){
- mg.popUpScreen("/bookmark/new");
+ if(mg.isMobile){
+ mg.popUpScreen2("/mobile/bookmark/new");
+ }else{
+ mg.popUpScreen2("/bookmark/new");
+ }
});
function adaptarTamanhoMenu(){
@@ -123,7 +127,7 @@ function populaTabela(data){
function abrirTelaEdicao(e){
var that = $(this);
if(this == e.target || that.hasClass("divItemBody") || that.hasClass("divItemHead")){
- mg.popUpScreen("/bookmark/edit", {
+ mg.popUpScreen2(mg.isMobile ? "/mobile/bookmark/edit" : "/bookmark/edit", {
data: {
id: that.parents(".divItem").data("id"),
editMode: true
diff --git a/public/js/ct/main.js b/public/js/ct/main.js
new file mode 100644
index 0000000..b91e25d
--- /dev/null
+++ b/public/js/ct/main.js
@@ -0,0 +1,35 @@
+// if you change here maybe also want to change src/controller/BookmarkController.js#306
+var languagesMap = null;
+function parseCode(content){
+
+ console.debug('m=parseCode, length=%s', content.length)
+ if(languagesMap == null){
+ languagesMap = {};
+ hljs.listLanguages().forEach(lang => languagesMap[lang] = true)
+ }
+ var renderer = new marked.Renderer();
+ renderer.code = function(code, lang){
+ console.debug('onparse=begin, code=%s, lang=%s', code, lang)
+ var parsedCode = languagesMap[lang] ? hljs.highlight(lang, code) : {value: code, plain: true}; // MG-40 hljs.highlightAuto(code) it is slow (1-2 seconds to parse)
+ console.debug('onparse=parsed, parsedCode=%o', parsedCode)
+ return Mustache.render($('#tplCodeBlock-2').html(), {
+ lang: lang, code: parsedCode.value, plain: parsedCode.plain,
+ overflown: parsedCode.value.split(/\r\n|\r|\n/).length > 7
+ });
+ }
+ renderer.table = function(header, body) {
+ return '\n'
+ + '\n'
+ + header
+ + '\n'
+ + '\n'
+ + body
+ + '\n'
+ + '
\n';
+ }
+
+ console.debug('parsing, ',marked(content, {renderer: renderer}));
+ return marked(content, {
+ renderer: renderer
+ })
+}
diff --git a/public/js/ct/mobile/bookmarkEdit.js b/public/js/ct/mobile/bookmarkEdit.js
new file mode 100644
index 0000000..7a720c9
--- /dev/null
+++ b/public/js/ct/mobile/bookmarkEdit.js
@@ -0,0 +1,64 @@
+(function(items){
+
+ var edition = new BookmarkEdition(items), ctx = edition.ctx;
+ items = edition.items;
+
+ items.btnTab.click(function(e){
+ e.preventDefault();
+ mg.insertAtCaret(items.editor.get(0), '\t');
+ });
+
+ items.btnFullScreen.click(function(){
+ $(".fields").slideToggle();
+ $(this).toggleClass("active");
+ })
+
+ items.btnEditor.click(function(){
+
+ items.btnEditor.addClass("active");
+ items.btnVisualize.removeClass("active");
+
+ items.editor.removeClass("hidden");
+ items.preview.addClass("hidden");
+
+ })
+
+ items.btnVisualize.click(function(){
+
+ items.btnEditor.removeClass("active");
+ items.btnVisualize.addClass("active");
+
+ items.editor.addClass("hidden");
+ items.preview.removeClass("hidden").html(parseCode(items.editor.val()))
+ })
+
+ items.btnLineWrap.click(function(){
+
+ if(items.editor.hasClass("line-wrap-on")){
+ items.editor.removeClass("line-wrap-on")
+ items.editor.addClass("line-wrap-off")
+ }else{
+ items.editor.removeClass("line-wrap-off")
+ items.editor.addClass("line-wrap-on")
+ }
+ $(this).toggleClass("png-active");
+
+ });
+
+ edition.setup();
+ if(ctx.editMode){
+ items.btnFullScreen.trigger("click");
+ }else{
+ console.log(items.editor);
+ items.editor.trigger("focus");
+ }
+
+
+})(new function(){
+ this.modal = $(".modal-editor")
+ this.btnEditor = $(".btn-edit")
+ this.btnVisualize = $(".btn-visualize")
+ this.btnFullScreen = $(".btn-fullscreen")
+ this.btnLineWrap = this.modal.find(".btn-linewrap")
+ this.btnTab = this.modal.find(".btn-tab")
+});
diff --git a/src/controller/BookmarkController.js b/src/controller/BookmarkController.js
index 5e174ee..601f1bd 100644
--- a/src/controller/BookmarkController.js
+++ b/src/controller/BookmarkController.js
@@ -180,6 +180,64 @@ module.exports.controller = function(app) {
});
});
+ app.get('/bookmark/edit', function(req, res) {
+ var query = url.parse(req.url, true).query;
+ m.getBookmarkById(query.id, function(err, bookmark){
+ mTag.getTagsByBoomarkId(query.id, function(err, tags){
+ res.render('bookmarkEdit', {
+ layout: false,
+ bookmark: bookmark,
+ tags: tags,
+ editMode: query.editMode,
+ stringify: function(){
+ return function(val, render){
+ return JSON.stringify(this.tags.map(function(tag){
+ return tag.name;
+ }));
+ }
+ },
+ getVisibilityFlag: getVisibilityFlag
+ });
+ });
+ });
+ });
+
+
+ app.get('/mobile/bookmark/new', function(req, res) {
+ res.render('mobile/bookmarkEdit', {
+ layout: false,
+ stringify: function(){
+ return function(){
+ return '[]';
+ }
+ },
+ getVisibilityFlag: getVisibilityFlag
+ });
+ });
+
+ app.get('/mobile/bookmark/edit', function(req, res) {
+ var query = url.parse(req.url, true).query;
+ m.getBookmarkById(query.id, function(err, bookmark){
+ mTag.getTagsByBoomarkId(query.id, function(err, tags){
+ res.render('mobile/bookmarkEdit', {
+ layout: false,
+ bookmark: bookmark,
+ tags: tags,
+ editMode: query.editMode,
+ stringify: function(){
+ return function(val, render){
+ return JSON.stringify(this.tags.map(function(tag){
+ return tag.name;
+ }));
+ }
+ },
+ getVisibilityFlag: getVisibilityFlag
+ });
+ });
+ });
+ });
+
+
/**
* Public bookmark view
*/
@@ -232,28 +290,6 @@ module.exports.controller = function(app) {
});
});
- app.get('/bookmark/edit', function(req, res) {
- var query = url.parse(req.url, true).query;
- m.getBookmarkById(query.id, function(err, bookmark){
- mTag.getTagsByBoomarkId(query.id, function(err, tags){
- res.render('bookmarkEdit', {
- layout: false,
- bookmark: bookmark,
- tags: tags,
- editMode: query.editMode,
- stringify: function(){
- return function(val, render){
- return JSON.stringify(this.tags.map(function(tag){
- return tag.name;
- }));
- }
- },
- getVisibilityFlag: getVisibilityFlag
- });
- });
- });
- });
-
function associarTagsBookmarks(app,req, res,id, editMode){
if(editMode){
try{
diff --git a/src/controller/TesteController.js b/src/controller/TesteController.js
deleted file mode 100644
index aceaf7c..0000000
--- a/src/controller/TesteController.js
+++ /dev/null
@@ -1,5 +0,0 @@
-module.exports.controller = function(app){
- app.get("/nova-grid", function(req, res){
- res.render('test/nova-grid');
- });
-}
\ No newline at end of file
diff --git a/view/bookmarkEdit.html b/view/bookmarkEdit.html
index d3257f1..afe8230 100644
--- a/view/bookmarkEdit.html
+++ b/view/bookmarkEdit.html
@@ -1,65 +1,58 @@
-