[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16414]
From: |
nelson . guerra |
Subject: |
[Fmsystem-commits] [16414] |
Date: |
Tue, 7 Mar 2017 22:16:36 -0500 (EST) |
Revision: 16414
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16414
Author: nelson224
Date: 2017-03-07 22:16:36 -0500 (Tue, 07 Mar 2017)
Log Message:
-----------
Added Paths:
-----------
branches/dev-syncromind-2/phpgwapi/js/jquery/print/
branches/dev-syncromind-2/phpgwapi/js/jquery/print/.gitignore
branches/dev-syncromind-2/phpgwapi/js/jquery/print/README.md
branches/dev-syncromind-2/phpgwapi/js/jquery/print/bower.json
branches/dev-syncromind-2/phpgwapi/js/jquery/print/jQuery.print.js
branches/dev-syncromind-2/phpgwapi/js/jquery/print/package.json
Added: branches/dev-syncromind-2/phpgwapi/js/jquery/print/.gitignore
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/print/.gitignore
(rev 0)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/print/.gitignore
2017-03-08 03:16:36 UTC (rev 16414)
@@ -0,0 +1,2 @@
+bower_components
+node_modules
Added: branches/dev-syncromind-2/phpgwapi/js/jquery/print/README.md
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/print/README.md
(rev 0)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/print/README.md
2017-03-08 03:16:36 UTC (rev 16414)
@@ -0,0 +1,132 @@
+# jQuery Print Plugin
+
+jQuery.print is a plugin for printing specific parts of a page
+
+## Usage
+
+Include it in your HTML after importing jQuery, like:
+
+```html
+ <script type="text/JavaScript" src="path/to/jquery.print.js" />
+```
+
+Use it like:
+
+```js
+ $("#myElementId").print(/*options*/);
+```
+
+or
+
+```js
+ $.print("#myElementId" /*, options*/);
+```
+
+You can submit the options object like:
+
+```js
+ $("#myElementId").print({
+ globalStyles: true,
+ mediaPrint: false,
+ stylesheet: null,
+ noPrintSelector: ".no-print",
+ iframe: true,
+ append: null,
+ prepend: null,
+ manuallyCopyFormValues: true,
+ deferred: $.Deferred(),
+ timeout: 750,
+ title: null,
+ doctype: '<!doctype html>'
+ });
+```
+
+Currently this plugin supports the following options:
+
+####globalStyles
+
+ - Default: `true`
+ - Acceptable-Values: Boolean
+ - Function: Whether or not the styles from the parent document should be
included
+
+####mediaPrint
+
+ - Default: `false`
+ - Acceptable-Values: Boolean
+ - Function: Whether or not link tags with media='print' should be included;
Over-riden by the `globalStyles` option
+
+####stylesheet
+
+ - Default: `null`
+ - Acceptable-Values: URL-string
+ - Function: URL of an external stylesheet to be included
+
+####noPrintSelector
+
+ - Default: `".no-print"`
+ - Acceptable-Values: Any valid `jQuery-selector`
+ - Function: A selector for the items that are to be excluded from printing
+
+####iframe
+
+ - Default: `true`, creates a hidden iframe if no-vaild iframe selector is
passed
+ - Acceptable-Values: Any valid `jQuery-selector` or Boolean
+ - Function: Whether to print from an iframe instead of a pop-up window; can
take the `jQuery-selector` of an existing iframe as value
+
+####append/prepend
+
+ - Default: `null`
+ - Acceptable-Values: Any valid `jQuery-selector` or HTML-text
+ - Function: Adds custom HTML before (prepend) or after (append) the selected
content
+
+####manuallyCopyFormValues
+
+ - Default: `true`
+ - Acceptable-Values: Boolean
+ - Function: Should it copy user-updated form input values onto the printed
markup (this is done by manually iterating over each form element)
+
+####deferred
+
+ - Default: `$.Deferred()`
+ - Acceptable-Values: Any valid `jQuery.Deferred` object
+ - Function: A jQuery.Deferred object that is resolved once the print function
is called. Can be used [to setup callbacks - see
wiki](https://github.com/DoersGuild/jQuery.print/wiki/Using-the-deferred-option-to-set-up-a-callback-after-printing)
+
+####timeout
+
+ - Default: `750`
+ - Acceptable-Values: Time in Milliseconds for `setTimeout`
+ - Function: To change the amount of max time to wait for the content, etc to
load before printing the element from the new window/iframe created, as a
fallback if the [`load`
event](https://developer.mozilla.org/en-US/docs/Web/Events/load) for the new
window/iframe has not fired yet
+
+####title
+
+ - Default: `null`, uses the host page title
+ - Acceptable-Values: Any single-line string
+ - Function: To change the printed title
+
+####doctype
+
+ - Default: `'<!doctype html>'`
+ - Acceptable-Values: Any valid doctype string
+ - Function: To prepend a doctype to the printed document frame
+
+## Tested with
+
+### jQuery
+* [jQuery](http://jquery.com/) v. 1.7.2
+* [jQuery](http://jquery.com/) v. 1.9.1
+* [jQuery](http://jquery.com/) v. 2.2.0
+* [jQuery](http://jquery.com/) v. 3.1.1
+
+### Browsers
+* Google Chrome - v 20, 26, 48, 55
+* Internet Explorer - v 10, 11
+* Firefox - v 35
+
+## License
+[CC-BY](http://creativecommons.org/licenses/by/3.0/).
+
+## Demo
+[jQuery.print/demo](http://doersguild.github.io/jQuery.print/demo/)
+
+---------------------------------------
+Like our [work](http://doersguild.com)? [Get in touch!](mailto:address@hidden)
Added: branches/dev-syncromind-2/phpgwapi/js/jquery/print/bower.json
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/print/bower.json
(rev 0)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/print/bower.json
2017-03-08 03:16:36 UTC (rev 16414)
@@ -0,0 +1,26 @@
+{
+ "name": "jQuery.print",
+ "main": "jQuery.print.js",
+ "version": "1.5.1",
+ "homepage": "https://doersguild.github.io/jQuery.print/",
+ "authors": [
+ "Sathvik P <address@hidden>"
+ ],
+ "description": "Easy to use, Element Printing Plugin for jQuery, for
printing specific parts of a page",
+ "keywords": [
+ "print",
+ "element printing",
+ "jquery print"
+ ],
+ "dependencies": {
+ "jquery": ">=1.7.2"
+ },
+ "license": "CC-BY",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
Added: branches/dev-syncromind-2/phpgwapi/js/jquery/print/jQuery.print.js
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/print/jQuery.print.js
(rev 0)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/print/jQuery.print.js
2017-03-08 03:16:36 UTC (rev 16414)
@@ -0,0 +1,255 @@
+/* @license
+ * jQuery.print, version 1.5.1
+ * (c) Sathvik Ponangi, Doers' Guild
+ * Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
+ *--------------------------------------------------------------------------*/
+(function ($) {
+ "use strict";
+ // A nice closure for our definitions
+ function getjQueryObject(string) {
+ // Make string a vaild jQuery thing
+ var jqObj = $("");
+ try {
+ jqObj = $(string)
+ .clone();
+ } catch (e) {
+ jqObj = $("<span />")
+ .html(string);
+ }
+ return jqObj;
+ }
+
+ function printFrame(frameWindow, content, options) {
+ // Print the selected window/iframe
+ var def = $.Deferred();
+ try {
+ frameWindow = frameWindow.contentWindow ||
frameWindow.contentDocument || frameWindow;
+ var wdoc = frameWindow.document || frameWindow.contentDocument ||
frameWindow;
+ if(options.doctype) {
+ wdoc.write(options.doctype);
+ }
+ wdoc.write(content);
+ wdoc.close();
+ var printed = false;
+ var callPrint = function () {
+ if(printed) {
+ return;
+ }
+ // Fix for IE : Allow it to render the iframe
+ frameWindow.focus();
+ try {
+ // Fix for IE11 - printng the whole page instead of the
iframe content
+ if (!frameWindow.document.execCommand('print', false,
null)) {
+ // document.execCommand returns false if it failed
-http://stackoverflow.com/a/21336448/937891
+ frameWindow.print();
+ }
+ // focus body as it is losing focus in iPad and content
not getting printed
+ $('body').focus();
+ } catch (e) {
+ frameWindow.print();
+ }
+ frameWindow.close();
+ printed = true;
+ def.resolve();
+ }
+ // Print once the frame window loads - seems to work for the
new-window option but unreliable for the iframe
+ $(frameWindow).on("load", callPrint);
+ // Fallback to printing directly if the frame doesn't fire the
load event for whatever reason
+ setTimeout(callPrint, options.timeout);
+ } catch (err) {
+ def.reject(err);
+ }
+ return def;
+ }
+
+ function printContentInIFrame(content, options) {
+ var $iframe = $(options.iframe + "");
+ var iframeCount = $iframe.length;
+ if (iframeCount === 0) {
+ // Create a new iFrame if none is given
+ $iframe = $('<iframe height="0" width="0" border="0"
wmode="Opaque"/>')
+ .prependTo('body')
+ .css({
+ "position": "absolute",
+ "top": -999,
+ "left": -999
+ });
+ }
+ var frameWindow = $iframe.get(0);
+ return printFrame(frameWindow, content, options)
+ .done(function () {
+ // Success
+ setTimeout(function () {
+ // Wait for IE
+ if (iframeCount === 0) {
+ // Destroy the iframe if created here
+ $iframe.remove();
+ }
+ }, 1000);
+ })
+ .fail(function (err) {
+ // Use the pop-up method if iframe fails for some reason
+ console.error("Failed to print from iframe", err);
+ printContentInNewWindow(content, options);
+ })
+ .always(function () {
+ try {
+ options.deferred.resolve();
+ } catch (err) {
+ console.warn('Error notifying deferred', err);
+ }
+ });
+ }
+
+ function printContentInNewWindow(content, options) {
+ // Open a new window and print selected content
+ var frameWindow = window.open();
+ return printFrame(frameWindow, content, options)
+ .always(function () {
+ try {
+ options.deferred.resolve();
+ } catch (err) {
+ console.warn('Error notifying deferred', err);
+ }
+ });
+ }
+
+ function isNode(o) {
+ /* http://stackoverflow.com/a/384380/937891 */
+ return !!(typeof Node === "object" ? o instanceof Node : o && typeof o
=== "object" && typeof o.nodeType === "number" && typeof o.nodeName ===
"string");
+ }
+ $.print = $.fn.print = function () {
+ // Print a given set of elements
+ var options, $this, self = this;
+ // console.log("Printing", this, arguments);
+ if (self instanceof $) {
+ // Get the node if it is a jQuery object
+ self = self.get(0);
+ }
+ if (isNode(self)) {
+ // If `this` is a HTML element, i.e. for
+ // $(selector).print()
+ $this = $(self);
+ if (arguments.length > 0) {
+ options = arguments[0];
+ }
+ } else {
+ if (arguments.length > 0) {
+ // $.print(selector,options)
+ $this = $(arguments[0]);
+ if (isNode($this[0])) {
+ if (arguments.length > 1) {
+ options = arguments[1];
+ }
+ } else {
+ // $.print(options)
+ options = arguments[0];
+ $this = $("html");
+ }
+ } else {
+ // $.print()
+ $this = $("html");
+ }
+ }
+ // Default options
+ var defaults = {
+ globalStyles: true,
+ mediaPrint: false,
+ stylesheet: null,
+ noPrintSelector: ".no-print",
+ iframe: true,
+ append: null,
+ prepend: null,
+ manuallyCopyFormValues: true,
+ deferred: $.Deferred(),
+ timeout: 750,
+ title: null,
+ doctype: '<!doctype html>'
+ };
+ // Merge with user-options
+ options = $.extend({}, defaults, (options || {}));
+ var $styles = $("");
+ if (options.globalStyles) {
+ // Apply the stlyes from the current sheet to the printed page
+ $styles = $("style, link, meta, base, title");
+ } else if (options.mediaPrint) {
+ // Apply the media-print stylesheet
+ $styles = $("link[media=print]");
+ }
+ if (options.stylesheet) {
+ // Add a custom stylesheet if given
+ $styles = $.merge($styles, $('<link rel="stylesheet" href="' +
options.stylesheet + '">'));
+ }
+ // Create a copy of the element to print
+ var copy = $this.clone();
+ // Wrap it in a span to get the HTML markup string
+ copy = $("<span/>")
+ .append(copy);
+ // Remove unwanted elements
+ copy.find(options.noPrintSelector)
+ .remove();
+ // Add in the styles
+ copy.append($styles.clone());
+ // Update title
+ if (options.title) {
+ var title = $("title", copy);
+ if (title.length === 0) {
+ title = $("<title />");
+ copy.append(title);
+ }
+ title.text(options.title);
+ }
+ // Appedned content
+ copy.append(getjQueryObject(options.append));
+ // Prepended content
+ copy.prepend(getjQueryObject(options.prepend));
+ if (options.manuallyCopyFormValues) {
+ // Manually copy form values into the HTML for printing
user-modified input fields
+ // http://stackoverflow.com/a/26707753
+ copy.find("input")
+ .each(function () {
+ var $field = $(this);
+ if ($field.is("[type='radio']") ||
$field.is("[type='checkbox']")) {
+ if ($field.prop("checked")) {
+ $field.attr("checked", "checked");
+ }
+ } else {
+ $field.attr("value", $field.val());
+ }
+ });
+ copy.find("select").each(function () {
+ var $field = $(this);
+ $field.find(":selected").attr("selected", "selected");
+ });
+ copy.find("textarea").each(function () {
+ // Fix for
https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
+ var $field = $(this);
+ $field.text($field.val());
+ });
+ }
+ // Get the HTML markup string
+ var content = copy.html();
+ // Notify with generated markup & cloned elements - useful for
logging, etc
+ try {
+ options.deferred.notify('generated_markup', content, copy);
+ } catch (err) {
+ console.warn('Error notifying deferred', err);
+ }
+ // Destroy the copy
+ copy.remove();
+ if (options.iframe) {
+ // Use an iframe for printing
+ try {
+ printContentInIFrame(content, options);
+ } catch (e) {
+ // Use the pop-up method if iframe fails for some reason
+ console.error("Failed to print from iframe", e.stack,
e.message);
+ printContentInNewWindow(content, options);
+ }
+ } else {
+ // Use a new window for printing
+ printContentInNewWindow(content, options);
+ }
+ return this;
+ };
+})(jQuery);
Added: branches/dev-syncromind-2/phpgwapi/js/jquery/print/package.json
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/print/package.json
(rev 0)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/print/package.json
2017-03-08 03:16:36 UTC (rev 16414)
@@ -0,0 +1,31 @@
+{
+ "name": "jQuery.print",
+ "filename": "jQuery.print.min.js",
+ "version": "1.5.1",
+ "homepage": "https://doersguild.github.io/jQuery.print/",
+ "authors": [
+ "Sathvik P <address@hidden>"
+ ],
+ "description": "Easy to use, Element Printing Plugin for jQuery, for
printing specific parts of a page",
+ "keywords": [
+ "print",
+ "element printing",
+ "jquery print"
+ ],
+ "dependencies": {
+ "jquery": ">=1.7.2"
+ },
+ "license": "CC-BY",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/DoersGuild/jQuery.print.git"
+ },
+ "autoupdate": {
+ "source": "git",
+ "target": "git://github.com/DoersGuild/jQuery.print.git",
+ "basePath": "",
+ "files": [
+ "jQuery.print*"
+ ]
+ }
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16414],
nelson . guerra <=