parent
82ea26f827
commit
3bc4cc8291
|
|
@ -220,8 +220,10 @@ if(isDisabled){button.disable()}
|
|||
return button.text(submitLabel).build()}
|
||||
function replaceButton(){var buttonElement=buildButton();KB.dom(submitButtonElement).replace(buttonElement);submitButtonElement=buttonElement}
|
||||
this.render=function(){KB.on('modal.stop',onStop);KB.on('modal.disable',onDisable);KB.on('modal.enable',onEnable);KB.on('modal.hide',onHide);KB.on('modal.submit.label',onUpdateSubmitLabel);KB.on('modal.close',function(){KB.removeListener('modal.stop',onStop);KB.removeListener('modal.disable',onDisable);KB.removeListener('modal.enable',onEnable);KB.removeListener('modal.hide',onHide);KB.removeListener('modal.submit.label',onUpdateSubmitLabel)});submitButtonElement=buildButton();var formActionElementBuilder=KB.dom('div').attr('class','form-actions').add(submitButtonElement);if(KB.modal.isOpen()){formActionElementBuilder.text(' '+options.orLabel+' ').add(KB.dom('a').attr('href','#').click(onCancel).text(options.cancelLabel).build())}
|
||||
formActionElement=formActionElementBuilder.build();containerElement.appendChild(formActionElement)}});KB.on('dom.ready',function(){function savePosition(subtaskId,position){var url=$(".subtasks-table").data("save-position-url");$.ajax({cache:!1,url:url,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({"subtask_id":subtaskId,"position":position})})}
|
||||
$(".draggable-row-handle").mouseenter(function(){$(this).parent().parent().addClass("draggable-item-hover")}).mouseleave(function(){$(this).parent().parent().removeClass("draggable-item-hover")});$(".subtasks-table tbody").sortable({forcePlaceholderSize:!0,handle:"td:first i",helper:function(e,ui){ui.children().each(function(){$(this).width($(this).width())});return ui},stop:function(event,ui){var subtask=ui.item;subtask.removeClass("draggable-item-selected");savePosition(subtask.data("subtask-id"),subtask.index()+1)},start:function(event,ui){ui.item.addClass("draggable-item-selected")}}).disableSelection()});KB.on('dom.ready',function(){$(document).on('click','.js-subtask-toggle-status',function(e){var el=$(this);var url=el.attr('href');e.preventDefault();$.ajax({cache:!1,url:url,success:function(data){if(url.indexOf('fragment=table')!=-1){$('.subtasks-table').replaceWith(data)}else if(url.indexOf('fragment=rows')!=-1){$(el).closest('.task-list-subtasks').replaceWith(data)}else{$(el).closest('.subtask-title').replaceWith(data)}}})});$(document).on('click','.js-subtask-toggle-timer',function(e){var el=$(this);e.preventDefault();$.ajax({cache:!1,url:el.attr('href'),success:function(data){$(el).closest('.subtask-time-tracking').replaceWith(data)}})})});KB.component('suggest-menu',function(containerElement,options){function onKeyDown(e){switch(KB.utils.getKey(e)){case 'Escape':destroy();break;case 'ArrowUp':e.preventDefault();e.stopImmediatePropagation();moveUp();break;case 'ArrowDown':e.preventDefault();e.stopImmediatePropagation();moveDown();break;case 'Enter':e.preventDefault();e.stopImmediatePropagation();insertSelectedItem();break}}
|
||||
formActionElement=formActionElementBuilder.build();containerElement.appendChild(formActionElement)}});(function(){function savePosition(subtaskId,position){var url=$(".subtasks-table").data("save-position-url");$.ajax({cache:!1,url:url,contentType:"application/json",type:"POST",processData:!1,data:JSON.stringify({"subtask_id":subtaskId,"position":position})})}
|
||||
function bootstrap(){$(".draggable-row-handle").mouseenter(function(){$(this).parent().parent().addClass("draggable-item-hover")}).mouseleave(function(){$(this).parent().parent().removeClass("draggable-item-hover")});$(".subtasks-table tbody").sortable({forcePlaceholderSize:!0,handle:"td:first i",helper:function(e,ui){ui.children().each(function(){$(this).width($(this).width())});return ui},stop:function(event,ui){var subtask=ui.item;subtask.removeClass("draggable-item-selected");savePosition(subtask.data("subtask-id"),subtask.index()+1)},start:function(event,ui){ui.item.addClass("draggable-item-selected")}}).disableSelection()}
|
||||
KB.on('dom.ready',bootstrap);KB.on('subtasks.reloaded',bootstrap)}());KB.on('dom.ready',function(){$(document).on('click','.js-subtask-toggle-status',function(e){var el=$(this);var url=el.attr('href');e.preventDefault();$.ajax({cache:!1,url:url,success:function(data){if(url.indexOf('fragment=table')!=-1){$('.subtasks-table').replaceWith(data)}else if(url.indexOf('fragment=rows')!=-1){$(el).closest('.task-list-subtasks').replaceWith(data)}else{$(el).closest('.subtask-title').replaceWith(data)}
|
||||
KB.trigger('subtasks.reloaded')}})});$(document).on('click','.js-subtask-toggle-timer',function(e){var el=$(this);e.preventDefault();$.ajax({cache:!1,url:el.attr('href'),success:function(data){$(el).closest('.subtask-time-tracking').replaceWith(data)}})})});KB.component('suggest-menu',function(containerElement,options){function onKeyDown(e){switch(KB.utils.getKey(e)){case 'Escape':destroy();break;case 'ArrowUp':e.preventDefault();e.stopImmediatePropagation();moveUp();break;case 'ArrowDown':e.preventDefault();e.stopImmediatePropagation();moveDown();break;case 'Enter':e.preventDefault();e.stopImmediatePropagation();insertSelectedItem();break}}
|
||||
function onClick(){insertSelectedItem()}
|
||||
function onMouseOver(element){if(KB.dom(element).hasClass('suggest-menu-item')){KB.find('.suggest-menu-item.active').removeClass('active');KB.dom(element).addClass('active')}}
|
||||
function insertSelectedItem(){containerElement.focus();var element=KB.find('.suggest-menu-item.active');var value=element.data('value');var trigger=element.data('trigger');var content=containerElement.value;var text=getLastWord(containerElement);var substitute=trigger+value+' ';var selectionPosition=KB.utils.getSelectionPosition(containerElement);var before=content.substring(0,selectionPosition.selectionStart-text.length);var after=content.substring(selectionPosition.selectionEnd);var position=before.length+substitute.length;containerElement.value=before+substitute+after;containerElement.setSelectionRange(position,position);destroy()}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
KB.on('dom.ready', function() {
|
||||
|
||||
(function () {
|
||||
function savePosition(subtaskId, position) {
|
||||
var url = $(".subtasks-table").data("save-position-url");
|
||||
|
||||
|
|
@ -16,29 +15,35 @@ KB.on('dom.ready', function() {
|
|||
});
|
||||
}
|
||||
|
||||
$(".draggable-row-handle").mouseenter(function() {
|
||||
$(this).parent().parent().addClass("draggable-item-hover");
|
||||
}).mouseleave(function() {
|
||||
$(this).parent().parent().removeClass("draggable-item-hover");
|
||||
});
|
||||
function bootstrap() {
|
||||
$(".draggable-row-handle").mouseenter(function() {
|
||||
$(this).parent().parent().addClass("draggable-item-hover");
|
||||
}).mouseleave(function() {
|
||||
$(this).parent().parent().removeClass("draggable-item-hover");
|
||||
});
|
||||
|
||||
$(".subtasks-table tbody").sortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: "td:first i",
|
||||
helper: function(e, ui) {
|
||||
ui.children().each(function() {
|
||||
$(this).width($(this).width());
|
||||
});
|
||||
|
||||
return ui;
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var subtask = ui.item;
|
||||
subtask.removeClass("draggable-item-selected");
|
||||
savePosition(subtask.data("subtask-id"), subtask.index() + 1);
|
||||
},
|
||||
start: function(event, ui) {
|
||||
ui.item.addClass("draggable-item-selected");
|
||||
}
|
||||
}).disableSelection();
|
||||
}
|
||||
|
||||
$(".subtasks-table tbody").sortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: "td:first i",
|
||||
helper: function(e, ui) {
|
||||
ui.children().each(function() {
|
||||
$(this).width($(this).width());
|
||||
});
|
||||
KB.on('dom.ready', bootstrap);
|
||||
KB.on('subtasks.reloaded', bootstrap);
|
||||
}());
|
||||
|
||||
return ui;
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
var subtask = ui.item;
|
||||
subtask.removeClass("draggable-item-selected");
|
||||
savePosition(subtask.data("subtask-id"), subtask.index() + 1);
|
||||
},
|
||||
start: function(event, ui) {
|
||||
ui.item.addClass("draggable-item-selected");
|
||||
}
|
||||
}).disableSelection();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ KB.on('dom.ready', function () {
|
|||
} else {
|
||||
$(el).closest('.subtask-title').replaceWith(data);
|
||||
}
|
||||
KB.trigger('subtasks.reloaded');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue