Changeset 208 in t29-www for en/dev/translation/editor.js
- Timestamp:
- Oct 24, 2010, 7:46:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
en/dev/translation/editor.js
r207 r208 54 54 t29.tr.sidebar.find(".tr-enabled .button").attr("href","#back_to_normal_mode").click(t29.tr.call("set_enabled",false)); 55 55 t29.tr.load_messages(); 56 t29.tr.defaultvalue(); // as general system 56 57 // initial value 57 //t29.tr.set_enabled(true); 58 //t29.tr.set_enabled(true); // won't work any more (call t29.tr.preloader.start) 58 59 }; 59 60 … … 61 62 // foobar.call(function(){ t29.tr.anything(value); }); 62 63 t29.tr.call = function(f, v){ return function(){ t29.tr[f](v);} }; 64 65 // helper: default value input elements. highly compressed selfwritten :) 66 // usage: <input value="my default value bla" class="defaultvalue"/> 67 t29.tr.defaultvalue = function(){ 68 $("input.defaultvalue").live('focus', function(){ 69 if(!(dv=(t=$(this)).data('dv'))) t.data('dv', t.val()); 70 if(t.val()==dv) t.val(''); 71 }).live('blur', function(){ 72 if((dv=((t=$(this)).data('dv'))) && /^\s*$/.test(t.val())) t.val(dv); 73 }); 74 }; 63 75 64 76 /** … … 135 147 // create Infobox, editorbox, topnoticebox, design elements 136 148 $("body").append(t29.tr.msg.create_ui_body_append); 149 $("#content").before(t29.tr.msg.create_ui_topbox); 137 150 $.each(["infobox", "editorbox", "topbox"], function(){ t29.tr[this] = $("#tr-"+this); }); 151 152 // make topbox being fixed at top scrolling 153 var top = t29.tr.topbox.offset().top; // - parseFloat($('#comment').css('marginTop').replace(/auto/, 0)) 154 $(window).scroll(function(e) { 155 var now_fixed = $(this).scrollTop() >= top; 156 // since topbox was embedded in content (not sidebar), place is 157 // removed there when switching from static to fixed. Setting the 158 // height is a workaround. 159 (p=t29.tr.topbox.parent()).css('height', now_fixed ? p.height() : ''); 160 t29.tr.topbox.toggleClass('fixed', now_fixed); 161 }); 162 163 // create all event handlers in the topbox 164 165 // Fields where clicking yields extender bar (poor man tab bar) 166 var hideall_tabs = function() { 167 t29.tr.topbox.find(".field.extends").removeClass('active'); 168 t29.tr.topbox.find(".extender > div").slideUp(); 169 } 170 t29.tr.topbox.find(".field.extends").toggle(function(){ 171 hideall_tabs(); // make sure no other is shown 172 var extender = $(this).hasClass('name') ? 'name' : 'feedback'; 173 t29.tr.topbox.find('.extender .'+extender).slideDown() 174 $(this).addClass('active'); 175 }, hideall_tabs); 176 177 // User name box form 178 t29.tr.topbox.find(".name :text").keyup(function(){ 179 t29.tr.settings[$(this).attr('name')] = $(this).val(); 180 t29.tr.topbox.find('.name .feedback').html("<b>"+t29.tr.settings.name+"</b> from <b>"+t29.tr.settings.location+"</b>"); 181 t29.tr.topbox.find('.name .stored').text(' - Thank you'); 182 }); 183 184 // Edit whole page button 185 t29.tr.topbox.find('.field.editwhole').click(t29.tr.edit_whole_page); 186 t29.tr.topbox.find('.field.help').click(t29.tr.help); 187 t29.tr.topbox.find('.field.exit').click(t29.tr.call('set_enabled', false)); 188 189 190 // Create Editor UI (only once) 191 t29.tr.editorbox.html(t29.tr.msg.create_editorui_editorbox); // remove all possible old classes 192 t29.tr.editorbox.find(".cancel").click(t29.tr.stop_editing); 193 t29.tr.editorbox.find(".submit").click(t29.tr.submit_editing); 194 t29.tr.editorbox.find(".help").click(t29.tr.help); 195 138 196 139 197 // create all wrapper elements (most important step) … … 299 357 return false; 300 358 } 359 }; 360 361 /** 362 * Shorthand method to start editing the whole #content area. May be called with 363 * callbacks, directly, etc. Will make sure that there is no other editor. 364 **/ 365 t29.tr.edit_whole_page = function() { 366 t29.tr.set_editing(false); // make sure there is no other editor 367 $("#content").wrapInner("<div class='tr-editable'/>"); 368 t29.tr.set_editing( $("#content > .tr-editable") ); 301 369 }; 302 370 … … 370 438 **/ 371 439 t29.tr.create_editorui = function() { 372 t29.tr.editorbox.append(t29.tr.msg.create_editorui_editorbox).removeClass(); // remove all possible old classes 373 t29.tr.editorbox.find(".cancel").click(t29.tr.stop_editing); 374 t29.tr.editorbox.find(".submit").click(t29.tr.submit_editing); 375 t29.tr.editorbox.find(".help").click(t29.tr.help); 376 377 t29.tr.editorbox.css({ 378 top: t29.tr.editor.offset().top - t29.tr.editorbox.outerHeight(), 379 left: t29.tr.editor.offset().left, 380 width: t29.tr.editor.width() 440 // Basic initial setup of the editorbox (HTML, callbacks) is already done in general UI) 441 442 443 t29.tr.editorbox.removeClass() 444 .css('width', t29.tr.editor.width()) // IMPORTANT - to be done before outerHeight() call 445 .css({ 446 top: t29.tr.editor.offset().top - t29.tr.editorbox.outerHeight(), 447 left: t29.tr.editor.offset().left 381 448 }).show(); 382 449 };
Note: See TracChangeset
for help on using the changeset viewer.