Plugin Directory

Changeset 647959 for wpide/trunk/js


Ignore:
Timestamp:
01/04/2013 06:43:46 PM (12 years ago)
Author:
WPsites
Message:

2.0.13

Location:
wpide/trunk/js
Files:
5 added
1 edited

Legend:

Unmodified
Added
Removed
  • wpide/trunk/js/load-editor.js

    r549142r647959 
    8787   
    8888    range.end.column = editor.getSession().getSelection().getCursor().column +1;//set end column as cursor pos
    89    
     89
    9090    //console.log("[ \.] based: " + editor.getSession().doc.getTextRange(range));
    9191   
     
    311311    //clear the text in the command help panel
    312312    //jQuery("#wpide_info_content").html("");
     313}
     314
     315function selectionChanged(e)  {
     316    var selected_text = editor.getSession().doc.getTextRange(editor.getSelectionRange());
     317   
     318    //check for hex colour match
     319    if ( selected_text.match('^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$')  != null ){
     320       
     321        var therange = editor.getSelectionRange();
     322        therange.end.column = therange.start.column;
     323        therange.start.column = therange.start.column-1;
     324
     325        // only show color assist if the character before the selection indicates a hex color (#)
     326        if ( editor.getSession().doc.getTextRange( therange ) == "#" ){
     327            jQuery("#wpide_color_assist").show();
     328        }
     329       
     330    }
    313331}
    314332
     
    472490            editor.getSession().on('change', onSessionChange);
    473491           
     492            editor.getSession().selection.on('changeSelection', selectionChanged);
     493           
    474494            editor.resize();
    475495            editor.focus();
     
    565585jQuery(document).ready(function($) {
    566586    $("#wpide_save").click(saveDocument);
    567    
     587
     588    // drag and drop colour picker image
     589    $("#wpide_color_assist").on('drop', function(e) {
     590        e.preventDefault();
     591        e.originalEvent.dataTransfer.items[0].getAsString(function(url){
     592                 
     593                $(".ImageColorPickerCanvas", $("#side-info-column") ).remove();
     594                $("img", $("#wpide_color_assist")).attr('src', url );
     595           
     596        });
     597    });
     598   
     599    $("#wpide_color_assist").on('dragover', function(e) {
     600        $(this).addClass("hover");
     601    }).on('dragleave', function(e) {
     602        $(this).removeClass("hover");
     603    });
    568604
    569605   
    570606    //add div for ace editor to latch on to
    571     //$('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>");
     607    $('#template').prepend("<div style='width:80%;height:500px;margin-right:0!important;' id='fancyeditordiv'></div>");
    572608    //create the editor instance
    573609    editor = ace.edit("fancyeditordiv");
     
    637673                //show command help panel for this command
    638674                wpide_function_help();
    639                 console.log("handler is visible");
     675                //console.log("handler is visible");
    640676               
    641677            }else if( document.getElementById('ac').style.display === 'block'  ) {
     
    646682                    select.selectedIndex = select.selectedIndex-1;
    647683                }
    648                  console.log("ac is visible");
     684                 //console.log("ac is visible");
    649685            } else {
    650686                var range = editor.getSelectionRange();
Note: See TracChangeset for help on using the changeset viewer.