Skip to content

Commit

Permalink
- 883: category status wasn't saved.
Browse files Browse the repository at this point in the history
- 870, 877, 878: growfield plugins send wrong value when empty textarea. Now use another plugin for autogrow.

git-svn-id: http://piwigo.org/svn/trunk@2653 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Oct 4, 2008
1 parent 9559f1a commit eb07150
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 337 deletions.
2 changes: 1 addition & 1 deletion admin/cat_modify.php
Expand Up @@ -100,7 +100,7 @@
{
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
}
if ($cat_info['status'] != get_boolean( $_POST['status'] ) )
if ($cat_info['status'] != $_POST['status'] )
{
set_cat_status(array($_GET['cat_id']), $_POST['status']);
}
Expand Down
8 changes: 3 additions & 5 deletions admin/template/goto/include/autosize.inc.tpl
@@ -1,16 +1,14 @@
{* $Id$ *}
{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"}
{known_script id="jquery.ui" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.core.packed.js"}
{known_script id="jquery.growfield" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.growfield.packed.js"}
{known_script id="jquery.autogrow" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.autogrow-textarea.js"}

{* Auto size and auto grow textarea *}
{literal}
<script type="text/javascript">
jQuery().ready(function(){
jQuery('textarea').css('overflow-y', 'hidden');
// Auto size and auto grow for all text area
jQuery("TEXTAREA").growfield({
animate: false
});
jQuery('textarea').autogrow();
});
</script>
{/literal}
47 changes: 47 additions & 0 deletions template-common/lib/plugins/jquery.autogrow-textarea.js
@@ -0,0 +1,47 @@
(function($) {

/*
* Auto-growing textareas; technique ripped from Facebook
*/
$.fn.autogrow = function(options) {

this.filter('textarea').each(function() {

var $this = $(this),
minHeight = $this.height(),
lineHeight = $this.css('lineHeight');

var shadow = $('<div></div>').css({
position: 'absolute',
top: -10000,
left: -10000,
width: $(this).width(),
fontSize: $this.css('fontSize'),
fontFamily: $this.css('fontFamily'),
lineHeight: $this.css('lineHeight'),
resize: 'none'
}).appendTo(document.body);

var update = function() {

var val = this.value.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/&/g, '&amp;')
.replace(/\n/g, '<br/>');

shadow.html(val);
$(this).css('height', Math.max(shadow.height() + 20, minHeight));

}

$(this).change(update).keyup(update).keydown(update);

update.apply(this);

});

return this;

}

})(jQuery);

0 comments on commit eb07150

Please sign in to comment.