/** * Required toolbar functions for the TFSLink plugin * * @author Thorsten Klingert * based on Link Wizard * @author Andreas Gohr * @author Pierre Spring * based on IndexMenu wizard * @author Gerrit Uitslag */ var addworkitemlink_wiz = { $wiz: null, textArea: null, justSyncingSelection: false, init: function($editor) { // position relative to the text area var pos = $editor.position(); // create HTML Structure if (addworkitemlink_wiz.$wiz) return; addworkitemlink_wiz.$wiz = jQuery(document.createElement('div')) .dialog({ autoOpen: false, draggable: true, title: LANG.plugins.tfslink.addlinktitle, resizable: false }) .html( '
'+LANG.plugins.tfslink.attributes+'' + '
' + '
' + '
' + '
'+LANG.plugins.tfslink.projectcollection+'' + '
' + '
' + '
' + '' ) .parent() .attr('id','addworkitemlink__wiz') .css({ 'position': 'absolute', 'top': (pos.top+20)+'px', 'left': (pos.left+80)+'px' }) .hide() .appendTo('.dokuwiki:first'); addworkitemlink_wiz.textArea = $editor[0]; addworkitemlink_wiz.populateProjectCollections(); // attach event handlers jQuery('#workitemid').bind('keydown keyup', function(){ // restrict input to numbers only addworkitemlink_wiz.filterNumberInput(this); }); jQuery("#usedefaultprojectcollection").bind('change', function() { addworkitemlink_wiz.syncProjectCollectionSelections(true); }); jQuery('#projectcollection').bind('change', function () { addworkitemlink_wiz.syncProjectCollectionSelections(false); }); jQuery('#addworkitemlink__insert').click(addworkitemlink_wiz.insertLink); jQuery('#addworkitemlink__wiz').find('.ui-dialog-titlebar-close').click(addworkitemlink_wiz.hide); }, /** * Allow only number, by direct removing other characters from input */ filterNumberInput: function(elem){ if(elem.value.match(/\D/)) { elem.value=this.value.replace(/\D/g,''); } }, /** * Populates the project collections */ populateProjectCollections: function() { var addOptions = function(data) { if (jQuery.isEmptyObject(data)) { // hide project collection options and check 'use default' jQuery('fieldset.projectcollection').hide(); jQuery('#usedefaultprojectcollection').prop('checked', true); return; } jQuery.each(data, function(i, pc){ if (!pc) return; jQuery('#projectcollection').append( jQuery('