Plugin Directory

Changeset 823750


Ignore:
Timestamp:
12/17/2013 09:07:37 AM (12 years ago)
Author:
evasivesoftware
Message:

Version 0.3 revision

Location:
prettypress
Files:
19 added
7 edited

Legend:

Unmodified
Added
Removed
  • prettypress/trunk/assets/css/prettypress.css

    r820608 r823750  
    164164
    165165.prettypress_nav {
    166     padding: 0 0.5em;
     166    padding: 0 0 0 0.5em;
    167167    height: 32px;
    168168    line-height: 32px;
    169     width: 40.75%;
     169    width: 41%;
    170170}
    171171
  • prettypress/trunk/assets/js/prettypress.js

    r820608 r823750  
    2828    //Set the status.
    2929    this.status = 0;
     30    this.hooked_tinymce = "no";
     31    this.hooked_text = "no";
    3032   
    3133    this.toggle = function() {
     34       
    3235        //Toggles the visibility of preview window.
    3336        if (this.status === 0) {
     
    3538            //Make sure we have a URL to preview.
    3639            if (this.findpageurl() === 1) {
     40               
    3741                jQuery("#wp-content-wrap").addClass("prettypress_entry_field");
    3842                jQuery("#titlewrap").addClass("prettypress_title");
     
    5054                this.status = 1;
    5155                prettypress.resize();
     56               
    5257            } else {
     58               
    5359                //No url visible.
    5460                //Need to "save" draft?
    5561                this.error("Couldn't find any page to draw original theme from. You may need to press 'save' if you have just created this post.", 5000);
     62               
    5663            }
    5764        } else {
     
    6471            this.status = 0;
    6572        }
     73       
    6674    }
    6775   
    6876    this.resize = function() {
     77       
    6978        //Resizes the PrettyPress preview window to fit parent container.
    7079        //Firefox causes issues with this in native CSS.
    7180        var padding = jQuery("#prettypress_wrapper").css("padding-top").replace(/[A-Za-z$-]/g, "");
    7281        padding = parseInt(padding) * 2;
     82       
    7383        var new_height = jQuery("#prettypress_wrapper").css("height").replace(/[A-Za-z$-]/g, "");
    7484        new_height = parseInt(new_height) - padding;
     85       
    7586        var editor_height = new_height - 230;
    7687        new_height = new_height + padding;
     88       
    7789        //Fix the preview window size.
    7890        jQuery("#prettypress_iframe").css("width", jQuery("#prettypress_preview_container").css("width"));
    7991        jQuery("#prettypress_iframe").css("height", new_height + "px");
     92       
    8093        //Fix the editor size.
    8194        jQuery("#content_ifr").css("height", editor_height + "px");
     95       
     96       
    8297    }
    8398   
     
    150165   
    151166    this.updatepreviewcontent = function(type) {
     167       
    152168        var iframe = jQuery("#prettypress_iframe");
    153169        if (prettypress.status === 1) {
     170           
    154171            //Only update for valid requests.
    155172            if (type === "title") {
     
    162179                }
    163180            } else if (type === "content") {
    164                 var tmp_content = tinymce.activeEditor.getContent();
     181                var tmp_content = this.getactivecontent();
    165182                if (tmp_content != this.current_content) {
    166183                    //Update the content.
     
    169186                }
    170187            }
    171         }
     188           
     189        }
     190       
     191    }
     192
     193    this.getactivecontent = function() {
     194
     195        //Find the active editor, and pull the value from it.
     196        //Is the raw text editor visible?
     197       
     198        if ( jQuery("textarea#content").css("display") === "none" ) {
     199            //TinyMCE is active.
     200            return tinymce.activeEditor.getContent();
     201        } else {
     202            //Raw text editor is active.
     203            return jQuery("textarea#content").val();
     204        }
     205       
     206    }
     207
     208
     209    this.hooktinymce = function() {
     210
     211        //Hook TinyMCE.
     212        //Do not call this unless you have verified TinyMCE is active.
     213
     214        tinymce.activeEditor.onKeyUp.add(function(activeEditor, l) {
     215            prettypress.updatepreviewcontent("content");
     216        });
     217   
     218        tinymce.activeEditor.onChange.add(function(activeEditor, l) {
     219            prettypress.updatepreviewcontent("content");
     220        });
     221       
     222    }
     223
     224    this.bootuphooks = function() {
     225
     226        //Hook tinymce / textarea at startup.
     227        //This lets the "live update" feature work.
     228
     229        if ( tinymce.activeEditor != null ) {
     230            prettypress.hooktinymce();
     231            prettypress.hooked_tinymce = "yes";
     232        }
     233       
     234        //Hook textarea.
     235        jQuery("textarea#content").keyup(function(){
     236            prettypress.updatepreviewcontent("content");
     237        });
     238        prettypress.hooked_text = "yes";
     239       
     240    }
     241
     242    this.recursivehooks = function() {
     243
     244        //This function is called every half a second on the chance the bootup hooks had an error.
     245        //This occurs when a user had tinymce disabled / inactive by default.
     246        //This allows PP to hook TinyMCE once its active.
     247       
     248        if ( prettypress.hooked_tinymce === "yes" && prettypress.hooked_text === "yes" ) {
     249            clearInterval(prettypress.recursinghnd);
     250            return false;
     251        } else {
     252
     253            if ( prettypress.hooked_tinymce === "no" ) {
     254                //Attempt to hook tinymce.
     255                if ( tinymce.activeEditor != null ) {
     256                    prettypress.hooktinymce();
     257                    prettypress.hooked_tinymce = "yes";
     258                }
     259            }
     260           
     261        }
     262       
    172263    }
    173264}
  • prettypress/trunk/assets/js/prettypress_hooks.js

    r819371 r823750  
    5353
    5454jQuery(window).load(function() {
    55     tinymce.activeEditor.onKeyUp.add(function(activeEditor, l) {
    56         prettypress.updatepreviewcontent("content");
    57     });
    58     tinymce.activeEditor.onChange.add(function(activeEditor, l) {
    59         prettypress.updatepreviewcontent("content");
    60     });
     55
     56    prettypress.bootuphooks();
     57    prettypress.recursinghnd = window.setInterval( function() {
     58        prettypress.recursivehooks();
     59    }, 500);
     60   
    6161});
  • prettypress/trunk/assets/js/prettypress_resize.js

    r820608 r823750  
    110110
    111111        var new_resize_left = new_left + padding;
    112         var new_resize_menu = new_resize_left - 4;
    113112   
    114113        jQuery(element_wp_content).css("width", new_left + "px");
    115114        jQuery(element_title).css("width", new_left + "px");
    116         jQuery(element_prettypress_menu).css("width", new_resize_menu + "px");
     115        jQuery(element_prettypress_menu).css("width", new_resize_left + "px");
    117116        jQuery(element_prettypress_container).css("width", new_right + "px");
    118117        jQuery(element_prettypress_iframe).css("width", new_right + "px");
  • prettypress/trunk/prettypress.php

    r820608 r823750  
    77Plugin URI: https://github.com/evasivesoftware/PrettyPress
    88Description: A simple Wordpress publishing layout, focused on writing with a live preview of your future post.
    9 Version: 0.2
     9Version: 0.3
    1010Author: EvasiveSoftware.com
    1111Author URI: http://www.evasivesoftware.com/
  • prettypress/trunk/readme.txt

    r820653 r823750  
    55Requires at least: 3.5
    66Tested up to: 3.8
    7 Stable tag: 0.2
     7Stable tag: 0.3
    88License: MIT
    99License URI: http://opensource.org/licenses/MIT
     
    5656== Changelog ==
    5757
     58= 0.3 =
     59* Fixed raw text / html hooks and support
     60* Live preview should now support raw text and html
     61* Fixed bug where live preview would not execute if page was loaded without TinyMCE as default active editor
     62
    5863= 0.2 =
    5964* Added Wordpress 3.8 style support
  • prettypress/trunk/view/edit.php

    r820608 r823750  
    4848    <div class="prettypress_nav wp-ui-primary wp-ui-core wp-submenu" id="prettypress_menu">
    4949        <div class="item item-left" id="prettypress_exit"></div>
    50         <div class="item-left">PrettyPress</div>
     50        <div class="item-left">Back to Wordpress</div>
    5151    </div>
    5252   
Note: See TracChangeset for help on using the changeset viewer.