-
Notifications
You must be signed in to change notification settings - Fork 13
/
header buttons add.html
156 lines (84 loc) · 4.06 KB
/
header buttons add.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<script>
$( ( ) => {
/*
begin header buttons add
License : < https://tinyurl.com/s872fb68 >
Version : 0.8.0
SS Version : 7.1
Fluid
Engine
Compatible : Not Applicable
Dependencies : jQuery
By : Thomas Creedon < http://www.tomsWeb.consulting/ >
*/
const buttonsAdd = [
/*
following is an example of a new button data structure. copy the
example new button data structure and paste after the example new
button data structure. remove the forward slash asterisk and asterisk
forward slash lines from before and after the copied example. repeat
for as many new buttons you want to create. this has been done once
initially
*/
/*
{
text : '[enter button text here between single quotes replacing square brackets]',
url : '[enter url here between single quotes replacing square brackets]',
// type is is optional. values are secondary, or tertiary
type : '[optional, enter type here between single quotes replacing square brackets]'
},
*/
{
text : '[enter button text here between single quotes replacing square brackets]',
url : '[enter url here between single quotes replacing square brackets]',
// type is is optional. values are secondary or tertiary
type : '[optional, enter type here between single quotes replacing square brackets]'
},
]
/*
targetAtttributeValue is an optional setting. enter _self, _blank,
_parent, _top, or framename see < https://mzl.la/2Q0JROF > between
single quotes
*/
const targetAtttributeValue = '';
/*
buttonOriginalTargetAttributeAdd is an optional setting. use false or
true. when true the target attribute will be added to SS's built-in cta
button
*/
const buttonOriginalTargetAttributeAdd = false;
// do not change anything below, there be the borg here
const codeName = 'Header Buttons Add';
const selector = '.header-actions-action--cta, .header-menu-cta';
const typeClassMap = {
secondary : 'sqs-button-element--secondary',
tertiary : 'sqs-button-element--tertiary'
};
const version = '0.8.0';
const s = `${ codeName } v${ version }, ` +
'License < https://tinyurl.com/s872fb68 >, ' +
'Tom\'s Web Consulting < http://www.tomsWeb.consulting >';
console.log ( s );
$( selector ).each ( function ( ) {
const $this = $( this );
const $buttonOriginal = $( '.btn:first', $this );
$.each ( buttonsAdd, function ( index, buttonAdd ) {
const $button = $buttonOriginal
.clone ( )
.attr ( 'href', buttonAdd.url )
.text ( buttonAdd.text )
.appendTo ( $this );
if ( targetAtttributeValue )
$button.attr ( 'target', targetAtttributeValue );
const clss = typeClassMap [ buttonAdd.type ];
if ( clss == undefined ) return true; // continue
$button
.removeClass ( 'sqs-button-element--primary' )
.addClass ( clss );
} );
if ( buttonOriginalTargetAttributeAdd && targetAtttributeValue )
$buttonOriginal.attr ( 'target', targetAtttributeValue );
} );
/* end header buttons add */
} );
</script>