Initial commit
This commit is contained in:
835
wp-content/plugins/gp-premium/sites/assets/css/admin.css
Normal file
835
wp-content/plugins/gp-premium/sites/assets/css/admin.css
Normal file
@ -0,0 +1,835 @@
|
||||
.appearance_page_generatepress-site-library #wpcontent,
|
||||
.appearance_page_generatepress-site-library #wpbody-content .metabox-holder {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.generate-site-library .site-library-header {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 1px 0 rgba(200,215,225,0.5), 0 1px 2px #DDD;
|
||||
margin-bottom: 40px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.site-library-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-site-library a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.site-library-header .site-library-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.library-links {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.library-links a {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.library-title {
|
||||
font-size: 20px;
|
||||
color: #000;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.generatepress-admin-block {
|
||||
transition: opacity 300ms ease-in-out;
|
||||
}
|
||||
|
||||
.generatepress-sites {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
grid-gap: 40px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.generatepress-sites.site-open {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.generatepress-sites.site-open .site-box {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.generatepress-sites:not(.site-open) .site-box h3 {
|
||||
margin: 0 0 20px;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.generatepress-sites .site-screenshot img {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.step-information {
|
||||
padding: 0 0 0 20px;
|
||||
grid-area: left;
|
||||
}
|
||||
|
||||
.step-information,
|
||||
.step-information p {
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.step-information p:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.step-information h3 {
|
||||
margin-top: 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.loading svg path,
|
||||
.loading svg rect {
|
||||
fill: #0073aa;
|
||||
}
|
||||
|
||||
.step-information li {
|
||||
list-style-type: disc;
|
||||
list-style-position: inside;
|
||||
margin-bottom: 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.site-open .steps {
|
||||
display: grid;
|
||||
grid-template-rows: initial;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
grid-template-areas: "left right";
|
||||
}
|
||||
|
||||
.site-open .site-overview-information {
|
||||
grid-area: left;
|
||||
}
|
||||
|
||||
.site-box {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.generatepress-sites:not(.site-open) .site-box .controls {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.site-box .controls {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.site-box .controls button,
|
||||
.site-demo .demo-panel button:not(.get-started) {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel button:not(.get-started) {
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.site-box .controls button:hover,
|
||||
.site-demo .demo-panel button:not(.get-started):hover {
|
||||
color: #0073aa;
|
||||
}
|
||||
|
||||
.site-box .steps:not(.step-overview) .controls .next,
|
||||
.site-box .steps:not(.step-overview) .controls .prev {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.site-box .close:before,
|
||||
.site-demo .close-demo:before {
|
||||
content: "\f335";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.site-box .prev:before,
|
||||
.site-demo .previous-demo:before {
|
||||
content: "\f341";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.site-box .next:before,
|
||||
.site-demo .next-demo:before {
|
||||
content: "\f345";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.step-note {
|
||||
font-size: 10px;
|
||||
padding: 5px 10px;
|
||||
text-transform: uppercase;
|
||||
background: #eee;
|
||||
margin-left: 10px;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
}
|
||||
|
||||
.site-demo {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 99999;
|
||||
padding-top: 68px;
|
||||
}
|
||||
|
||||
.site-demo iframe {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: calc(100% - 68px);
|
||||
}
|
||||
|
||||
.demo-loading {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-top: -25px;
|
||||
margin-left: -25px;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.demo-loading.loading svg {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
box-shadow: 0px 0px 20px 0px rgba(38,50,56,0.25);
|
||||
text-align: center;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.demo-panel .left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.demo-panel button.get-started {
|
||||
line-height: 40px;
|
||||
height: 40px;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
font-size: 15px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.automatic-plugins .installing-plugins:first-child:after,
|
||||
.automatic-plugins .installing-plugins.show-loading:after {
|
||||
content: "";
|
||||
opacity: 1;
|
||||
display: inline-block;
|
||||
height: 17px;
|
||||
width: 17px;
|
||||
background-image: url(loading.svg);
|
||||
background-size: 17px 17px;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
line-height: 17px;
|
||||
vertical-align: top;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.automatic-plugins .plugin-installed:after {
|
||||
font-family: dashicons;
|
||||
content: "\f147";
|
||||
color: green;
|
||||
line-height: 1;
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start the CSS for the list of site boxes we initially see.
|
||||
*/
|
||||
.site-screenshot {
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.site-screenshot img {
|
||||
max-width: 100%;
|
||||
transition: all 300ms ease-in-out;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.lazyload{
|
||||
-webkit-transition: opacity 500ms ease-in-out;
|
||||
-moz-transition: opacity 500ms ease-in-out;
|
||||
-o-transition: opacity 500ms ease-in-out;
|
||||
transition: opacity 500ms ease-in-out;
|
||||
max-width: 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.lazyload.b-loaded {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.step-one {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.generatepress-sites:not(.site-open) .site-box:not(:hover) .site-screenshot {
|
||||
box-shadow: 0 0 10px rgba( 0,0,0,0.1 );
|
||||
}
|
||||
|
||||
.site-box:hover .step-one {
|
||||
box-shadow: 0 0 10px rgba( 0,0,0,0.1 );
|
||||
}
|
||||
|
||||
.step-one .site-info {
|
||||
background: #fff;
|
||||
border-top: 1px solid #ddd;
|
||||
color: #222;
|
||||
display: block;
|
||||
opacity: 0;
|
||||
padding: 20px 40px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
z-index: 15;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.site-box:hover .step-one .site-info {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.steps .site-title {
|
||||
text-align: center;
|
||||
padding-top: 15px;
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.site-box:hover .step-one .site-title {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.step-one .author-name {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.site-description button {
|
||||
margin: 0 5px !important;
|
||||
}
|
||||
|
||||
.step-one .site-info a,
|
||||
.step-one .site-description a {
|
||||
color: initial;
|
||||
}
|
||||
|
||||
.plugin-error {
|
||||
padding-left: 10px;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.plugin-error:before {
|
||||
font-family: dashicons;
|
||||
content: "\f335";
|
||||
padding-right: 3px;
|
||||
line-height: 1;
|
||||
font-size: 13px;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.generate-sites .notice {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.refresh-sites {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.generatepress-sites.site-open + .refresh-sites {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.site-library-tabs-wrapper {
|
||||
display: flex;
|
||||
margin-bottom: 40px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.site-library-tabs-wrapper .generatepress-dashboard-tabs {
|
||||
margin-bottom: 0;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.filter-select {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.filter-select:after {
|
||||
font-family: dashicons;
|
||||
content: "\f347";
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.filter-select select {
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
padding: 0 30px 0 10px;
|
||||
box-shadow: none;
|
||||
background-image: none;
|
||||
-webkit-appearance: none;
|
||||
cursor: pointer;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
}
|
||||
|
||||
.filter-select select:focus {
|
||||
outline: 0;
|
||||
border: 1px solid #bbb;
|
||||
}
|
||||
|
||||
.page-builder-filter {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.page-builder-filter span {
|
||||
font-size: 13px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.page-builder-label {
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.site-demo iframe {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.site-demo.mobile iframe {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.site-demo.tablet iframe {
|
||||
width: 768px;
|
||||
}
|
||||
|
||||
.site-demo.open:after {
|
||||
content: "";
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0,0,0,0.8);
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.site-demo .show-desktop:before {
|
||||
content: "\f472";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.site-demo .show-tablet:before {
|
||||
content: "\f471";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.site-demo .show-mobile:before {
|
||||
content: "\f470";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel button.close-demo {
|
||||
border-right: 1px solid #ddd;
|
||||
margin-right: 10px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel button.show-desktop {
|
||||
border-left: 1px solid #ddd;
|
||||
margin-left: 10px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel button.show-mobile {
|
||||
border-right: 1px solid #ddd;
|
||||
margin-right: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.site-demo .demo-panel button.active {
|
||||
color: #0073aa;
|
||||
}
|
||||
|
||||
.version-required-message {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.disabled-site {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.disabled-site > * {
|
||||
pointer-events :none;
|
||||
}
|
||||
|
||||
.site-step-details > div {
|
||||
border-bottom: 1px solid #ddd;
|
||||
margin: 0 0 30px;
|
||||
padding: 0 0 30px 60px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.site-step-details > div:last-child {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.site-step-details > div p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.number,
|
||||
.big-loader {
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #fff;
|
||||
border-radius: 50%;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
border: 2px solid #555;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
transition: opacity 250ms ease-in-out;
|
||||
}
|
||||
|
||||
.site-step-details > div:nth-child(1) .number:before {
|
||||
content: "1";
|
||||
}
|
||||
|
||||
.site-step-details > div:nth-child(2) .number:before {
|
||||
content: "2";
|
||||
}
|
||||
|
||||
.site-step-details > div:nth-child(3) .number:before {
|
||||
content: "3";
|
||||
}
|
||||
|
||||
.site-step-details > div:nth-child(4) .number:before {
|
||||
content: "4";
|
||||
}
|
||||
|
||||
.big-loader {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.big-loader svg {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
position: relative;
|
||||
top: -5px;
|
||||
left: -5px;
|
||||
}
|
||||
|
||||
.site-step-details > div .number.step-complete:before {
|
||||
content: "\f147";
|
||||
font-family: dashicons;
|
||||
color: #4BB543;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.number.step-complete {
|
||||
border-color: #4BB543;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.site-step-details h3 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.site-step-details p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.replace-elementor-urls,
|
||||
.site-step-details .replace-elementor-urls p:not(:first-child) {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.action-area {
|
||||
margin: 40px 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.action-buttons input[type="submit"] {
|
||||
border-radius: 0;
|
||||
font-size: 17px;
|
||||
line-height: 50px;
|
||||
height: auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.big-loader {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.loading,
|
||||
.error-message {
|
||||
font-size: 15px;
|
||||
line-height: 52px;
|
||||
}
|
||||
|
||||
.loading svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
.checking-for-plugins {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.action-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.important-note {
|
||||
padding-left: 20px;
|
||||
width: 75%;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.important-note label {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.important-note input {
|
||||
position: relative;
|
||||
top: 3px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.site-open .site-box .step-information {
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #DDD;
|
||||
padding: 40px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.step-information h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.site-open .site-overview-details {
|
||||
grid-area: right;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.site-open .site-description h3 {
|
||||
margin-bottom: 0;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.site-open .site-screenshot {
|
||||
margin-bottom: 40px;
|
||||
padding: 5px;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #DDD;
|
||||
}
|
||||
|
||||
.site-description > div:not(:last-child) {
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.site-description > div > *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.site-step-details ul li {
|
||||
list-style-type: none;
|
||||
display: inline-block;
|
||||
padding: 2px 5px;
|
||||
background: #f5f5f5;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.elementor-urls input {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.elementor-urls label {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.elementor-urls {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.site-open .site-box .controls button {
|
||||
background: #fff;
|
||||
border: none;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
padding: 10px;
|
||||
line-height: 1;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #DDD;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.site-open .site-box .controls button:before {
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.site-open .site-box .controls .preview-site {
|
||||
font-size: inherit;
|
||||
color: #000;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
margin-left: auto;
|
||||
margin-right: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.site-open .site-box .controls .preview-site:hover {
|
||||
color: #0073aa;
|
||||
}
|
||||
|
||||
.site-box:not(.no-page-builder) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.site-card-buttons {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.site-card-buttons button.button,
|
||||
.site-card-buttons button.button-primary {
|
||||
width: 50%;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.site-details p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.plugin-area {
|
||||
display: none;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.site-plugins {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.skip-content-import {
|
||||
font-size: 11px;
|
||||
font-weight: normal;
|
||||
padding: 2px 5px;
|
||||
margin-left: 5px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.no-site-library-results {
|
||||
text-align: center;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.remove-site {
|
||||
background: #fff;
|
||||
padding: 40px;
|
||||
box-shadow: 0 0 10px 10px rgba(0,0,0,0.01);
|
||||
border: 1px solid #ddd;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.remove-site h2 {
|
||||
margin-top: 0;
|
||||
font-size: 25px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.remove-site button.button-primary {
|
||||
font-size: 17px;
|
||||
line-height: 50px;
|
||||
height: 50px;
|
||||
padding: 0 20px;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.remove-site .loading {
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.close-remove-site,
|
||||
.skip-remove-site {
|
||||
display: inline-block;
|
||||
margin-left: 15px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.remove-site p {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.remove-site-actions {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.generatepress-sites.remove-site-needed {
|
||||
pointer-events: none;
|
||||
opacity: 0.2;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
|
||||
<path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/>
|
||||
<path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0C22.32,8.481,24.301,9.057,26.013,10.047z">
|
||||
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20" dur="0.5s" repeatCount="indefinite"/>
|
||||
</path>
|
||||
</svg>
|
After Width: | Height: | Size: 888 B |
BIN
wp-content/plugins/gp-premium/sites/assets/images/screenshot.png
Normal file
BIN
wp-content/plugins/gp-premium/sites/assets/images/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
913
wp-content/plugins/gp-premium/sites/assets/js/admin.js
Normal file
913
wp-content/plugins/gp-premium/sites/assets/js/admin.js
Normal file
@ -0,0 +1,913 @@
|
||||
jQuery( document ).ready( function($) {
|
||||
|
||||
var bLazy = new Blazy({
|
||||
selector: '.lazyload',
|
||||
success: function(ele){
|
||||
$( ele ).parent().addClass( 'image-loaded' );
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Demo sites
|
||||
*/
|
||||
$( '.site-box .preview-site' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
var _this = $( this );
|
||||
var site_box = _this.closest( '.site-box' );
|
||||
|
||||
if ( ! site_box.find( 'iframe' ).attr( 'src' ) ) {
|
||||
site_box.find( 'iframe' ).attr( 'src', site_box.data( 'site-data' ).preview_url );
|
||||
}
|
||||
|
||||
site_box.find( 'iframe' ).on( 'load', function () {
|
||||
site_box.find( '.demo-loading' ).fadeOut().remove();
|
||||
});
|
||||
|
||||
site_box.find( '.site-demo' ).show().addClass( 'open' );
|
||||
} );
|
||||
|
||||
$( '.site-demo .close-demo' ).on( 'click', function( e ) {
|
||||
$( '.site-demo' ).hide().removeClass( 'open' );
|
||||
bLazy.revalidate();
|
||||
} );
|
||||
|
||||
$( '.demo-panel .show-desktop' ).on( 'click', function( e ) {
|
||||
$( this ).addClass( 'active' ).siblings().removeClass( 'active' );
|
||||
$( '.site-demo' ).removeClass( 'mobile' ).removeClass( 'tablet' );
|
||||
} );
|
||||
|
||||
$( '.demo-panel .show-tablet' ).on( 'click', function( e ) {
|
||||
$( this ).addClass( 'active' ).siblings().removeClass( 'active' );
|
||||
$( '.site-demo' ).removeClass( 'mobile' ).addClass( 'tablet' );
|
||||
} );
|
||||
|
||||
$( '.demo-panel .show-mobile' ).on( 'click', function( e ) {
|
||||
$( this ).addClass( 'active' ).siblings().removeClass( 'active' );
|
||||
$( '.site-demo' ).addClass( 'mobile' ).removeClass( 'tablet' );
|
||||
} );
|
||||
|
||||
$( '.site-demo .get-started' ).on( 'click', function( e ) {
|
||||
$( '.site-demo' ).hide().removeClass( 'open' );
|
||||
|
||||
if ( ! $( '.generatepress-sites' ).hasClass( 'site-open' ) ) {
|
||||
var this_site = $( this ).closest( '.site-box' );
|
||||
|
||||
$( '.generatepress-sites' ).addClass( 'site-open' );
|
||||
$( '.library-filters' ).hide();
|
||||
var screenshot = this_site.find( '.site-card-screenshot img' ).attr( 'src' );
|
||||
|
||||
this_site.find( '.site-overview-screenshot img' ).attr( 'src', screenshot );
|
||||
this_site.siblings().hide();
|
||||
this_site.find( '.step-one' ).hide().next().show();
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Site card controls
|
||||
*/
|
||||
$( '.site-box .close' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
var siteBox = $( '.site-box' ),
|
||||
page_builder = $( '.generatepress-sites' ).attr( 'data-page-builder' );
|
||||
|
||||
siteBox.find( '.steps' ).hide();
|
||||
siteBox.find( '.step-one' ).fadeIn().css( 'display', '' );
|
||||
|
||||
$( '.generatepress-sites' ).removeClass( 'site-open' );
|
||||
$( '.library-filters' ).show();
|
||||
siteBox.siblings( page_builder ).fadeIn( 'fast' );
|
||||
|
||||
bLazy.revalidate();
|
||||
|
||||
if ( $( 'body' ).hasClass( 'site-import-data-exists' ) ) {
|
||||
$( '.remove-site' ).show();
|
||||
$( '.remove-site .do-remove-site' ).show();
|
||||
$( '.remove-site .skip-remove-site' ).show();
|
||||
$( '.generatepress-sites' ).addClass( 'remove-site-needed' );
|
||||
window.scrollTo( { top: 0 } );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.site-box .next' ).on( 'click', function( e ) {
|
||||
var page_builder = $( '.generatepress-sites' ).attr( 'data-page-builder' );
|
||||
var this_site = $( this ).closest( '.site-box' );
|
||||
var next_site = this_site.nextAll( page_builder ).not( '.disabled-site' ).first();
|
||||
|
||||
if ( ! next_site.length ) {
|
||||
next_site = $( '.generatepress-sites' ).find( '.site-box' + page_builder ).first();
|
||||
}
|
||||
|
||||
var screenshot = next_site.find( '.site-card-screenshot img' ).attr( 'data-src' );
|
||||
|
||||
if ( ! screenshot ) {
|
||||
screenshot = next_site.find( '.site-card-screenshot img' ).attr( 'src' );
|
||||
}
|
||||
|
||||
if ( this_site.parent().hasClass( 'site-open' ) ) {
|
||||
this_site.hide();
|
||||
next_site.show().find( '.step-one' ).hide().next().show();
|
||||
next_site.find( '.site-overview-screenshot img' ).attr( 'src', screenshot );
|
||||
}
|
||||
|
||||
if ( this_site.find( '.site-demo' ).hasClass( 'open' ) ) {
|
||||
this_site.find( '.site-demo' ).hide().removeClass( 'open' );
|
||||
|
||||
if ( ! next_site.find( 'iframe' ).attr( 'src' ) ) {
|
||||
next_site.find( 'iframe' ).attr( 'src', next_site.data( 'site-data' ).preview_url );
|
||||
}
|
||||
|
||||
next_site.find( 'iframe' ).on( 'load', function () {
|
||||
next_site.find( '.demo-loading' ).fadeOut().remove();
|
||||
});
|
||||
|
||||
next_site.find( '.site-demo' ).show().addClass( 'open' );
|
||||
}
|
||||
|
||||
if ( $( 'body' ).hasClass( 'site-import-data-exists' ) ) {
|
||||
$( '.remove-site' ).show();
|
||||
$( '.remove-site .do-remove-site' ).show();
|
||||
$( '.remove-site .skip-remove-site' ).show();
|
||||
$( '.generatepress-sites' ).addClass( 'remove-site-needed' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.site-box .prev' ).on( 'click', function( e ) {
|
||||
var page_builder = $( '.generatepress-sites' ).attr( 'data-page-builder' );
|
||||
var this_site = $( this ).closest( '.site-box' );
|
||||
var prev_site = this_site.prevAll( page_builder ).not( '.disabled-site' ).first();
|
||||
|
||||
if ( ! prev_site.length ) {
|
||||
prev_site = $( '.generatepress-sites' ).find( '.site-box' + page_builder ).last();
|
||||
}
|
||||
|
||||
var screenshot = prev_site.find( '.site-card-screenshot img' ).attr( 'data-src' );
|
||||
|
||||
if ( ! screenshot ) {
|
||||
screenshot = prev_site.find( '.site-card-screenshot img' ).attr( 'src' );
|
||||
}
|
||||
|
||||
if ( this_site.parent().hasClass( 'site-open' ) ) {
|
||||
this_site.hide();
|
||||
prev_site.show().find( '.step-one' ).hide().next().show();
|
||||
prev_site.find( '.site-overview-screenshot img' ).attr( 'src', screenshot );
|
||||
}
|
||||
|
||||
if ( this_site.find( '.site-demo' ).hasClass( 'open' ) ) {
|
||||
this_site.find( '.site-demo' ).hide().removeClass( 'open' );
|
||||
|
||||
if ( ! prev_site.find( 'iframe' ).attr( 'src' ) ) {
|
||||
prev_site.find( 'iframe' ).attr( 'src', prev_site.data( 'site-data' ).preview_url );
|
||||
}
|
||||
|
||||
prev_site.find( 'iframe' ).on( 'load', function () {
|
||||
prev_site.find( '.demo-loading' ).fadeOut().remove();
|
||||
});
|
||||
|
||||
prev_site.find( '.site-demo' ).show().addClass( 'open' );
|
||||
}
|
||||
|
||||
if ( $( 'body' ).hasClass( 'site-import-data-exists' ) ) {
|
||||
$( '.remove-site' ).show();
|
||||
$( '.remove-site .do-remove-site' ).show();
|
||||
$( '.remove-site .skip-remove-site' ).show();
|
||||
$( '.generatepress-sites' ).addClass( 'remove-site-needed' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.site-box .site-details' ).on( 'click', function( e ) {
|
||||
var _this = $( this ),
|
||||
siteBox = _this.closest( '.site-box' ),
|
||||
step = _this.closest( '.steps' ),
|
||||
screenshot = step.find( '.site-card-screenshot img' ).attr( 'data-src' );
|
||||
|
||||
if ( ! screenshot ) {
|
||||
screenshot = step.find( '.site-card-screenshot img' ).attr( 'src' );
|
||||
}
|
||||
|
||||
$( '.generatepress-sites' ).addClass( 'site-open' );
|
||||
$( '.library-filters' ).hide();
|
||||
|
||||
_this.closest( '.site-box' ).siblings().hide();
|
||||
step.hide();
|
||||
step.next().fadeIn( 'fast' );
|
||||
siteBox.find( '.site-overview-screenshot img' ).attr( 'src', screenshot );
|
||||
} );
|
||||
|
||||
$( '.confirm-content-import' ).on( 'change', function() {
|
||||
var siteBox = $( this ).closest( '.site-box' );
|
||||
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
siteBox.find( 'input.import-content' ).attr( 'disabled', false );
|
||||
} else {
|
||||
siteBox.find( 'input.import-content' ).attr( 'disabled', 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.confirm-options-import' ).on( 'change', function() {
|
||||
var siteBox = $( this ).closest( '.site-box' );
|
||||
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
siteBox.find( 'input.backup-options' ).attr( 'disabled', false );
|
||||
siteBox.find( 'input.import-options' ).attr( 'disabled', false );
|
||||
} else {
|
||||
siteBox.find( 'input.backup-options' ).attr( 'disabled', 'disabled' );
|
||||
siteBox.find( 'input.import-options' ).attr( 'disabled', 'disabled' );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.page-builder-group' ).on( 'change', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this ),
|
||||
filter = _this.val();
|
||||
|
||||
// _this.siblings().removeClass( 'active' );
|
||||
// _this.addClass( 'active' );
|
||||
|
||||
if ( '' == filter ) {
|
||||
$( '.site-box' ).show();
|
||||
$( '.generatepress-sites' ).attr( 'data-page-builder', '' );
|
||||
} else {
|
||||
$( '.site-box:not(.' + filter + ')' ).hide();
|
||||
$( '.site-box.' + filter ).show();
|
||||
$( '.generatepress-sites' ).attr( 'data-page-builder', '.' + filter );
|
||||
}
|
||||
|
||||
bLazy.revalidate();
|
||||
} );
|
||||
|
||||
var setup_demo_content = function( _this ) {
|
||||
var site_box = _this.closest( '.site-box' );
|
||||
var site_data = site_box.data( 'site-data' );
|
||||
|
||||
if ( ! site_box.hasClass( 'data-content-loaded' ) ) {
|
||||
// Prevent duplicate setup.
|
||||
site_box.addClass( 'data-content-loaded' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_setup_demo_content_' + site_data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log(data);
|
||||
|
||||
if ( data.content ) {
|
||||
if ( data.widgets ) {
|
||||
site_box.find( '.site-action.import-content' ).attr( 'data-widgets', true );
|
||||
} else {
|
||||
site_box.find( '.site-action.import-content' ).attr( 'data-widgets', false );
|
||||
}
|
||||
|
||||
if ( data.plugins ) {
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_check_plugins_' + site_data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
data: site_box.data( 'site-data' ),
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
site_box.find( '.site-plugins' ).hide();
|
||||
site_box.find( '.plugin-area' ).show();
|
||||
site_box.find( '.site-action.import-content' ).attr( 'data-plugins', JSON.stringify( data.plugin_data ) );
|
||||
|
||||
$.each( data.plugin_data, function( index, value ) {
|
||||
var slug = value.slug.substring( 0, value.slug.indexOf( '/' ) );
|
||||
|
||||
if ( value.repo && ! value.installed ) {
|
||||
site_box.find( '.automatic-plugins' ).fadeIn();
|
||||
site_box.find( '.automatic-plugins ul' ).append( '<li data-slug="' + slug + '">' + value.name + '</li>' );
|
||||
} else if ( value.installed || value.active ) {
|
||||
site_box.find( '.installed-plugins' ).fadeIn();
|
||||
site_box.find( '.installed-plugins ul' ).append( '<li class="plugin-installed" data-slug="' + slug + '">' + value.name + '</li>' );
|
||||
} else {
|
||||
site_box.find( '.manual-plugins' ).fadeIn();
|
||||
site_box.find( '.manual-plugins ul' ).append( '<li>' + value.name + '</li>' );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( $.isEmptyObject( data.plugin_data ) ) {
|
||||
site_box.find( '.no-plugins' ).fadeIn();
|
||||
}
|
||||
|
||||
site_box.find( '.loading' ).hide();
|
||||
site_box.find( '.site-action.import-content' ).show();
|
||||
site_box.find( '.confirm-content-import-message' ).show();
|
||||
site_box.find( '.skip-content-import' ).show();
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
site_box.find( '.site-message' ).hide();
|
||||
site_box.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
site_box.find( '.loading' ).hide();
|
||||
site_box.find( '.site-action.import-content' ).show();
|
||||
site_box.find( '.confirm-content-import-message' ).show();
|
||||
site_box.find( '.skip-content-import' ).show();
|
||||
}
|
||||
} else {
|
||||
site_box.find( '.loading' ).hide();
|
||||
site_box.find( '.demo-content .big-loader' ).css( 'opacity', '0' );
|
||||
site_box.find( '.demo-content .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
_this.next( 'input' ).show();
|
||||
|
||||
setTimeout( function() {
|
||||
site_box.find( '.import-complete .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
}, 500 );
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
site_box.removeClass( 'data-loaded' );
|
||||
site_box.find( '.loading' ).hide();
|
||||
site_box.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Backup options.
|
||||
*/
|
||||
$( '.site-box .backup-options' ).on( 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this ),
|
||||
siteBox = _this.closest( '.site-box' );
|
||||
|
||||
_this.hide();
|
||||
siteBox.find( '.confirm-backup-options' ).hide();
|
||||
backup_options( _this );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Backup and import theme options.
|
||||
*/
|
||||
$( '.site-box .import-options' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this );
|
||||
|
||||
_this.hide();
|
||||
_this.closest( '.site-box' ).find( '.confirm-backup-options' ).hide();
|
||||
import_options( _this );
|
||||
} );
|
||||
|
||||
function backup_options( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' )
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.backing_up_options );
|
||||
siteBox.find( '.loading' ).show();
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_backup_options_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
download( data, 'generatepress-options-backup.json', 'application/json' );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
_this.next( 'input' ).show();
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function import_options( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.importing_options );
|
||||
siteBox.find( '.loading' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '1' );;
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '0' );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_import_options_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
if ( 'undefined' !== typeof data.success && ! data.success ) {
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.data ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
return;
|
||||
}
|
||||
|
||||
console.log( 'Options imported.' );
|
||||
|
||||
_this.hide();
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
$( 'body' ).addClass( 'site-import-data-exists' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.checking_demo_content );
|
||||
siteBox.find( '.loading' ).show();
|
||||
setup_demo_content( _this );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( '.site-box' ).on( 'click', '.skip-content-import a', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this ),
|
||||
siteBox = _this.closest( '.site-box' );
|
||||
|
||||
siteBox.find( '.skip-content-import' ).hide();
|
||||
siteBox.find( '.demo-content' ).css( 'opacity', '0.5' );
|
||||
siteBox.find( '.confirm-content-import-message' ).hide();
|
||||
siteBox.find( '.action-buttons input' ).hide();
|
||||
siteBox.find( '.action-buttons input.view-site' ).show();
|
||||
siteBox.find( '.import-complete .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Install and activate plugins.
|
||||
* Before content, as content may be depedent on plugins.
|
||||
*/
|
||||
$( '.site-box' ).on( 'click', '.import-content', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this )
|
||||
siteBox = _this.closest( '.site-box' ),
|
||||
plugins = _this.data( 'plugins' ),
|
||||
plugin_text = siteBox.find( '.automatic-plugins li' );
|
||||
|
||||
_this.hide();
|
||||
siteBox.find( '.skip-content-import' ).hide();
|
||||
siteBox.find( '.loading' ).show();
|
||||
siteBox.find( '.confirm-content-import-message' ).hide();
|
||||
siteBox.find( '.demo-content .big-loader' ).css( 'opacity', '1' );
|
||||
siteBox.find( '.demo-content .number' ).css( 'opacity', '0' );
|
||||
$( 'body' ).addClass( 'site-import-content-exists' );
|
||||
|
||||
siteBox.attr( 'data-plugins', JSON.stringify( plugins ) );
|
||||
|
||||
if ( ! $.isEmptyObject( plugins ) ) {
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.installing_plugins );
|
||||
|
||||
$.each( plugins, function( index, value ) {
|
||||
var plugin_slug = value.slug.split('/')[0];
|
||||
|
||||
var plugin_row = plugin_text.filter( function () {
|
||||
return $( this ).attr( 'data-slug' ) == plugin_slug;
|
||||
} );
|
||||
|
||||
if ( 'elementor' === plugin_slug ) {
|
||||
siteBox.find( '.replace-elementor-urls' ).show();
|
||||
}
|
||||
|
||||
if ( ! value.installed ) {
|
||||
plugin_row.find( '.loading' ).show();
|
||||
plugin_row.addClass( 'installing-plugins' );
|
||||
|
||||
// Install BB Lite if Pro doesn't exist.
|
||||
if ( 'bb-plugin' == plugin_slug ) {
|
||||
plugin_slug = 'beaver-builder-lite-version';
|
||||
}
|
||||
|
||||
wp.updates.installPlugin( {
|
||||
slug: plugin_slug,
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
plugin_row.removeClass( 'installing-plugins' ).addClass( 'plugin-installed' );
|
||||
plugin_row.removeClass( 'show-loading' ).next().addClass( 'show-loading' );
|
||||
|
||||
// Remove current plugin from queue
|
||||
delete plugins[index];
|
||||
|
||||
if ( $.isEmptyObject( plugins ) ) {
|
||||
// Onto the next step
|
||||
activate_plugins( _this );
|
||||
}
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log(data);
|
||||
|
||||
plugin_row.append( '<span class="plugin-error">' + data.errorMessage + '</span>' );
|
||||
plugin_row.removeClass( 'installing-plugins' ).addClass( 'plugin-install-failed' );
|
||||
plugin_row.removeClass( 'show-loading' ).next().addClass( 'show-loading' );
|
||||
|
||||
// Remove current plugin from queue
|
||||
delete plugins[index];
|
||||
|
||||
if ( $.isEmptyObject( plugins ) ) {
|
||||
// Onto the next step
|
||||
activate_plugins( _this );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
// Remove current plugin from queue
|
||||
delete plugins[index];
|
||||
|
||||
if ( $.isEmptyObject( plugins ) ) {
|
||||
// Onto the next step
|
||||
activate_plugins( _this );
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
} else {
|
||||
download_content( _this );
|
||||
}
|
||||
} );
|
||||
|
||||
function activate_plugins( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.activating_plugins );
|
||||
|
||||
setTimeout( function() {
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_activate_plugins_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
download_content( _this );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}, 250 );
|
||||
}
|
||||
|
||||
function download_content( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.downloading_content );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_download_content_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
import_content( _this );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function import_content( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.importing_content );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_import_content_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
import_site_options( _this );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Import site options.
|
||||
* Comes last, as options may be dependent on plugins.
|
||||
*/
|
||||
function import_site_options( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.importing_site_options );
|
||||
|
||||
setTimeout( function() {
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_import_site_options_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
if ( '1' == _this.data( 'widgets' ) ) {
|
||||
|
||||
import_widgets( _this );
|
||||
|
||||
} else {
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.site-message' ).hide();
|
||||
siteBox.find( '.demo-content .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.demo-content .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
_this.next( 'input' ).show();
|
||||
siteBox.find( '.import-complete .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
|
||||
}
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}, 250 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Import widgets.
|
||||
*/
|
||||
function import_widgets( _this ) {
|
||||
var siteBox = _this.closest( '.site-box' ),
|
||||
data = siteBox.data( 'site-data' );
|
||||
|
||||
siteBox.find( '.site-message' ).text( generate_sites_params.importing_widgets );
|
||||
|
||||
setTimeout( function() {
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_import_widgets_' + data.slug,
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.site-message' ).hide();
|
||||
siteBox.find( '.demo-content .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.demo-content .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
_this.next( 'input' ).show();
|
||||
siteBox.find( '.import-complete .number' ).css( 'opacity', '1' ).addClass( 'step-complete' );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
|
||||
siteBox.find( '.loading' ).hide();
|
||||
siteBox.find( '.error-message' ).html( data.status + ' ' + data.statusText + ' <a href="https://docs.generatepress.com/article/error-codes-importing/" target="_blank" rel="noopener">[?]</a>' ).show();
|
||||
siteBox.find( '.theme-options .big-loader' ).css( 'opacity', '0' );
|
||||
siteBox.find( '.theme-options .number' ).css( 'opacity', '1' );
|
||||
}
|
||||
} );
|
||||
}, 250 );
|
||||
}
|
||||
|
||||
/**
|
||||
* View our completed site.
|
||||
*/
|
||||
$( '.site-box .view-site, .remove-site .view-site' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
window.location.href = generate_sites_params.home_url;
|
||||
} );
|
||||
|
||||
function restoreThemeOptions() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.do-remove-site' ).hide()
|
||||
restoreBox.find( '.skip-remove-site' ).hide();
|
||||
restoreBox.find( '.loading' ).show();
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restoreThemeOptions );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_theme_options',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
if ( generate_sites_params.hasContentBackup || $( 'body' ).hasClass( 'site-import-content-exists' ) ) {
|
||||
restoreSiteOptions();
|
||||
} else {
|
||||
restoreCSS();
|
||||
}
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function restoreSiteOptions() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restoreSiteOptions );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_site_options',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
restoreContent();
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function restoreContent() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restoreContent );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_content',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
restorePlugins();
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function restorePlugins() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restorePlugins );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_plugins',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
restoreWidgets();
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function restoreWidgets() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restoreWidgets );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_widgets',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
restoreCSS();
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function restoreCSS() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.restoreCSS );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_css',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
cleanUp();
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
var restoreBox = $( '.remove-site' );
|
||||
|
||||
restoreBox.find( '.remove-site-message' ).text( generate_sites_params.cleanUp );
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: generate_sites_params.ajaxurl,
|
||||
data: {
|
||||
action: 'generate_restore_site_clean_up',
|
||||
nonce: generate_sites_params.nonce,
|
||||
},
|
||||
success: function( data ) {
|
||||
restoreBox.find( '.loading' ).hide();
|
||||
restoreBox.hide();
|
||||
|
||||
$( '.generatepress-sites' ).removeClass( 'remove-site-needed' );
|
||||
$( 'body' ).removeClass( 'site-import-content-exists' );
|
||||
$( 'body' ).removeClass( 'site-import-data-exists' );
|
||||
console.log( data );
|
||||
},
|
||||
error: function( data ) {
|
||||
console.log( data );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( '.do-remove-site' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( confirm( generate_sites_params.confirmRemoval ) ) {
|
||||
restoreThemeOptions();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.skip-remove-site' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.remove-site' ).hide();
|
||||
$( '.generatepress-sites' ).removeClass( 'remove-site-needed' );
|
||||
$( 'body' ).removeClass( 'site-import-content-exists' );
|
||||
$( 'body' ).removeClass( 'site-import-data-exists' );
|
||||
} );
|
||||
} );
|
6
wp-content/plugins/gp-premium/sites/assets/js/blazy.min.js
vendored
Normal file
6
wp-content/plugins/gp-premium/sites/assets/js/blazy.min.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
hey, [be]Lazy.js - v1.8.2 - 2016.10.25
|
||||
A fast, small and dependency free lazy load script (https://github.com/dinbror/blazy)
|
||||
(c) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy
|
||||
*/
|
||||
(function(q,m){"function"===typeof define&&define.amd?define(m):"object"===typeof exports?module.exports=m():q.Blazy=m()})(this,function(){function q(b){var c=b._util;c.elements=E(b.options);c.count=c.elements.length;c.destroyed&&(c.destroyed=!1,b.options.container&&l(b.options.container,function(a){n(a,"scroll",c.validateT)}),n(window,"resize",c.saveViewportOffsetT),n(window,"resize",c.validateT),n(window,"scroll",c.validateT));m(b)}function m(b){for(var c=b._util,a=0;a<c.count;a++){var d=c.elements[a],e;a:{var g=d;e=b.options;var p=g.getBoundingClientRect();if(e.container&&y&&(g=g.closest(e.containerClass))){g=g.getBoundingClientRect();e=r(g,f)?r(p,{top:g.top-e.offset,right:g.right+e.offset,bottom:g.bottom+e.offset,left:g.left-e.offset}):!1;break a}e=r(p,f)}if(e||t(d,b.options.successClass))b.load(d),c.elements.splice(a,1),c.count--,a--}0===c.count&&b.destroy()}function r(b,c){return b.right>=c.left&&b.bottom>=c.top&&b.left<=c.right&&b.top<=c.bottom}function z(b,c,a){if(!t(b,a.successClass)&&(c||a.loadInvisible||0<b.offsetWidth&&0<b.offsetHeight))if(c=b.getAttribute(u)||b.getAttribute(a.src)){c=c.split(a.separator);var d=c[A&&1<c.length?1:0],e=b.getAttribute(a.srcset),g="img"===b.nodeName.toLowerCase(),p=(c=b.parentNode)&&"picture"===c.nodeName.toLowerCase();if(g||void 0===b.src){var h=new Image,w=function(){a.error&&a.error(b,"invalid");v(b,a.errorClass);k(h,"error",w);k(h,"load",f)},f=function(){g?p||B(b,d,e):b.style.backgroundImage='url("'+d+'")';x(b,a);k(h,"load",f);k(h,"error",w)};p&&(h=b,l(c.getElementsByTagName("source"),function(b){var c=a.srcset,e=b.getAttribute(c);e&&(b.setAttribute("srcset",e),b.removeAttribute(c))}));n(h,"error",w);n(h,"load",f);B(h,d,e)}else b.src=d,x(b,a)}else"video"===b.nodeName.toLowerCase()?(l(b.getElementsByTagName("source"),function(b){var c=a.src,e=b.getAttribute(c);e&&(b.setAttribute("src",e),b.removeAttribute(c))}),b.load(),x(b,a)):(a.error&&a.error(b,"missing"),v(b,a.errorClass))}function x(b,c){v(b,c.successClass);c.success&&c.success(b);b.removeAttribute(c.src);b.removeAttribute(c.srcset);l(c.breakpoints,function(a){b.removeAttribute(a.src)})}function B(b,c,a){a&&b.setAttribute("srcset",a);b.src=c}function t(b,c){return-1!==(" "+b.className+" ").indexOf(" "+c+" ")}function v(b,c){t(b,c)||(b.className+=" "+c)}function E(b){var c=[];b=b.root.querySelectorAll(b.selector);for(var a=b.length;a--;c.unshift(b[a]));return c}function C(b){f.bottom=(window.innerHeight||document.documentElement.clientHeight)+b;f.right=(window.innerWidth||document.documentElement.clientWidth)+b}function n(b,c,a){b.attachEvent?b.attachEvent&&b.attachEvent("on"+c,a):b.addEventListener(c,a,{capture:!1,passive:!0})}function k(b,c,a){b.detachEvent?b.detachEvent&&b.detachEvent("on"+c,a):b.removeEventListener(c,a,{capture:!1,passive:!0})}function l(b,c){if(b&&c)for(var a=b.length,d=0;d<a&&!1!==c(b[d],d);d++);}function D(b,c,a){var d=0;return function(){var e=+new Date;e-d<c||(d=e,b.apply(a,arguments))}}var u,f,A,y;return function(b){if(!document.querySelectorAll){var c=document.createStyleSheet();document.querySelectorAll=function(a,b,d,h,f){f=document.all;b=[];a=a.replace(/\[for\b/gi,"[htmlFor").split(",");for(d=a.length;d--;){c.addRule(a[d],"k:v");for(h=f.length;h--;)f[h].currentStyle.k&&b.push(f[h]);c.removeRule(0)}return b}}var a=this,d=a._util={};d.elements=[];d.destroyed=!0;a.options=b||{};a.options.error=a.options.error||!1;a.options.offset=a.options.offset||100;a.options.root=a.options.root||document;a.options.success=a.options.success||!1;a.options.selector=a.options.selector||".b-lazy";a.options.separator=a.options.separator||"|";a.options.containerClass=a.options.container;a.options.container=a.options.containerClass?document.querySelectorAll(a.options.containerClass):!1;a.options.errorClass=a.options.errorClass||"b-error";a.options.breakpoints=a.options.breakpoints||!1;a.options.loadInvisible=a.options.loadInvisible||!1;a.options.successClass=a.options.successClass||"b-loaded";a.options.validateDelay=a.options.validateDelay||25;a.options.saveViewportOffsetDelay=a.options.saveViewportOffsetDelay||50;a.options.srcset=a.options.srcset||"data-srcset";a.options.src=u=a.options.src||"data-src";y=Element.prototype.closest;A=1<window.devicePixelRatio;f={};f.top=0-a.options.offset;f.left=0-a.options.offset;a.revalidate=function(){q(a)};a.load=function(a,b){var c=this.options;void 0===a.length?z(a,b,c):l(a,function(a){z(a,b,c)})};a.destroy=function(){var a=this._util;this.options.container&&l(this.options.container,function(b){k(b,"scroll",a.validateT)});k(window,"scroll",a.validateT);k(window,"resize",a.validateT);k(window,"resize",a.saveViewportOffsetT);a.count=0;a.elements.length=0;a.destroyed=!0};d.validateT=D(function(){m(a)},a.options.validateDelay,a);d.saveViewportOffsetT=D(function(){C(a.options.offset)},a.options.saveViewportOffsetDelay,a);C(a.options.offset);l(a.options.breakpoints,function(a){if(a.width>=window.screen.width)return u=a.src,!1});setTimeout(function(){q(a)})}});
|
167
wp-content/plugins/gp-premium/sites/assets/js/download.js
Normal file
167
wp-content/plugins/gp-premium/sites/assets/js/download.js
Normal file
@ -0,0 +1,167 @@
|
||||
//download.js v4.2, by dandavis; 2008-2016. [MIT] see http://danml.com/download.html for tests/usage
|
||||
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
|
||||
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
|
||||
// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
|
||||
// v4 adds AMD/UMD, commonJS, and plain browser support
|
||||
// v4.1 adds url download capability via solo URL argument (same domain/CORS only)
|
||||
// v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
|
||||
// https://github.com/rndme/download
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define([], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.download = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
|
||||
return function download(data, strFileName, strMimeType) {
|
||||
|
||||
var self = window, // this script is only for browsers anyway...
|
||||
defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
|
||||
mimeType = strMimeType || defaultMime,
|
||||
payload = data,
|
||||
url = !strFileName && !strMimeType && payload,
|
||||
anchor = document.createElement("a"),
|
||||
toString = function(a){return String(a);},
|
||||
myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
|
||||
fileName = strFileName || "download",
|
||||
blob,
|
||||
reader;
|
||||
myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
|
||||
|
||||
if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
|
||||
payload=[payload, mimeType];
|
||||
mimeType=payload[0];
|
||||
payload=payload[1];
|
||||
}
|
||||
|
||||
|
||||
if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
|
||||
fileName = url.split("/").pop().split("?")[0];
|
||||
anchor.href = url; // assign href prop to temp anchor
|
||||
if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
|
||||
var ajax=new XMLHttpRequest();
|
||||
ajax.open( "GET", url, true);
|
||||
ajax.responseType = 'blob';
|
||||
ajax.onload= function(e){
|
||||
download(e.target.response, fileName, defaultMime);
|
||||
};
|
||||
setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
|
||||
return ajax;
|
||||
} // end if valid url?
|
||||
} // end if url?
|
||||
|
||||
|
||||
//go ahead and download dataURLs right away
|
||||
if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){
|
||||
|
||||
if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
|
||||
payload=dataUrlToBlob(payload);
|
||||
mimeType=payload.type || defaultMime;
|
||||
}else{
|
||||
return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
|
||||
navigator.msSaveBlob(dataUrlToBlob(payload), fileName) :
|
||||
saver(payload) ; // everyone else can save dataURLs un-processed
|
||||
}
|
||||
|
||||
}else{//not data url, is it a string with special needs?
|
||||
if(/([\x80-\xff])/.test(payload)){
|
||||
var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length;
|
||||
for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i);
|
||||
payload=new myBlob([tempUiArr], {type: mimeType});
|
||||
}
|
||||
}
|
||||
blob = payload instanceof myBlob ?
|
||||
payload :
|
||||
new myBlob([payload], {type: mimeType}) ;
|
||||
|
||||
|
||||
function dataUrlToBlob(strUrl) {
|
||||
var parts= strUrl.split(/[:;,]/),
|
||||
type= parts[1],
|
||||
decoder= parts[2] == "base64" ? atob : decodeURIComponent,
|
||||
binData= decoder( parts.pop() ),
|
||||
mx= binData.length,
|
||||
i= 0,
|
||||
uiArr= new Uint8Array(mx);
|
||||
|
||||
for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);
|
||||
|
||||
return new myBlob([uiArr], {type: type});
|
||||
}
|
||||
|
||||
function saver(url, winMode){
|
||||
|
||||
if ('download' in anchor) { //html5 A[download]
|
||||
anchor.href = url;
|
||||
anchor.setAttribute("download", fileName);
|
||||
anchor.className = "download-js-link";
|
||||
anchor.innerHTML = "downloading...";
|
||||
anchor.style.display = "none";
|
||||
document.body.appendChild(anchor);
|
||||
setTimeout(function() {
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
|
||||
}, 66);
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle non-a[download] safari as best we can:
|
||||
if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
|
||||
if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
||||
if(!window.open(url)){ // popup blocked, offer direct download:
|
||||
if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//do iframe dataURL download (old ch+FF):
|
||||
var f = document.createElement("iframe");
|
||||
document.body.appendChild(f);
|
||||
|
||||
if(!winMode && /^data:/.test(url)){ // force a mime that will download:
|
||||
url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
||||
}
|
||||
f.src=url;
|
||||
setTimeout(function(){ document.body.removeChild(f); }, 333);
|
||||
|
||||
}//end saver
|
||||
|
||||
|
||||
|
||||
|
||||
if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
|
||||
return navigator.msSaveBlob(blob, fileName);
|
||||
}
|
||||
|
||||
if(self.URL){ // simple fast and modern way using Blob and URL:
|
||||
saver(self.URL.createObjectURL(blob), true);
|
||||
}else{
|
||||
// handle non-Blob()+non-URL browsers:
|
||||
if(typeof blob === "string" || blob.constructor===toString ){
|
||||
try{
|
||||
return saver( "data:" + mimeType + ";base64," + self.btoa(blob) );
|
||||
}catch(y){
|
||||
return saver( "data:" + mimeType + "," + encodeURIComponent(blob) );
|
||||
}
|
||||
}
|
||||
|
||||
// Blob but not URL support:
|
||||
reader=new FileReader();
|
||||
reader.onload=function(e){
|
||||
saver(this.result);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
return true;
|
||||
}; /* end download() */
|
||||
}));
|
Reference in New Issue
Block a user