diff options
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/ajax.js | 22 | ||||
-rw-r--r-- | lib/scripts/cookie.js | 6 | ||||
-rw-r--r-- | lib/scripts/edit.js | 60 | ||||
-rw-r--r-- | lib/scripts/linkwiz.js | 6 | ||||
-rw-r--r-- | lib/scripts/locktimer.js | 16 | ||||
-rw-r--r-- | lib/scripts/media.js | 38 | ||||
-rw-r--r-- | lib/scripts/subscriptions.js | 6 | ||||
-rw-r--r-- | lib/scripts/toolbar.js | 28 |
8 files changed, 96 insertions, 86 deletions
diff --git a/lib/scripts/ajax.js b/lib/scripts/ajax.js index fe93502cb..aa083978c 100644 --- a/lib/scripts/ajax.js +++ b/lib/scripts/ajax.js @@ -4,12 +4,12 @@ * @license GPL2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> * @author Adrian Lang <lang@cosmocode.de> - * @author Michal Rezler <m.rezler@centrum.cz> + * @author Michal Rezler <m.rezler@centrum.cz> */ - + (function ($) { var init, clear_results, onCompletion; - + var ajax_quicksearch = { inObj: null, outObj: null, @@ -56,7 +56,7 @@ ajax_quicksearch.outObj.hide(); } ); - + }; clear_results = function(){ @@ -76,10 +76,10 @@ // shorten namespaces if too long var width = outObj.clientWidth; var links = $('ajax_quicksearch outObj a'); - + for (var i=0; i<links.length; i++) { var content = links[i].text(); - + // maximum allowed width: var max = width - links[i].offsetLeft; var isRTL = (document.documentElement.dir == 'rtl'); @@ -97,8 +97,8 @@ (!isRTL && links[i].offsetWidth > max) || (isRTL && links[i].offsetLeft < 0) ) - ){ - + ){ + if(runaway++ > 500) return; // just in case something went wrong if(eli){ @@ -115,16 +115,16 @@ var mid = Math.floor( nsL + ((nsR-nsL)/2) ); content = content.substring(0,mid)+'…' + content.substring(mid+1); } - + eli = content.indexOf('…'); nsL = content.indexOf('('); nsR = content.indexOf(')'); } } }; - + $(function () { init('qsearch__in','qsearch__out'); }); -}(jQuery));
\ No newline at end of file +}(jQuery)); diff --git a/lib/scripts/cookie.js b/lib/scripts/cookie.js index 4904117ee..f7d9b5ffb 100644 --- a/lib/scripts/cookie.js +++ b/lib/scripts/cookie.js @@ -72,8 +72,8 @@ DokuCookie = { expires: expires_, path: path_, domain: domain_, - secure: secure_, - }; + secure: secure_, + }; jQuery.cookie(name, value, params); }, @@ -99,4 +99,4 @@ DokuCookie = { date.setTime(date.getTime() - skew); } } -};
\ No newline at end of file +}; diff --git a/lib/scripts/edit.js b/lib/scripts/edit.js index d04baaa6d..a9623e14d 100644 --- a/lib/scripts/edit.js +++ b/lib/scripts/edit.js @@ -11,7 +11,7 @@ * Style the buttons through the toolbutton class * * @author Andreas Gohr <andi@splitbrain.org> - * @author Michal Rezler <m.rezler@centrum.cz> + * @author Michal Rezler <m.rezler@centrum.cz> */ function createToolButton(icon,label,key,id,classname){ var $ = jQuery; @@ -23,11 +23,11 @@ function createToolButton(icon,label,key,id,classname){ if(classname){ btn.attr('class', 'toolbutton '+classname); } - + btn.attr('title', label); if(key){ btn.attr('title', label + ' ['+key.toUpperCase()+']') - .attr('accessKey', key); + .attr('accessKey', key); } // set IDs if given @@ -43,8 +43,8 @@ function createToolButton(icon,label,key,id,classname){ ico.attr('src', DOKU_BASE+'lib/images/toolbar/'+icon); } btn.append(ico); - - // we have to return a javascript object (for compatibility reasons) + + // we have to return a javascript object (for compatibility reasons) return btn[0]; } @@ -69,12 +69,12 @@ function createPicker(id,props,edid){ // create the wrapping div var picker = $('<div></div>'); - + var className = 'picker'; if(props['class']){ className += ' '+props['class']; } - + picker.attr('class', className) .attr('id', id) .css('position', 'absolute') @@ -89,17 +89,17 @@ function createPicker(id,props,edid){ var btn = $('<button>'); btn.attr('class', 'pickerbutton') .attr('title', key); - + var ico = $('<img>'); if (list[key].substr(0,1) == '/') { var src = list[key]; } else { var src = DOKU_BASE+'lib/images/'+icobase+'/'+list[key]; } - + ico.attr('src', src); btn.append(ico); - + btn.bind('click', bind(pickerInsert, key, edid)); picker.append(btn); }else if (typeof (list[key]) == 'string'){ @@ -107,12 +107,12 @@ function createPicker(id,props,edid){ var btn = $('<button>'); btn.attr('class', 'pickerbutton') .attr('title', list[key]); - + var txt = $(document.createTextNode(list[key])); btn.append(txt); - + btn.bind('click', bind(pickerInsert, list[key], edid)); - + picker.append(btn); }else{ // a list of lists -> treat it as subtoolbar @@ -123,7 +123,7 @@ function createPicker(id,props,edid){ } var body = $('body'); body.append(picker); - + // we have to return a javascript object (for compatibility reasons) return picker[0]; } @@ -265,7 +265,7 @@ function currentHeadlineLevel(textboxId){ /** * global var used for not saved yet warning */ -var textChanged = false; +window.textChanged = false; /** * Delete the draft before leaving the page @@ -277,7 +277,7 @@ function deleteDraft() { // remove a possibly saved draft using ajax var dwform = jQuery('#dw__editform'); if(dwform.length != 0) { - + jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', { @@ -295,14 +295,14 @@ function deleteDraft() { * Sets focus to the editbox as well */ addInitEvent(function () { - var $ = jQuery; + var $ = jQuery; var editform = $('#dw__editform'); if (editform.length == 0) return; var edit_text = $('#wiki__text'); - if (edit_text.length > 0) { + if (edit_text.length > 0) { if(edit_text.attr('readOnly')) return; - + // in Firefox, keypress doesn't send the correct keycodes, // in Opera, the default of keydown can't be prevented if (is_opera) { @@ -310,21 +310,25 @@ addInitEvent(function () { } else { edit_text.keydown(keyHandler); } - - // set focus + + // set focus and place cursor at the start + var sel = getSelection(edit_text.get(0)); + sel.start = 0; + sel.end = 0; + setSelection(sel); edit_text.focus(); } - + var checkfunc = function() { textChanged = true; //global var summaryCheck(); - }; - - editform.change(checkfunc); + }; + + editform.change(checkfunc); editform.keydown(checkfunc); window.onbeforeunload = function(){ - if(textChanged) { + if(window.textChanged) { return LANG.notsavedyet; } }; @@ -333,11 +337,13 @@ addInitEvent(function () { // reset change memory var on submit $('#edbtn__save').click( function() { + window.onbeforeunload = ''; textChanged = false; } ); $('#edbtn__preview').click( function() { + window.onbeforeunload = ''; textChanged = false; window.keepDraft = true; // needed to keep draft on page unload } @@ -346,7 +352,7 @@ addInitEvent(function () { var summary = $('#edit__summary'); summary.change(summaryCheck); summary.keyup(summaryCheck); - + if (textChanged) summaryCheck(); }); diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js index 2750d07a8..e9a1d71b3 100644 --- a/lib/scripts/linkwiz.js +++ b/lib/scripts/linkwiz.js @@ -21,11 +21,11 @@ * and attaching the eventhandlers */ var init = function(textAreaElement){ - + // create HTML Structure wiz = document.createElement('div'); - wiz.style.position = 'absolute'; + wiz.style.position = 'absolute'; wiz.id = 'link__wiz'; wiz.className = 'picker'; wiz.style.top = (findPosY(textAreaElement)+20)+'px'; @@ -316,4 +316,4 @@ }); } }); -})(jQuery);
\ No newline at end of file +})(jQuery); diff --git a/lib/scripts/locktimer.js b/lib/scripts/locktimer.js index ad3e7ff62..60508a8e7 100644 --- a/lib/scripts/locktimer.js +++ b/lib/scripts/locktimer.js @@ -9,7 +9,11 @@ var locktimer = { msg: '', pageid: '', - init: function(timeout,msg,draft){ + init: function(timeout,msg,draft,edid){ + var edit = $(edid); + if(!edit) return; + if(edit.readOnly) return; + // init values this.timeout = timeout*1000; this.msg = msg; @@ -19,7 +23,7 @@ var locktimer = { if(jQuery('#dw__editform').length == 0) return; this.pageid = jQuery('#dw__editform input[name=id]').val(); if(!this.pageid) return; - + if(jQuery('#wiki__text').attr('readonly')) return; // register refresh event @@ -72,18 +76,18 @@ var locktimer = { params['id'] = locktimer.pageid; if(locktimer.draft && jQuery('#dw__editform textarea[name=wikitext]').length > 0){ - params['prefix'] = jQuery('#dw__editform input[name=prefix]').val(); + params['prefix'] = jQuery('#dw__editform input[name=prefix]').val(); params['wikitext'] = jQuery('#dw__editform textarea[name=wikitext]').val(); params['suffix'] = jQuery('#dw__editform input[name=suffix]').val(); if(jQuery('#dw__editform input[name=date]').length > 0) { params['date'] = jQuery('#dw__editform input[name=id]').val(); } } - + jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', params, - function (data) { + function (data) { locktimer.refreshed(data); }, 'html' @@ -103,4 +107,4 @@ var locktimer = { if(error != '1') return; // locking failed this.reset(); } -};
\ No newline at end of file +}; diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 7529523ad..cf4a839d9 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -12,7 +12,7 @@ */ (function ($) { var toggle, list, prepare_content, insert, confirmattach, attachoptions, initpopup, updatehide, setalign, setsize, inSet, outSet, media_manager, hasFlash; - + var media_manager = { keepopen: false, hide: false, @@ -23,7 +23,7 @@ size: false, ext: false, }; - + @@ -34,11 +34,11 @@ */ initpopup = function() { var popup; - + popup = document.createElement('div'); popup.setAttribute('id','media__popup'); popup.style.display = "none"; - + var root = document.getElementById('media__manager'); if (root === null) return; root.appendChild(popup); @@ -156,11 +156,11 @@ btn.value = LANG['mediainsert']; btnp.appendChild(btn); }; - + // moved from helpers.js temporarily here /** * Very simplistic Flash plugin check, probably works for Flash 8 and higher only - * + * */ hasFlash = function(version){ var ver = 0; @@ -524,13 +524,13 @@ kobox.defaultChecked = true; //IE wants this media_manager.keepopen = true; } - + $(kobox).click( function () { toggleOption(this, 'keepopen'); } ); - + var kolbl = document.createElement('label'); kolbl.htmlFor = 'media__keepopen'; kolbl.innerHTML = LANG['keepopen']; @@ -574,7 +574,7 @@ * Generalized toggler * * @author Pierre Spring <pierre.spring@caillou.ch> - */ + */ toggleOption = function (checkbox, variable) { if (checkbox.checked) { DokuCookie.setValue(variable, 1); @@ -588,12 +588,12 @@ initFlashUpload = function () { var oform, oflash, title; if(!hasFlash(8)) return; - + oform = $('#dw__upload'); oflash = $('#dw__flashupload'); - + if(!oform.size() || !oflash.size()) return; - + title = LANG['mu_btn']; $('<img/>').attr('src', DOKU_BASE+'lib/images/multiupload.png') @@ -608,7 +608,7 @@ ) .appendTo(oform); }; - + /** * Sets the visibility of the image details accordingly to the * chosen hide state @@ -631,7 +631,7 @@ ); }; - + /** * set the align * @@ -652,7 +652,7 @@ media_manager.align = false; } }; - + /** * set the link type * @@ -692,7 +692,7 @@ media_manager.link = false; } }; - + /** * set the image size * @@ -712,14 +712,14 @@ media_manager.width = false; } }; - + /** * sets the border to inset */ inSet = function(id) { var ele = $('#' + id).css('border-style', 'inset'); }; - + /** * sets the border to outset */ @@ -748,4 +748,4 @@ $('#media__tree').delegate('img', 'click', toggle) .delegate('a', 'click', list); }); -}(jQuery));
\ No newline at end of file +}(jQuery)); diff --git a/lib/scripts/subscriptions.js b/lib/scripts/subscriptions.js index 144f31881..79b1caf1a 100644 --- a/lib/scripts/subscriptions.js +++ b/lib/scripts/subscriptions.js @@ -7,13 +7,13 @@ (function ($) { $(function () { var form, list, digest; - + form = $('#subscribe__form'); if (0 === form.size()) { return; } - + list = form.find("input[name='sub_style'][value='list']"); digest = form.find("input[name='sub_style'][value='digest']"); @@ -38,4 +38,4 @@ .filter(':checked') .click(); }); -}(jQuery));
\ No newline at end of file +}(jQuery)); diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js index 6beb07c5b..c8dfe394d 100644 --- a/lib/scripts/toolbar.js +++ b/lib/scripts/toolbar.js @@ -18,12 +18,12 @@ function initToolbar(tbid,edid,tb, allowblock){ } else { var toolbar = $(tbid); } - + if(toolbar.length == 0) return; - + var edit = $('#' + edid); if(edit.length == 0) return; - + if(edit.attr('readOnly')) return; if (typeof allowblock === 'undefined') { @@ -33,41 +33,41 @@ function initToolbar(tbid,edid,tb, allowblock){ //empty the toolbar area: toolbar.html(''); - var cnt = tb.length; - + var cnt = tb.length; + for(var i=0; i<cnt; i++){ if (!allowblock && tb[i].block === true) { continue; } var actionFunc; - + // create new button (jQuery object) var btn = $(createToolButton(tb[i]['icon'], tb[i]['title'], tb[i]['key'], tb[i]['id'], tb[i]['class'])); - + // type is a tb function -> assign it as onclick actionFunc = 'tb_'+tb[i]['type']; if( $.isFunction(window[actionFunc]) ){ - btn.bind('click', bind(window[actionFunc],btn,tb[i],edid) ); + btn.bind('click', bind(window[actionFunc],btn,tb[i],edid) ); toolbar.append(btn); continue; } - + // type is a init function -> execute it actionFunc = 'addBtnAction'+tb[i]['type'].charAt(0).toUpperCase()+tb[i]['type'].substring(1); if( $.isFunction(window[actionFunc]) ){ if(window[actionFunc](btn, tb[i], edid)){ toolbar.append(btn); - } + } continue; } - + alert('unknown toolbar type: '+tb[i]['type']+' '+actionFunc); } // end for - + } /** @@ -205,7 +205,7 @@ function tb_autohead(btn, props, edid){ function addBtnActionPicker(btn, props, edid) { var pickerid = 'picker'+(pickercounter++); createPicker(pickerid, props, edid); - + btn.click( function() { pickerToggle(pickerid,btn); @@ -240,7 +240,7 @@ function pickerToggle(pickerid,btn){ if (picker.css('marginLeft') == '-10000px'){ var x = findPosX(btn[0]); var y = findPosY(btn[0]); - + picker.css('left',(x+3)+'px') .css('top', (y+btn[0].offsetHeight+3)+'px') .css('marginLeft', '0px') |