Plugin Directory

Changeset 1503963


Ignore:
Timestamp:
09/27/2016 07:05:17 PM (9 years ago)
Author:
urre
Message:

Minor

Location:
update-from-bottom
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • update-from-bottom/tags/1.0.3/readme.txt

    r1162822 r1503963  
    11=== Update from Bottom ===
    22Contributors: urre
     3Donate link: https://www.paypal.me/urbansanden
    34Tags: top, scroll, bottom, publish, down, scrolldown
    45Requires at least: 3.0
    5 Tested up to: 4.2.2
     6Tested up to: 4.6.1
    67Stable tag: 1.0.3
    78
  • update-from-bottom/trunk/js/update-from-bottom.admin.js

    r997093 r1503963  
    11(function ($) {
    2     "use strict";
    32
    4     $(window).load( function() {
     3    'use strict';
    54
    6         // Button markup depending on post/page status
    7         if($('#publish').val() == updatefrombottomParams.publish) {
    8             $('<div id="updatefrombottom"><a class="button button-totop">'+updatefrombottomParams.totop+'</a><a class="button button-primary button-large">'+updatefrombottomParams.publish+'</a></div>').appendTo("#wpbody-content");
    9         } else {
    10             $('<div id="updatefrombottom"><a class="button button-totop">'+updatefrombottomParams.totop+'</a><a class="button button-primary button-large">'+updatefrombottomParams.update+'</a></div>').appendTo("#wpbody-content");
    11         }
     5    var UpdateFromBottom = {
    126
    13         // DOM Caching
    14         var elements =  {
    15             box    : $('#updatefrombottom'),
    16             heart  : $('#jsc-heart'),
    17             update  : $('#updatefrombottom .button-primary'),
    18             publish: $('#publish'),
    19             totop : $('#updatefrombottom .button-totop')
    20         }
     7        // Settings
     8        settings :  {
     9            box    : null,
     10            heart  : null,
     11            update  : null,
     12            publish: null,
     13            totop : null,
     14        },
    2115
    22         // Publish/Update content
    23         elements.update.on('click', function(e){
     16        publish: function() {
    2417
    25             if($(this).text() == updatefrombottomParams.publish) {
    26                 $(this).text(updatefrombottomParams.publishing);
    27                 setTimeout(function() {
    28                     $(this).text(updatefrombottomParams.publish);
    29                 }, 2000);
    30             } else {
    31                 $(this).text(updatefrombottomParams.updating);
    32                 setTimeout(function() {
    33                     $(this).text(updatefrombottomParams.update);
    34                 }, 2000);
    35             }
     18            // Publish/Update content
     19            UpdateFromBottom.settings.update.on('click', function(e){
    3620
    37             elements.publish.trigger('click');
     21                if($(this).text() == updatefrombottomParams.publish) {
     22                    $(this).text(updatefrombottomParams.publishing);
     23                    setTimeout(function() {
     24                        $(this).text(updatefrombottomParams.publish);
     25                    }, 2000);
     26                } else {
     27                    $(this).text(updatefrombottomParams.updating);
     28                    setTimeout(function() {
     29                        $(this).text(updatefrombottomParams.update);
     30                    }, 2000);
     31                }
    3832
    39             e.preventDefault();
     33                UpdateFromBottom.settings.publish.trigger('click');
    4034
    41         });
     35                e.preventDefault();
    4236
    43         // Scroll to top
    44         elements.totop.on('click', function(event){
    45             event.preventDefault();
    46             $('html, body').animate({scrollTop : 0}, 600);
    47         });
     37            });
     38        },
    4839
    49         // Check if we are near bottom, show box
    50         $(window).scroll(function(){
    51             if($(window).scrollTop() + $(window).height() > $(document).height() - 40) {
    52                 elements.box.show();
     40        scrollToTop: function() {
    5341
    54             } else {
    55                 elements.box.hide();
    56             }
    57         });
     42            // Scroll to top
     43            UpdateFromBottom.settings.totop.on('click', function(event){
     44                event.preventDefault();
     45                $('html, body').animate({scrollTop : 0}, 600);
     46            });
    5847
    59         // Show box on wide screens
    60         $(window).on('resize', function() {
     48        },
    6149
    62             if($(window).width() > 900 && $(window).height() > 1000) {
    63                 elements.box.show();
    64             } else {
    65                 elements.box.hide();
    66             }
     50        showBox: function() {
    6751
    68         });
     52            // Show box if near bottom
     53            if(($(window).scrollTop() + $(window).height()) > ($(document).height() - 40)) {
     54                UpdateFromBottom.settings.box.show();
     55            } else {
     56                UpdateFromBottom.settings.box.hide();
     57            }
     58        },
    6959
    70     });
     60        showBoxOnWide: function() {
     61
     62            // Show box if neccessary
     63            if($(window).width() > 900 && $(window).height() > 1000) {
     64                UpdateFromBottom.settings.box.show();
     65            } else {
     66                UpdateFromBottom.settings.box.hide();
     67            }
     68
     69        },
     70
     71        AlternateMarkup: function() {
     72            // Button markup depending on post/page status
     73            if($('#updatefrombottom .button-primary').val() == updatefrombottomParams.publish) {
     74                $('<div id="updatefrombottom"><a class="button button-totop">'+updatefrombottomParams.totop+'</a><a class="button button-primary button-large">'+updatefrombottomParams.publish+'</a></div>').appendTo("#wpbody-content");
     75            } else {
     76                $('<div id="updatefrombottom"><a class="button button-totop">'+updatefrombottomParams.totop+'</a><a class="button button-primary button-large">'+updatefrombottomParams.update+'</a></div>').appendTo("#wpbody-content");
     77            }
     78
     79            // Store selectors to settings
     80            UpdateFromBottom.settings.box = $('#updatefrombottom');
     81            UpdateFromBottom.settings.heart = $('#jsc-heart');
     82            UpdateFromBottom.settings.update =  $('#updatefrombottom .button-primary');
     83            UpdateFromBottom.settings.publish = $('#publish');
     84            UpdateFromBottom.settings.totop = $('#updatefrombottom .button-totop');
     85
     86
     87        }
     88
     89    }
     90
     91    $(window).load(function() {
     92
     93        // Alternate markup
     94        UpdateFromBottom.AlternateMarkup();
     95
     96        setTimeout(function() {
     97
     98            // Scroll to top
     99            UpdateFromBottom.scrollToTop();
     100                   
     101             // Publish/Update
     102             UpdateFromBottom.publish();
     103
     104        }, 1000);
     105
     106    });
     107
     108    $(window).scroll(function() {
     109
     110        // Check if we are near bottom, show box   
     111        UpdateFromBottom.showBox();
     112
     113    });
     114
     115    $(window).on('resize', function() {
     116       
     117        // Show box on wide screens
     118        UpdateFromBottom.showBoxOnWide();
     119
     120    });
    71121
    72122}(jQuery));
  • update-from-bottom/trunk/readme.txt

    r1162822 r1503963  
    11=== Update from Bottom ===
    22Contributors: urre
    3 Donate link: http://urre.me/donate
     3Donate link: https://www.paypal.me/urbansanden
    44Tags: top, scroll, bottom, publish, down, scrolldown
    55Requires at least: 3.0
    6 Tested up to: 4.2.2
     6Tested up to: 4.6.1
    77Stable tag: 1.0.3
    88
  • update-from-bottom/trunk/update-from-bottom.php

    r1147036 r1503963  
    101101    $ufb = new UpdatefromBottom();
    102102endif;
     103
     104?>
Note: See TracChangeset for help on using the changeset viewer.