Current Path : /var/www/html/clients/nsmk.e-nk.ru/application/maxsite/plugins/file_manager/js/ |
Current File : /var/www/html/clients/nsmk.e-nk.ru/application/maxsite/plugins/file_manager/js/jquery.fmeditor.js |
// jQuery FileManager Editor Plugin // // Version 1.00 http://gromoff.net/file-manager/ // // (c) 2007-2008 Andrew Gromoff and is released under the MIT License: // http://www.opensource.org/licenses/mit-license.php // jQuery.fn.FMeditor = function(o) // options { var o = jQuery.extend( { text:'' ,setText:'' ,cont:'' ,setContainer:'' ,before:'' ,callback:'' ,after:'' ,afterstart:'' ,cancel:'' } ,o); return this.each(function() { var _self = jQuery(this); var key = ''; var activator = ''; function post(newname) { //log('post'); _self.hide(0); if (newname) { o.text.html(newname); o.cont.show(0); } else { o.cont.show(0); } if(o.after){o.after(o.cont)} } function start() { _self.removeAttr("disabled"); _self.removeAttr("readonly"); // textarea o.cont.hide(0); _self.val(o.text.html()).show(0).focus(); if(o.afterstart){o.afterstart(activator, o.text, o.cont)} } o.activator.live("click", function(e) // только click // mousedown return false - no blur // mouse down return true - blur fast { if (e.button === 0) { activator = $(this); if(o.before) { if (!o.before(activator)){return false;} } if(o.setText){o.text = o.setText(activator)} if (!o.text){o.text = activator} if(o.setContainer) {o.cont = o.setContainer(activator)} else {o.cont = o.text;} start(); return false; } }); _self.focus(function() { key = ''; _self.one("blur",function(e) { _self.val($.trim(_self.val())); // TRIM !!! if(_self.val() != o.text.html()) { if(!key) // потеря фокуса { _self.attr("disabled", true); // что б нам фокус какой не прислали... if(confirm("Сохранить изменения?")) {key = 13} else {log('1'); key = 27} } } else key = 27; // значения равны, изменять нечего if((o.callback) && (key == 13)) { _self.attr("disabled", true); o.callback( activator ,o.text.html() ,_self.val() ,o.cont ,post // post ,function() // error { start(); } ); } else { post(); if(o.cancel){o.cancel(activator)} } return false; }) }) .keydown(function(e) { if ((e.keyCode == 13) || (e.keyCode == 27)) { key = e.keyCode; _self.blur(); return false; } }); }); };