Update for fun service coupon
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Apr 2019 20:39:34 +0000 (16:39 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Apr 2019 20:39:34 +0000 (16:39 -0400)
Adding print button

js/PrintArea/PrintArea.jquery.json [new file with mode: 0644]
js/PrintArea/ReadMe.txt [new file with mode: 0644]
js/PrintArea/jquery.PrintArea.js [new file with mode: 0644]
js/PrintArea/license.txt [new file with mode: 0644]
page-74.php [new file with mode: 0644]
style.css

diff --git a/js/PrintArea/PrintArea.jquery.json b/js/PrintArea/PrintArea.jquery.json
new file mode 100644 (file)
index 0000000..df80405
--- /dev/null
@@ -0,0 +1,15 @@
+{
+"name": "PrintArea",
+"title": "PrintArea",
+"description": "Prints a specific area of the page. Using json settings, the printed area is either opened in a popup or in a hidden iframe. Minimal setup and easy to use. See the demo for examples and usage of the options.",
+"keywords": ["print", "printing"],
+"version": "2.4.0",
+"author": { "name": "Chris Ritschard" },
+"licenses": [
+    {
+    "type": "MIT",
+    "url": "http://www.opensource.org/licenses/mit-license.php"
+    }
+],
+"dependencies": { "jquery": ">=1.9" }
+}
\ No newline at end of file
diff --git a/js/PrintArea/ReadMe.txt b/js/PrintArea/ReadMe.txt
new file mode 100644 (file)
index 0000000..fb14edc
--- /dev/null
@@ -0,0 +1,31 @@
+This software is licensed under the MIT agreement. Please see license.txt for any additional requests.
+
+Update 2.4.0
+    - Issue reported in IE (specifically 11) that the iframe mode is printing the whole page.
+        * After some investigation the demo seemed to break when the external css was not completely loaded from the external site in the iframe.
+
+    - Notes:
+        * Minor version increased.
+        * Added jquery ui dialog to demo (jquery-ui-1.10.4)
+        * Demo is using jquery-1.10.2
+
+Update 2.3.3
+
+    - Issue reported that when using Chrome, css not being applied correctly. Added delay to allow css to be applied correctly to print document.
+        Thanks jer-gallagher-oe for supplying the fix!
+
+Update 2.3.2
+
+    - Fixed bug in IE8 browsers and jquery 1.7 (as reported in issues). Switch from for-in to for-each.
+
+Update 2.3.1
+
+    - Important Changes:
+        * In this version, the document standard is no longer set by the option 'strict'.
+            To accomodate different standards, you can specify one of [strict, loose, html5] as the new 'standard' option.
+        * HTML5 is the default standard for the doc type.
+
+    - Notes:
+        * For <link> elements, you MUST include the 'rel' attribute with a value of 'stylesheet'. Otherwise the stylesheet will not be included in the printed element.
+        * New option : 'extraHead' this is a comma delimited string of additional elements that is added to the head of the printed document.
+            An example of this might be: '<meta charset="utf-8" />,<meta http-equiv="X-UA-Compatible" content="IE=edge"/>'
diff --git a/js/PrintArea/jquery.PrintArea.js b/js/PrintArea/jquery.PrintArea.js
new file mode 100644 (file)
index 0000000..23daa7a
--- /dev/null
@@ -0,0 +1,193 @@
+/**
+ *  Version 2.4.0 Copyright (C) 2013
+ *  Tested in IE 11, FF 28.0 and Chrome 33.0.1750.154
+ *  No official support for other browsers, but will TRY to accommodate challenges in other browsers.
+ *  Example:
+ *      Print Button: <div id="print_button">Print</div>
+ *      Print Area  : <div class="PrintArea" id="MyId" class="MyClass"> ... html ... </div>
+ *      Javascript  : <script>
+ *                       $("div#print_button").click(function(){
+ *                           $("div.PrintArea").printArea( [OPTIONS] );
+ *                       });
+ *                     </script>
+ *  options are passed as json (example: {mode: "popup", popClose: false})
+ *
+ *  {OPTIONS}   | [type]     | (default), values      | Explanation
+ *  ---------   | ---------  | ---------------------- | -----------
+ *  @mode       | [string]   | (iframe),popup         | printable window is either iframe or browser popup
+ *  @popHt      | [number]   | (500)                  | popup window height
+ *  @popWd      | [number]   | (400)                  | popup window width
+ *  @popX       | [number]   | (500)                  | popup window screen X position
+ *  @popY       | [number]   | (500)                  | popup window screen Y position
+ *  @popTitle   | [string]   | ('')                   | popup window title element
+ *  @popClose   | [boolean]  | (false),true           | popup window close after printing
+ *  @extraCss   | [string]   | ('')                   | comma separated list of extra css to include
+ *  @retainAttr | [string[]] | ["id","class","style"] | string array of attributes to retain for the containment area. (ie: id, style, class)
+ *  @standard   | [string]   | strict, loose, (html5) | Only for popup. For html 4.01, strict or loose document standard, or html 5 standard
+ *  @extraHead  | [string]   | ('')                   | comma separated list of extra elements to be appended to the head tag
+ */
+(function($) {
+    var counter = 0;
+    var modes = { iframe : "iframe", popup : "popup" };
+    var standards = { strict : "strict", loose : "loose", html5 : "html5" };
+    var defaults = { mode       : modes.iframe,
+                     standard   : standards.html5,
+                     popHt      : 500,
+                     popWd      : 400,
+                     popX       : 200,
+                     popY       : 200,
+                     popTitle   : '',
+                     popClose   : false,
+                     extraCss   : '',
+                     extraHead  : '',
+                     retainAttr : ["id","class","style"] };
+
+    var settings = {};//global settings
+
+    $.fn.printArea = function( options )
+    {
+        $.extend( settings, defaults, options );
+
+        counter++;
+        var idPrefix = "printArea_";
+        $( "[id^=" + idPrefix + "]" ).remove();
+
+        settings.id = idPrefix + counter;
+
+        var $printSource = $(this);
+
+        var PrintAreaWindow = PrintArea.getPrintWindow();
+
+        PrintArea.write( PrintAreaWindow.doc, $printSource );
+
+        setTimeout( function () { PrintArea.print( PrintAreaWindow ); }, 1000 );
+    };
+
+    var PrintArea = {
+        print : function( PAWindow ) {
+            var paWindow = PAWindow.win;
+
+            $(PAWindow.doc).ready(function(){
+                paWindow.focus();
+                paWindow.print();
+
+                if ( settings.mode == modes.popup && settings.popClose )
+                    setTimeout(function() { paWindow.close(); }, 2000);
+            });
+        },
+        write : function ( PADocument, $ele ) {
+            PADocument.open();
+            PADocument.write( PrintArea.docType() + "<html>" + PrintArea.getHead() + PrintArea.getBody( $ele ) + "</html>" );
+            PADocument.close();
+        },
+        docType : function() {
+            if ( settings.mode == modes.iframe ) return "";
+
+            if ( settings.standard == standards.html5 ) return "<!DOCTYPE html>";
+
+            var transitional = settings.standard == standards.loose ? " Transitional" : "";
+            var dtd = settings.standard == standards.loose ? "loose" : "strict";
+
+            return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01' + transitional + '//EN" "http://www.w3.org/TR/html4/' + dtd +  '.dtd">';
+        },
+        getHead : function() {
+            var extraHead = "";
+            var links = "";
+
+            if ( settings.extraHead ) settings.extraHead.replace( /([^,]+)/g, function(m){ extraHead += m });
+
+            $(document).find("link")
+                .filter(function(){ // Requirement: <link> element MUST have rel="stylesheet" to be considered in print document
+                        var relAttr = $(this).attr("rel");
+                        return ($.type(relAttr) === 'undefined') == false && relAttr.toLowerCase() == 'stylesheet';
+                    })
+                .filter(function(){ // Include if media is undefined, empty, print or all
+                        var mediaAttr = $(this).attr("media");
+                        return $.type(mediaAttr) === 'undefined' || mediaAttr == "" || mediaAttr.toLowerCase() == 'print' || mediaAttr.toLowerCase() == 'all'
+                    })
+                .each(function(){
+                        links += '<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >';
+                    });
+            if ( settings.extraCss ) settings.extraCss.replace( /([^,\s]+)/g, function(m){ links += '<link type="text/css" rel="stylesheet" href="' + m + '">' });
+
+            return "<head><title>" + settings.popTitle + "</title>" + extraHead + links + "</head>";
+        },
+        getBody : function ( elements ) {
+            var htm = "";
+            var attrs = settings.retainAttr;
+            elements.each(function() {
+                var ele = PrintArea.getFormData( $(this) );
+
+                var attributes = ""
+                for ( var x = 0; x < attrs.length; x++ )
+                {
+                    var eleAttr = $(ele).attr( attrs[x] );
+                    if ( eleAttr ) attributes += (attributes.length > 0 ? " ":"") + attrs[x] + "='" + eleAttr + "'";
+                }
+
+                htm += '<div ' + attributes + '>' + $(ele).html() + '</div>';
+            });
+
+            return "<body>" + htm + "</body>";
+        },
+        getFormData : function ( ele ) {
+            var copy = ele.clone();
+            var copiedInputs = $("input,select,textarea", copy);
+            $("input,select,textarea", ele).each(function( i ){
+                var typeInput = $(this).attr("type");
+                if ($.type(typeInput) === 'undefined') typeInput = $(this).is("select") ? "select" : $(this).is("textarea") ? "textarea" : "";
+                var copiedInput = copiedInputs.eq( i );
+
+                if ( typeInput == "radio" || typeInput == "checkbox" ) copiedInput.attr( "checked", $(this).is(":checked") );
+                else if ( typeInput == "text" ) copiedInput.attr( "value", $(this).val() );
+                else if ( typeInput == "select" )
+                    $(this).find( "option" ).each( function( i ) {
+                        if ( $(this).is(":selected") ) $("option", copiedInput).eq( i ).attr( "selected", true );
+                    });
+                else if ( typeInput == "textarea" ) copiedInput.text( $(this).val() );
+            });
+            return copy;
+        },
+        getPrintWindow : function () {
+            switch ( settings.mode )
+            {
+                case modes.iframe :
+                    var f = new PrintArea.Iframe();
+                    return { win : f.contentWindow || f, doc : f.doc };
+                case modes.popup :
+                    var p = new PrintArea.Popup();
+                    return { win : p, doc : p.doc };
+            }
+        },
+        Iframe : function () {
+            var frameId = settings.id;
+            var iframeStyle = 'border:0;position:absolute;width:0px;height:0px;right:0px;top:0px;';
+            var iframe;
+
+            try
+            {
+                iframe = document.createElement('iframe');
+                document.body.appendChild(iframe);
+                $(iframe).attr({ style: iframeStyle, id: frameId, src: "#" + new Date().getTime() });
+                iframe.doc = null;
+                iframe.doc = iframe.contentDocument ? iframe.contentDocument : ( iframe.contentWindow ? iframe.contentWindow.document : iframe.document);
+            }
+            catch( e ) { throw e + ". iframes may not be supported in this browser."; }
+
+            if ( iframe.doc == null ) throw "Cannot find document.";
+
+            return iframe;
+        },
+        Popup : function () {
+            var windowAttr = "location=yes,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no";
+            windowAttr += ",width=" + settings.popWd + ",height=" + settings.popHt;
+            windowAttr += ",resizable=yes,screenX=" + settings.popX + ",screenY=" + settings.popY + ",personalbar=no,scrollbars=yes";
+
+            var newWin = window.open( "", "_blank",  windowAttr );
+
+            newWin.doc = newWin.document;
+
+            return newWin;
+        }
+    };
+})(jQuery);
\ No newline at end of file
diff --git a/js/PrintArea/license.txt b/js/PrintArea/license.txt
new file mode 100644 (file)
index 0000000..a8708c4
--- /dev/null
@@ -0,0 +1,4 @@
+PrintArea is a plugin designed to print specified areas of a web page, as
+designed by the developer.  It is licensed under the MIT agreement.
+
+MIT license: http://opensource.org/licenses/MIT
\ No newline at end of file
diff --git a/page-74.php b/page-74.php
new file mode 100644 (file)
index 0000000..1918714
--- /dev/null
@@ -0,0 +1,49 @@
+<?php get_header(); ?>
+<main class="page-inside">
+    <div id="header-image" class="page-header">
+        <?php echo glm_get_header();?>
+    </div>
+    <div id="content-wrapper">
+        <div class="row">
+            <?php
+            get_template_part('parts/bread-crumbs');
+            ?>
+            <div class="small-12 large-2 add-this-container columns">
+                <?php get_template_part('parts/share-this'); ?>
+            </div>
+        </div>
+        <div class="row">
+
+<script src="<?php echo get_template_directory_uri();?>/js/PrintArea/jquery.PrintArea.js"></script>
+<script>
+jQuery(document).ready(function($) {
+    $(".graph-print").click(function(){
+        var areaToPrint = $(this).attr('data-areaToPrint');
+        var position = $(this).offset();
+        $('#' + areaToPrint).printArea({
+            mode:       'popup',   // printable window is either iframe or browser popup
+            popHt:      800,       // popup window height
+            popWd:      800,       // popup window width
+            popX:       500,       // popup window screen X position
+            popY:       500,       // popup window screen Y position
+            popTitle:   'Receipt', // popup window title element
+            popClose:   true,      // popup window close after printing
+            extraCss:   '',        // Comma separated list of extra css to include
+            extraHead:  '',        // Comma separated list of extra elements to be appended to head tag
+            strict:     false      // strict or looseTransitional html 4.01 document standard or undefined to not include at all only for popup option
+        });
+    });
+});
+</script>
+
+            <div id="main-content" class="small-12 columns">
+                <?php if(have_posts()) : while(have_posts()): the_post();?>
+                <?php the_content();?>
+                <?php endwhile; else:?>
+                <p><?php _e('Sorry, no results found.');?></p>
+                <?php endif;?>
+            </div>
+        </div>
+    </div>
+</main><!--End of main-->
+<?php get_footer(); ?>
index 3d2d261..17ca7f6 100644 (file)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: StarLine
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme for Star Line
-Version: 1.0.45
+Version: 1.0.46
 */