From: Nenad M. <svn...@pl...> - 2010-06-30 16:49:16
|
Author: manca Date: Wed Jun 30 16:49:08 2010 New Revision: 119968 Modified: Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/js/pfgWidgets.js Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/pfgQuickEdit.js Log: Edit fields titles on the fly... just double click while in quick edit mode Modified: Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/js/pfgWidgets.js ============================================================================== --- Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/js/pfgWidgets.js (original) +++ Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/js/pfgWidgets.js Wed Jun 30 16:49:08 2010 @@ -36,6 +36,8 @@ pfgWidgets.updatePositionOnServer(item, target) } }); + + this.editTitles(); }, getPos: function(node) { @@ -49,6 +51,40 @@ target_id: t }; $.post('reorderField', args) + }, + + editTitles: function() { + // first we create a new dynamic node (which will be used to edit content) + var node = document.createElement("input"); + node.setAttribute('name', "change"); + node.setAttribute("type", "text"); + + // then we attach a new event to label fields + $("label.formQuestion").live('dblclick', function(e) { + e.preventDefault(); + var content = $(this).text(); + var tmpfor = $(this).attr('for'); + $(this).append(node); + $(this).html($(node).val(content)); + $(node).fadeIn(); + $(this).children().unwrap(); + node.focus(); + + $(node).blur(function(e) { + $(this).wrap("<label class='formQuestion' for='"+ tmpfor +"'></label>"); + $(this).parent().html($(this).val()) + var arg = { + item_id: $(this).name, + title: $(this).val() + } + $.post("updateTitle",arg,function() {alert("Sent!")}); + }); + }); + + }, + + deinit: function() { + $("label.formQuestion").die(); // removes even handlers setup by .live } Modified: Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/pfgQuickEdit.js ============================================================================== --- Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/pfgQuickEdit.js (original) +++ Products.PloneFormGen/branches/manca-gsoc/Products/PloneFormGen/skins/PloneFormGen/pfgQuickEdit.js Wed Jun 30 16:49:08 2010 @@ -167,6 +167,7 @@ jQuery("#pfgThanksEdit").hide(); jQuery("#pfgqedit").fadeIn(); location.hash = ""; + pfgWidgets.deinit(); }; jQuery(document).ready(function() { |