|
|
שורה 1: |
שורה 1: |
| */
| |
| Qe = {
| |
|
| |
| bar : [
| |
| {title : 'שמירה', onclick : 'Qe.save($(this))'},
| |
| {title : 'תצוגה מקדימה', onclick : 'Qe.preview($(this))'},
| |
| {title : 'ביטול', onclick : 'Qe.cancel()'}
| |
| ],
| |
|
| |
| run : function(){
| |
|
| |
|
| $('.mw-editsection').before('<span class="QuickEditor">[<a>עריכה מהירה</a>]</span>');
| |
| var captions = $.merge($('.mw-headline').parent(), $('h1'));
| |
| $(captions).find('.mw-editsection-link-secondary').hide();
| |
| $(captions).hover(
| |
| function(){$(this).find('.mw-editsection-link-secondary').show().css('visibility', 'visible')},
| |
| function(){$(this).find('.mw-editsection-link-secondary').hide().css('visibility', 'hidden')}
| |
| );
| |
|
| |
| $('.QuickEditor').on('click',function(){
| |
| if($('#loading').length) return;
| |
|
| |
| /*** external scripts support: ***/
| |
|
| |
| if($('#move-section').length) Qe.external.options.move = 1; // for מדיה ויקי:סקריפטים/77.js
| |
| if($('.gallery-slideshow').length) Qe.external.options.slideshow = 1;
| |
|
| |
| /** END **/
| |
|
| |
| Qe.next = true;
| |
| var oldindex = Qe.index;
| |
| Qe.index = $(this).index('.QuickEditor');
| |
| if($('#QE').length && oldindex && Qe.index >= oldindex)Qe.index++;
| |
| $('#QE').length ? null : Qe.copy = $($('#mw-content-text').html()).clone(true, true);
| |
| Qe.cancel();
| |
| var a = $('.QuickEditor').eq(Qe.index);
| |
| var section = $(this).nextAll('.mw-editsection').find('a').eq(0).attr('href').split(/&v?e?section/)[1].replace('=', '').split('&')[0];
| |
|
| |
| if(a.parents('h1').length){
| |
| Qe.caption = $($('#mw-content-text').children().not('div')[0]);
| |
| Qe.next = Qe.caption[0].tagName.split('')[0] == 'H' ? false : true;
| |
| Qe.get_caption(Qe.caption.nextAll(), 'until');
| |
| Qe.caption.before(Qe.loading);
| |
| }else{
| |
| Qe.get_caption(a.parents(), 'caption');
| |
| Qe.caption = a.parents(Qe.caption);
| |
| Qe.get_caption(Qe.caption.nextAll(), 'until');
| |
| Qe.caption.after(Qe.loading);
| |
| }
| |
|
| |
| var href = $(this).nextAll('.mw-editsection').children('a').attr('href').replace('veaction', 'action').replace('vesection', 'section');
| |
| Qe.until = Qe.until || '';
| |
| $.get(href, function(e){
| |
| $('#loading').remove();
| |
| var text = $(e).find('#wpTextbox1').val();
| |
| Qe.time = $(e).find('[name=wpEdittime]').val();
| |
| Qe.base = $(e).find('[name=wpStarttime]').val();
| |
| if(Qe.next){
| |
| Qe.caption.nextUntil(Qe.until).remove();
| |
| }
| |
| var place = Qe.next ? 'after' : 'before';
| |
| Qe.caption[place]('<div id="QE" style="clear : both"><div id="bar_icons"></div><textarea id="WYSIWYG"></textarea></div>');
| |
| for(var btn in Qe.bar){
| |
| $('#bar_icons').append($('<button class = "bar_click">').attr(Qe.bar[btn]).attr('section', section).text(Qe.bar[btn].title));
| |
| }
| |
|
| |
| $('#bar_icons').append('<label>תקציר עריכה:</label><input id="wpSummary" name="wpSummary" style="width:500px">').prepend('<input id="wpMinoredit" type="checkbox"><label>זהו שינוי משני</label>');
| |
| var summary = Qe.caption.children('.mw-headline').text() || 'פתיח';
| |
| if(!Qe.next)summary = 'פתיח';
| |
| if(summary == 'פתיח' && Qe.next){
| |
| Qe.caption.prevAll().remove();
| |
| }
| |
| $('#wpSummary').val('/* ' + summary + ' */ ');
| |
| if(Qe.caption.parent().css('position') == 'absolute')Qe.caption.parent().remove();
| |
| if(Qe.next)Qe.caption.remove();
| |
| $('#WYSIWYG').val(text).height($("#WYSIWYG")[0].scrollHeight);
| |
| $('body, html').scrollTop($('#QE').offset().top);
| |
| eval(Qe.smr);
| |
| $('#summariesList').css('width', '100%');
| |
|
| |
| //autoComplete:
| |
|
| |
| if($.fn.autoCompleteWikiText){
| |
| $('#WYSIWYG').autoCompleteWikiText({
| |
| positionMy: "left top",
| |
| positionAt: "left top",
| |
| positionOf: '#QE',
| |
| positionOffset: "0 0",
| |
| menuCSS: {'z-index': 10000, background:'#E0EEF7', 'box-shadow': '1px 1px 5px rgba(0,0,200,.4)', 'border-radius': '3px'},
| |
| itemCSS: {padding: 0, margin: 0}
| |
| });
| |
| }
| |
|
| |
| if(Qe.ToolBar){
| |
| $('#WYSIWYG').before(Qe.ToolBar);
| |
| }
| |
| });
| |
| });
| |
|
| |
| },
| |
|
| |
| save : function(elem){
| |
| $('#bar_icons').after(Qe.loading);
| |
| var section = elem.attr("section");
| |
| var param = {
| |
| action : 'edit',
| |
| basetimestamp : Qe.time,
| |
| starttimestamp : Qe.base,
| |
| title : mw.config.get('wgPageName'),
| |
| text : $('#WYSIWYG').val(),
| |
| token : mw.user.tokens.values.editToken,
| |
| section : section,
| |
| summary : $('#wpSummary').val(),
| |
| format : 'xml'
| |
| };
| |
| if($('#wpMinoredit').is(':checked'))param.minor = true;
| |
|
| |
| $.post('/w/api.php',param,function(f){
| |
|
| |
| var conflict = false;
| |
| if($(f).find('error').length){
| |
| alert('התנגשות עריכה: משתמש אחר ערך את הפסקה לאחר שהתחלתם לערוך אותה. כעת תוצג לפניכם הגרסה העדכנית של הדף, אותה תוכלו לערוך.');
| |
| conflict = true;
| |
| }
| |
|
| |
| $.get(document.URL,function(e){
| |
| $('#mw-content-text').html($(e).find('#mw-content-text').html());
| |
| if(conflict){
| |
| $('#mw-content-text').append($('<div>', {id : 'oldval'}).append($('<div>').append('זהו הטקסט שלכם, תוכלו להעתיק ולהדביק אותו בחלונית העריכה <button style="float : left" onclick="$(\'#oldval\').remove()">סגור</button>'), $('<textarea>').val(param.text)));
| |
| $('#oldval textarea').height($('#oldval textarea')[0].scrollHeight + 50);
| |
| }
| |
| var result = conflict ? 'העריכה בוטלה' : 'העריכה נשמרה בהצלחה!';
| |
| mw.util.jsMessage(result);
| |
| $('.QuickEditor').remove();
| |
| $('.mw-editsection').before('<span class="QuickEditor">[<a>עריכה מהירה</a>]</span>');
| |
|
| |
| if(Qe.visual){
| |
| $('#mw-content-text .mw-editsection a').each(function(){
| |
| Qe.ve.bild($(this));
| |
| });
| |
| Qe.ve.style();
| |
| }
| |
|
| |
| for(var opt in Qe.external.options)Qe.external[opt]();
| |
| });
| |
| });
| |
| },
| |
|
| |
| get_caption : function(elem, obj){
| |
| elem.each(function(){
| |
| var tag = this.tagName.split('');
| |
|
| |
| if(tag[0] == 'H' && /[0-9]/.test(tag[1])){
| |
| if(obj == 'until')
| |
| {
| |
| var ctag = Qe.caption[0].tagName.split('')[1];
| |
| if(tag[1] > ctag) return true;
| |
| }
| |
| Qe[obj] = this.tagName;
| |
| return false;
| |
| }
| |
| });
| |
| },
| |
|
| |
| preview : function(elem){
| |
| if($('#WYSIWYG').val() !== ''){
| |
| $('#bar_icons').after(Qe.loading);
| |
| var section = elem.attr("section");
| |
| var param = {
| |
| action : 'edit',
| |
| title : mw.config.get('wgPageName'),
| |
| wpTextbox1 : $('#WYSIWYG').val(),
| |
| section : section,
| |
| wpPreview :true,
| |
| live : true
| |
| };
| |
| $.post('/w/index.php', param, function(e){
| |
| $('#loading').remove();
| |
| var pre = $($(e).find('preview').text());
| |
|
| |
| for(var cls = 0; cls < pre.length; cls++){
| |
| if($(pre[cls]).attr('class') == 'mw-content-rtl'){
| |
| precon = pre[cls];
| |
| break;
| |
| }
| |
| }
| |
|
| |
| $('#WYSIWYG').after($('<div id = "preview">').html(precon)).hide();
| |
| });
| |
| }
| |
| else {$('#WYSIWYG').hide()}
| |
|
| |
| elem.text('חזרה לעריכה').attr({'onclick' : 'Qe.rePreview(this)', 'title' : 'חזרה למצב עריכה'});
| |
| },
| |
|
| |
| rePreview : function(elem){
| |
| $(elem).text('תצוגה מקדימה').attr({'onclick' : 'Qe.preview($(this))', 'title' : 'תצוגה מקדימה'});
| |
| $('#preview').remove();
| |
| $('#WYSIWYG').show();
| |
| },
| |
|
| |
| cancel : function(o){
| |
| if(!Qe.copy)return;
| |
| $('#mw-content-text').html(Qe.copy.clone(true, true));
| |
| Qe.ve.style();
| |
| },
| |
|
| |
| next : true,
| |
|
| |
| //for the VisualEditor:
| |
|
| |
| ve : {
| |
|
| |
| bild : function(obj){
| |
|
| |
| var bracket = $('<span>', {'class' : 'mw-editsection-bracket'}),
| |
| link = obj.attr('href'),
| |
| title = obj.attr('title'),
| |
| divider = $('<span>', {'class' : 'mw-editsection-divider'}).text('|');
| |
|
| |
| var primary = $('<a>', {'class' : 'mw-editsection-link-primary', title : title, href : link.replace('action', 'veaction').replace('section', 'vesection')}),
| |
| secondary = $('<a>', {'class' : 'mw-editsection-link-secondary', title : title, href : link});
| |
|
| |
| var section = [
| |
| bracket.clone().text('['),
| |
| primary.text('עריכה'),
| |
| bracket.clone().text(']'),
| |
| divider,
| |
| secondary.text(' עריכת קוד מקור'),
| |
| bracket.clone().text(']')
| |
| ];
| |
| var parent = obj.parent();
| |
| parent.empty().append(section);
| |
| Qe.ve.hide(parent);
| |
| },
| |
|
| |
| style : function(){
| |
| $('.mw-headline').parent().on({
| |
| mouseenter : function(){
| |
| $(this).addClass('mw-editsection-expanded').find('.mw-editsection-bracket:not(:first-child, :last-child)').css('visibility', 'hidden').hide();
| |
| $(this).find('.mw-editsection-divider, .mw-editsection-bracket:last-child').css('visibility', 'visible').show();
| |
| $(this).find('.mw-editsection-link-secondary').css('visibility', 'visible').show();
| |
| },
| |
| mouseleave : function(){
| |
| Qe.ve.hide($(this));
| |
| }
| |
| });
| |
| },
| |
|
| |
| hide : function(elem){
| |
| elem.removeClass('mw-editsection-expanded').find('.mw-editsection-bracket:not(:first-child, :last-child)').css('visibility', 'visible').show();
| |
| elem.find('.mw-editsection-divider, .mw-editsection-bracket:last-child').css('visibility', 'hidden').hide();
| |
| elem.find('.mw-editsection-link-secondary').css('visibility', 'hidden').hide().prev().css('visibility', 'hidden').hide();
| |
| }
| |
|
| |
| },
| |
|
| |
| //for external scripts:
| |
|
| |
| external : {
| |
| move: function(){
| |
| $('.mw-editsection').each(function(){
| |
| if($(this).parents('h1').length)return true;
| |
| var href = $(this).find('a').eq(0).attr('href').replace('&vesection', '§ion').replace('&veaction', '&action');
| |
| var tag = $(this).parent()[0].tagName.split('')[1];
| |
| href += '&move=' + tag;
| |
| $(this).nextAll().after('<span id="move-section">[<a href = ' + href + '>העברה</a>]</span>');
| |
| });
| |
| },
| |
|
| |
| slideshow: function(){
| |
| $('.gallery-slideshow').each(function(){
| |
| var slide = new SlideShow($(this));
| |
| slide.run();
| |
| });
| |
| },
| |
|
| |
| options : {}
| |
| },
| |
|
| |
| loading : '<img id = "loading" src = "data:image/gif;base64,R0lGODlhgAAPAPEAAP///6fX+eXy/KfX+SH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAgAAPAAACo5QvoIC33NKKUtF3Z8RbN/55CEiNonMaJGp1bfiaMQvBtXzTpZuradUDZmY+opA3DK6KwaQTCbU9pVHc1LrDUrfarq765Ya9u+VRzLyO12lwG10yy39zY11Jz9t/6jf5/HfXB8hGWKaHt6eYyDgo6BaH6CgJ+QhnmWWoiVnI6ddJmbkZGkgKujhplNpYafr5OooqGst66Uq7OpjbKmvbW/p7UAAAIfkECQoAAAAsAAAAAIAADwAAArCcP6Ag7bLYa3HSZSG2le/Zgd8TkqODHKWzXkrWaq83i7V5s6cr2f2TMsSGO9lPl+PBisSkcekMJphUZ/OopGGfWug2Jr16x92yj3w247bh6teNXseRbyvc0rbr6/x5Ng0op4YSJDb4JxhI58eliEiYYujYmFi5eEh5OZnXhylp+RiaKQpWeDf5qQk6yprawMno2nq6KlsaSauqS5rLu8cI69k7+ytcvGl6XDtsyzxcAAAh+QQJCgAAACwAAAAAgAAPAAACvpw/oIC3IKIUb8pq6cpacWyBk3htGRk1xqMmZviOcemdc4R2kF3DvfyTtFiqnPGm+yCPQdzy2RQMF9Moc+fDArU0rtMK9SYzVUYxrASrxdc0G00+K8ruOu+9tmf1W06ZfsfXJfiFZ0g4ZvEndxjouPfYFzk4mcIICJkpqUnJWYiYs9jQVpm4edqJ+lkqikDqaZoquwr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z5LLooO326Owxd7Bzam4x8pZ1t3Szu3VMOdF4AACH5BAkKAAAALAAAAACAAA8AAAK/nD+ggLfc0opS0XdnxFs3/i3CSApPSWZWt4YtAsKe/DqzXRsxDqDj6VNBXENakSdMso66WzNX6fmAKCXRasQil9onM+oziYLc8tWcRW/PbGOYWupG5Tsv3TlXe9/jqj7ftpYWaPdXBzbVF2eId+jYCAn1KKlIApfCSKn5NckZ6bnJpxB2t1kKinoqJCrlRwg4GCs4W/jayUqamaqryruES2b72StsqgvsKlurDEvbvOx8mzgazNxJbD18PN1aUgAAIfkECQoAAAAsAAAAAIAADwAAArKcP6CAt9zSilLRd2fEWzf+ecgjlKaQWZ0asqPowAb4urE9yxXUAqeZ4tWEN2IOtwsqV8YkM/grLXvTYbV4PTZpWGYU9QxTxVZyd4wu975ZZ/qsjsPn2jYpatdx62b+2y8HWMTW5xZoSIcouKjYePeTh7TnqFcpabmFSfhHeemZ+RkJOrp5OHmKKapa+Hiyyokaypo6q1CaGDv6akoLu3DLmLuL28v7CdypW6vsK9vsE1UAACH5BAkKAAAALAAAAACAAA8AAAKjnD+ggLfc0opS0XdnxFs3/nkISI2icxokanVt+JoxC8G1fNOlm6tp1QNmZj6ikDcMrorBpBMJtT2lUdzUusNSt9qurvrlhr275VHMvI7XaXAbXTLLf3NjXUnP23/qN/n8d9cHyEZYpoe3p5jIOCjoFofoKAn5CGeZZaiJWcjp10mZuRkaSAq6OGmU2lhp+vk6iioay3rpSrs6mNsqa9tb+ntQAAA7AAAAAAAAAAAA">'
| |
|
| |
| };
| |
|
| |
| $(function(){
| |
|
| |
| var style = '', rules = {
| |
|
| |
| button : {cursor : 'pointer'},
| |
|
| |
| '.bar_click' : {margin : '0 2px'},
| |
|
| |
| '#bar_icons' : {
| |
| 'margin-bottom' : '4px',
| |
| border : '2px solid #C8C8E9',
| |
| padding : '5px'
| |
| },
| |
|
| |
| '#bar_icons label' : {margin: '0 2px 0 10px'},
| |
|
| |
| '.QuickEditor, #move-section' : {
| |
| float : $('.mw-editsection').css('float') == 'left' ? 'left' : 'none',
| |
| 'font-weight' : 'normal',
| |
| 'font-size' : 'small',
| |
| 'margin-right' : '1em',
| |
| 'line-height' : '1em',
| |
| display : 'inline-block',
| |
| cursor : 'pointer'
| |
| },
| |
|
| |
| '#oldval' : {
| |
| overflow : 'auto',
| |
| border: '3px solid #C9C9CF',
| |
| position : 'fixed',
| |
| 'max-height' : '80%',
| |
| top : '50px',
| |
| width : '82%',
| |
| 'background-color' : 'rgb(201, 201, 207)',
| |
| padding : '5px',
| |
| 'box-shadow' : '2px 3px 6px rgba(0,0,0,.3)',
| |
| 'border-radius' : '5px'
| |
| },
| |
|
| |
| '#oldval div' : {
| |
| height : '30px',
| |
| color : 'white',
| |
| 'font-size' : '15px',
| |
| 'line-height' : '1.7'
| |
| },
| |
|
| |
| '#WYSIWYG, #oldval textarea' : {width : '99.5%'}
| |
| };
| |
|
| |
| for(var k in rules){
| |
| style += k + '{';
| |
| for(var i in rules[k]){
| |
| style += i + ':' + rules[k][i] + ';';
| |
| }
| |
| style += '}';
| |
| }
| |
|
| |
| if(Qe.Tools){
| |
| $.get('/w/index.php?title=משתמש:קובי_כרמל/Qe_Toolbar&action=edit', function(e){return Qe.ToolBar = $(e).find('#wpTextbox1').val()});
| |
| }
| |
|
| |
| mw.util.addCSS(style);
| |
|
| |
| /* $.get('/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-Summarieslist.js?action=edit',function(e){
| |
| Qe.smr = $(e).find('#wpTextbox1').val().split("(mw.util.getParamValue('section') == 'new')) {")[1];
| |
| Qe.smr = Qe.smr.slice(0, Qe.smr.length - 7).split("wpSummary').after").join("bar_icons').append");
| |
| }); */
| |
|
| |
| if($('.mw-editsection-link-primary').length)Qe.visual = true;
| |
|
| |
| Qe.run();
| |
|
| |
| });
| |