TagSpaces is an offline, open source, document manager with tagging support
bootstraping dialogs
uggrockef479befd6f6
diff --git a/data/ext/perspectiveRiver/extension.js b/data/ext/perspectiveRiver/extension.jsindex 865e8e2f0..26d40d2a6 100644--- a/data/ext/perspectiveRiver/extension.js+++ b/data/ext/perspectiveRiver/extension.js@@ -75,8 +75,7 @@ define(function(require, exports, module) {var initButtons = function() {$( "#"+exports.ID+"CreateFileButton" ).click(function() {- $( "#dialog-filecreate" ).dialog( "open" );+ TSCORE.showFileCreateDialog();});}-});\ No newline at end of filediff --git a/data/ext/perspectiveThumb/extension.js b/data/ext/perspectiveThumb/extension.jsindex aca8510f1..2232b68a8 100644--- a/data/ext/perspectiveThumb/extension.js+++ b/data/ext/perspectiveThumb/extension.js@@ -40,7 +40,7 @@ define(function(require, exports, module) {.append( $("<i>", { class: "icon-file", }) ).append("New").click(function() {- $( "#dialog-filecreate" ).dialog( "open" );+ TSCORE.showFileCreateDialog();}));diff --git a/data/index.html b/data/index.htmlindex ec447f028..e213c8009 100644--- a/data/index.html+++ b/data/index.html@@ -72,7 +72,7 @@</div></div><div id="helpers" style="display: none;">- <div id="dialog-filecreate" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div id="dialogFileCreate" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" ><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4>Create new file</h4>@@ -274,59 +274,110 @@</div></div>+ <div id="dialogAddTags" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Add Tags</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div class="control-group">+ <label class="control-label" for="tags">Comma separated list of the tags</label>+ <div class="controls">+ <input type="text" name="tags" id="tags" />+ </div>+ </div>+ </form>+ </div>+ <div class="modal-footer">+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button id="addTagsButton" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>+ </div>+ </div>- <div id="dialogAddTags" title="Add Tags">- <p class="validateTips">All form fields are required.</p>- <form action="javascript:void(0);">- <fieldset>- <label for="tags">Comma separated list of the tags</label>- <input type="text" name="tags" id="tags" />- </fieldset>- </form>- </div>+ <div id="dialogEditInTreeTag" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Edit Tag</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div class="control-group">+ <label class="control-label" for="tagInTreeName">Tag Name</label>+ <div class="controls">+ <input type="text" name="tagInTreeName" id="tagInTreeName" />+ </div>+ </div>+ </form>+ </div>+ <div class="modal-footer">+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button id="editTagInTreeButton" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>+ </div>+ </div>++ <div id="dialogTagCreate" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Create Tag</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div class="control-group">+ <label class="control-label" for="newTagTitle">Tag Name</label>+ <div class="controls">+ <input type="text" name="newTagTitle" id="newTagTitle" />+ </div>+ </div>+ </form>+ </div>+ <div class="modal-footer">+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button id="createTagButton" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>+ </div>+ </div>- <div id="dialog-tagedit" title="Edit Tag">- <p class="validateTips">All form fields are required.</p>- <form action="javascript:void(0);">- <fieldset>- <label for="name">Name</label>- <input type="text" name="name" id="tagName" />- </fieldset>- </form>- </div>+ <div id="dialogEditTagGroup" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Edit TagGroup</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div class="control-group">+ <label class="control-label" for="tagGroupName">TagGroup Name</label>+ <div class="controls">+ <input type="text" name="tagGroupName" id="tagGroupName" />+ </div>+ </div>+ </form>+ </div>+ <div class="modal-footer">+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button id="editTagGroupButton" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>+ </div>+ </div>- <div id="dialog-tagcreate" title="Create tag">- <p class="validateTips">All form fields are required.</p>- <form action="javascript:void(0);">- <fieldset>- <label for="name">Name</label>- <input type="text" name="name" id="newTagName" />- </fieldset>- </form>- </div>-- <div id="dialog-taggroupEdit" title="Edit Taggroup">- <p class="validateTips">All form fields are required.</p>- <form action="javascript:void(0);">- <fieldset>- <label for="name">Name</label>- <input type="text" name="name" id="tagGroupName" />- </fieldset>- </form>- </div>-- <div id="dialog-taggroupCreate" title="Create Taggroup">- <p class="validateTips">All form fields are required.</p>- <form action="javascript:void(0);">- <fieldset>- <p>- <label for="name">Name</label>- <input type="text" name="name" id="newTagGroupName" />- </p>- </fieldset>- </form>- </div>-+ <div id="dialogTagGroupCreate" class="modal hide" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true" >+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>+ <h4>Create TagGroup</h4>+ </div>+ <div class="modal-body">+ <form class="form-horizontal">+ <div class="control-group">+ <label class="control-label" for="newTagGroupName">TagGroup Name</label>+ <div class="controls">+ <input type="text" name="newTagGroupName" id="newTagGroupName" />+ </div>+ </div>+ </form>+ </div>+ <div class="modal-footer">+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>+ <button id="createTagGroupButton" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>+ </div>+ </div><ul id="favoritesList" class="dropdown-menu"></ul>diff --git a/data/js/core.api.js b/data/js/core.api.jsindex 16d95e129..f753ba2af 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -286,6 +286,10 @@ define(function(require, exports, module) {exports.generateTagButtons = tsTagsUI.generateTagButtons;exports.openTagMenu = tsTagsUI.openTagMenu;exports.showAddTagsDialog = tsTagsUI.showAddTagsDialog;+ exports.showTagEditInTreeDialog = tsTagsUI.showTagEditInTreeDialog;+ exports.showDialogTagCreate = tsTagsUI.showDialogTagCreate;+ exports.showDialogEditTagGroup = tsTagsUI.showDialogEditTagGroup;+ exports.showDialogTagGroupCreate = tsTagsUI.showDialogTagGroupCreate;// Proxying functions from directoriesUIexports.updateSubDirs = tsDirectoriesUI.updateSubDirs;diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 009e8deed..67fc4d7f3 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -76,7 +76,7 @@ define(function(require, exports, module) {var showFileCreateDialog = function() {fileContent = TSCORE.Config.getNewTextFileContent(); // Default new file in text file$( "#newFileName" ).val(".txt");- $( '#dialog-filecreate' ).modal({show: true});+ $( '#dialogFileCreate' ).modal({show: true});$( '#txtFileTypeButton' ).button('toggle');}diff --git a/data/js/tags.ui.js b/data/js/tags.ui.jsindex 39debf3a5..a40d773d7 100644--- a/data/js/tags.ui.js+++ b/data/js/tags.ui.js@@ -43,8 +43,7 @@ define(function(require, exports, module) {});$( "#tagTreeMenuEditTag" ).click( function() {- $( "#tagName" ).val(TSCORE.selectedTag);- $( "#dialog-tagedit" ).dialog( "open" );+ TSCORE.showTagEditInTreeDialog();});$( "#tagTreeMenuDeleteTag" ).click( function() {@@ -60,12 +59,11 @@ define(function(require, exports, module) {// Context menu for the tags groups$( "#tagGroupMenuCreateNewTag" ).click( function() {- $( "#newTagName" ).val("");- $( "#dialog-tagcreate" ).dialog( "open" );+ TSCORE.showDialogTagCreate();});$( "#tagGroupMenuCreateTagGroup" ).click( function() {- $( "#dialog-taggroupCreate" ).dialog( "open" );+ TSCORE.showDialogTagGroupCreate();});$( "#tagGroupMenuMoveUp" ).click( function() {@@ -79,8 +77,7 @@ define(function(require, exports, module) {});$( "#tagGroupMenuEditTagGroup" ).click( function() {- $( "#tagGroupName" ).val(TSCORE.selectedTagData.title);- $( "#dialog-taggroupEdit" ).dialog( "open" );+ TSCORE.showDialogEditTagGroup();});$( "#tagGroupMenuDeleteTagGroup" ).click( function() {@@ -96,137 +93,30 @@ define(function(require, exports, module) {}function initDialogs() {- $( "#dialog-tagedit" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Save": function() {- TSCORE.Config.editTag(TSCORE.selectedTagData, $( "#tagName" ).val() )- generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialog-tagcreate" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Create Tag": function() {- TSCORE.Config.createTag(TSCORE.selectedTagData, $( "#newTagName" ).val() )- generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- open: function() {- $( "#newTagName" ).val("");- }- });-- $( "#dialog-taggroupCreate" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Create": function() {- TSCORE.Config.createTagGroup(TSCORE.selectedTagData, $( "#newTagGroupName" ).val() )- generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- open: function() {- $( "#newTagGroupName" ).val("");- }- });-- $( "#dialog-taggroupEdit" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Save": function() {- TSCORE.Config.editTagGroup(TSCORE.selectedTagData, $( "#tagGroupName" ).val() )- generateTagGroups();- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- }- });-- $( "#dialogAddTags" ).dialog({- autoOpen: false,- resizable: false,- height:240,- modal: true,- buttons: {- "Add tags": function() {- var tags = $("#tags").val().split(",");- TSCORE.TagUtils.addTag(TSCORE.selectedFiles, tags);- $( this ).dialog( "close" );- },- Cancel: function() {- $( this ).dialog( "close" );- }- },- open: function() {-- function split( val ) {- return val.split( /,\s*/ );- }- function extractLast( term ) {- return split( term ).pop();- }-- $( "#tags" )- // don't navigate away from the field on tab when selecting an item- .bind( "keydown", function( event ) {- if ( event.keyCode === $.ui.keyCode.TAB &&- $( this ).data( "autocomplete" ).menu.active ) {- event.preventDefault();- }- })- .autocomplete({- minLength: 0,- source: function( request, response ) {- // delegate back to autocomplete, but extract the last term- response( $.ui.autocomplete.filter(- TSCORE.Config.getAllTags(), extractLast( request.term ) ) );- },- focus: function() {- // prevent value inserted on focus- return false;- },- select: function( event, ui ) {- var terms = split( this.value );- // remove the current input- terms.pop();- // add the selected item- terms.push( ui.item.value );- // add placeholder to get the comma-and-space at the end- terms.push( "" );- this.value = terms.join( ", " );- return false;- }- });- }- });+ $( "#editTagInTreeButton" ).click( function() {+ TSCORE.Config.editTag(TSCORE.selectedTagData, $( "#tagInTreeName" ).val() )+ generateTagGroups();+ });++ $( "#addTagsButton" ).click( function() {+ var tags = $("#tags").val().split(",");+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, tags);+ });++ $( "#createTagButton" ).click( function() {+ TSCORE.Config.createTag(TSCORE.selectedTagData, $( "#newTagTitle" ).val() )+ generateTagGroups();+ });++ $( "#createTagGroupButton" ).click( function() {+ TSCORE.Config.createTagGroup(TSCORE.selectedTagData, $( "#newTagGroupName" ).val() )+ generateTagGroups();+ });++ $( "#editTagGroupButton" ).click( function() {+ TSCORE.Config.editTagGroup(TSCORE.selectedTagData, $( "#tagGroupName" ).val() )+ generateTagGroups();+ });}function generateTagGroups() {@@ -367,13 +257,71 @@ define(function(require, exports, module) {}return wrapper.html();}-- var showAddTagsDialog = function() {+ function showDialogTagCreate() {+ $( "#newTagTitle" ).val("");+ $( '#dialogTagCreate' ).modal({show: true});+ }++ function showDialogEditTagGroup() {+ $( "#tagGroupName" ).val(TSCORE.selectedTagData.title);+ $( '#dialogEditTagGroup' ).modal({show: true});+ }++ function showDialogTagGroupCreate() {+ $( "#newTagGroupName" ).val("");+ $( '#dialogTagGroupCreate' ).modal({show: true});+ }++ function showTagEditInTreeDialog() {+ $( "#tagInTreeName" ).val(TSCORE.selectedTagData.title);+ $( '#dialogEditInTreeTag' ).modal({show: true});+ }++ function showAddTagsDialog() {console.debug("Adding tags...");+ function split( val ) {+ return val.split( /,\s*/ );+ }+ function extractLast( term ) {+ return split( term ).pop();+ }++ $( "#tags" )+ // don't navigate away from the field on tab when selecting an item+ .bind( "keydown", function( event ) {+ if ( event.keyCode === $.ui.keyCode.TAB &&+ $( this ).data( "autocomplete" ).menu.active ) {+ event.preventDefault();+ }+ })+ .autocomplete({+ minLength: 0,+ source: function( request, response ) {+ // delegate back to autocomplete, but extract the last term+ response( $.ui.autocomplete.filter(+ TSCORE.Config.getAllTags(), extractLast( request.term ) ) );+ },+ focus: function() {+ // prevent value inserted on focus+ return false;+ },+ select: function( event, ui ) {+ var terms = split( this.value );+ // remove the current input+ terms.pop();+ // add the selected item+ terms.push( ui.item.value );+ // add placeholder to get the comma-and-space at the end+ terms.push( "" );+ this.value = terms.join( ", " );+ return false;+ }+ });+$("#tags").val("");- $( "#dialogAddTags" ).dialog( "open" );- }+ $( '#dialogAddTags' ).modal({show: true});+ }// Public API definitionexports.initContextMenus = initContextMenus;@@ -382,5 +330,9 @@ define(function(require, exports, module) {exports.openTagMenu = openTagMenu;exports.generateTagButtons = generateTagButtons;exports.showAddTagsDialog = showAddTagsDialog;+ exports.showTagEditInTreeDialog = showTagEditInTreeDialog;+ exports.showDialogTagCreate = showDialogTagCreate;+ exports.showDialogEditTagGroup = showDialogEditTagGroup;+ exports.showDialogTagGroupCreate = showDialogTagGroupCreate;});\ No newline at end of file