Version Description
- fix for "code conflict with CoSchedule plugin"
Download this release
Release Info
Developer | krozero199 |
Plugin | WP Custom Widget area |
Version | 1.0.3 |
Comparing to | |
See all releases |
Version 1.0.3
- LICENSE.txt +339 -0
- README.txt +74 -0
- admin/class-wp-custom-widget-area-admin.php +263 -0
- admin/css/themes/tooltipster-light.css +12 -0
- admin/css/themes/tooltipster-noir.css +12 -0
- admin/css/themes/tooltipster-punk.css +12 -0
- admin/css/themes/tooltipster-shadow.css +12 -0
- admin/css/tooltipster.css +274 -0
- admin/css/wp-custom-widget-area-admin.css +119 -0
- admin/img/x.png +0 -0
- admin/index.php +1 -0
- admin/js/jquery.tooltipster.js +1327 -0
- admin/js/jquery.tooltipster.min.js +1 -0
- admin/js/wp-custom-widget-area-admin.js +155 -0
- admin/partials/cwa-admin-display.php +208 -0
- assets/screenshot-1.png +0 -0
- includes/class-custom-widget-area.php +211 -0
- includes/class-wp-custom-widget-area-activator.php +71 -0
- includes/class-wp-custom-widget-area-deactivator.php +36 -0
- includes/class-wp-custom-widget-area-i18n.php +63 -0
- includes/class-wp-custom-widget-area-loader.php +129 -0
- includes/config.php +6 -0
- includes/index.php +1 -0
- index.php +1 -0
- languages/plugin-name.pot +0 -0
- uninstall.php +31 -0
- wp-custom-widget-area.php +74 -0
LICENSE.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) <year> <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
README.txt
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: krozero
|
3 |
+
Donate link: http://kishorkhambu.com.np/donation
|
4 |
+
Tags: widget area, custom widget area, widget, simple widget area, custom sidebar, dynamic sidebar
|
5 |
+
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 1.0.3
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Create a Custom widget area or sidebar easily.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
A Wordpress Plugin to create a custom widget areas or sidebar easily. It allows user to create multiple widget areas from admin panel and allows to use it anywhere like in theme sidebar or in any page/post content.
|
16 |
+
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Upload `wp-custom-widget-area` to the `/wp-content/plugins/` directory
|
21 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
22 |
+
3. click on CWA settings menu at left menu bar
|
23 |
+
|
24 |
+
== Frequently Asked Questions ==
|
25 |
+
|
26 |
+
= How to use it? =
|
27 |
+
|
28 |
+
1. create a custom widget area.
|
29 |
+
2. copy the code form "get code" Link
|
30 |
+
3. paste into wordpress theme where you want to display it
|
31 |
+
|
32 |
+
= How to Use it in page or post content? =
|
33 |
+
1. Click on the "get shortcode" link form widget area table below.
|
34 |
+
2. Copy the shortcode and Paste it in a post or page editor in which you want it to display it.
|
35 |
+
|
36 |
+
= How to customize widget style? =
|
37 |
+
1. Click on the advance link while creating new widget area and add widget class.
|
38 |
+
2. Add custom css targeting your widget area class. i.e.
|
39 |
+
.mynewwidgetareaclass a{ color: red; }
|
40 |
+
at the bottom of your style.css where ".mynewwidgetareaclass" is your widget area class.
|
41 |
+
|
42 |
+
== Screenshots ==
|
43 |
+
|
44 |
+
1. /assets/screenshot-1.png
|
45 |
+
|
46 |
+
== Changelog ==
|
47 |
+
|
48 |
+
= 1.0.3 =
|
49 |
+
* fix for "code conflict with CoSchedule plugin"
|
50 |
+
|
51 |
+
= 1.0.2 =
|
52 |
+
* shortcode bug fix
|
53 |
+
* removed unused assets
|
54 |
+
|
55 |
+
= 1.0.1 =
|
56 |
+
* added widget area shortcode
|
57 |
+
* how to use update
|
58 |
+
|
59 |
+
= 1.0.0 =
|
60 |
+
* Launch version.
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
== Upgrade Notice ==
|
65 |
+
|
66 |
+
= 1.0.3 =
|
67 |
+
* code conflict fix
|
68 |
+
|
69 |
+
= 1.0.2 =
|
70 |
+
* shortcode bug fix for page and posts.
|
71 |
+
|
72 |
+
= 1.0.1 =
|
73 |
+
* added widget area shortcode
|
74 |
+
* how to use update
|
admin/class-wp-custom-widget-area-admin.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The dashboard-specific functionality of the plugin.
|
5 |
+
*
|
6 |
+
* @link http://example.com
|
7 |
+
* @since 1.0.3
|
8 |
+
*
|
9 |
+
* @package Custom_Widget_Area
|
10 |
+
* @subpackage Custom_Widget_Area/admin
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The dashboard-specific functionality of the plugin.
|
15 |
+
*
|
16 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
+
* enqueue the dashboard-specific stylesheet and JavaScript.
|
18 |
+
*
|
19 |
+
* @package Custom_Widget_Area
|
20 |
+
* @subpackage Custom_Widget_Area/admin
|
21 |
+
* @author Your Name <email@example.com>
|
22 |
+
*/
|
23 |
+
|
24 |
+
require_once('partials/cwa-admin-display.php');
|
25 |
+
class Custom_Widget_Area_Admin {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The ID of this plugin.
|
29 |
+
*
|
30 |
+
* @since 1.0.3
|
31 |
+
* @access private
|
32 |
+
* @var string $plugin_name The ID of this plugin.
|
33 |
+
*/
|
34 |
+
private $plugin_name;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* The version of this plugin.
|
38 |
+
*
|
39 |
+
* @since 1.0.3
|
40 |
+
* @access private
|
41 |
+
* @var string $version The current version of this plugin.
|
42 |
+
*/
|
43 |
+
private $version;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Initialize the class and set its properties.
|
47 |
+
*
|
48 |
+
* @since 1.0.3
|
49 |
+
* @var string $plugin_name The name of this plugin.
|
50 |
+
* @var string $version The version of this plugin.
|
51 |
+
*/
|
52 |
+
public function __construct( $plugin_name, $version ) {
|
53 |
+
global $table_name, $wpdb;
|
54 |
+
$this->view = new CWA_View();
|
55 |
+
$this->plugin_name = $plugin_name;
|
56 |
+
$this->version = $version;
|
57 |
+
$this->table_name = $table_name;
|
58 |
+
$this->setuo_ajax_request();
|
59 |
+
add_action( 'widgets_init', array($this, 'registerSidebar'));
|
60 |
+
}
|
61 |
+
public function menu_setup(){
|
62 |
+
|
63 |
+
add_menu_page('CWA Settings', 'CWA Settings', 'administrator', __FILE__, array($this->view, 'cwa_settings_page'),''/*plugins_url('/images/icon.png', __FILE__)*/);
|
64 |
+
self::setuo_ajax_request();
|
65 |
+
}
|
66 |
+
public function setuo_ajax_request(){
|
67 |
+
add_action( 'wp_ajax_add_cwa', array($this, 'add_cwa'));
|
68 |
+
|
69 |
+
add_action( 'wp_ajax_delete_cwa', array($this, 'delete_cwa'));
|
70 |
+
add_action( 'wp_ajax_check_cwa_id', array($this, 'check_cwa_id'));
|
71 |
+
//add_action( 'wp_ajax_get_cwa', array($this, 'get_cwa'));
|
72 |
+
add_action( 'wp_ajax_reloadTable', array($this->view , 'widgetTable'));
|
73 |
+
|
74 |
+
|
75 |
+
}
|
76 |
+
public function add_cwa(){
|
77 |
+
|
78 |
+
global $table_name, $wpdb;
|
79 |
+
$wpdb->show_errors();
|
80 |
+
//get parameter $x = $_POST['x'];
|
81 |
+
$data = $_POST['data'];
|
82 |
+
//echo "hello : your test is successfull!!!";
|
83 |
+
//var_dump($_POST);
|
84 |
+
//var_export($table_name);
|
85 |
+
if($data['cwa_name'] !== '' && $data['cwa_id'] !== '' ){
|
86 |
+
$new_data = $this->validatePost();
|
87 |
+
//echo "id: " .$this->check_cwa_id($new_data['cwa_id']);
|
88 |
+
if($this->check_cwa_id($new_data['cwa_id'])){
|
89 |
+
$new_data['last_updated'] = date('Y-m-d');
|
90 |
+
//var_dump($new_data);
|
91 |
+
$row = $wpdb->replace( $table_name, $new_data );
|
92 |
+
|
93 |
+
if($row){
|
94 |
+
wp_send_json(array('code'=>1, 'message' => $new_data['cwa_id'].' created successfully.'));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
else{
|
98 |
+
wp_send_json(array('code' => 0, 'message' => 'Widget id already registered'));
|
99 |
+
|
100 |
+
}
|
101 |
+
}
|
102 |
+
else{
|
103 |
+
wp_send_json(array('code' => 0, 'message' => 'Widget area name or id not defined'));
|
104 |
+
}
|
105 |
+
die(); // this is required to terminate immediately and return a proper response
|
106 |
+
}
|
107 |
+
|
108 |
+
public function delete_cwa(){
|
109 |
+
global $table_name, $wpdb;
|
110 |
+
$wpdb->show_errors();
|
111 |
+
$cwa_id = esc_html($_POST['data']['cwa_id']);
|
112 |
+
|
113 |
+
|
114 |
+
$row = $wpdb->delete( $table_name, array( 'cwa_id' => $cwa_id ), $where_format = null );
|
115 |
+
//wp_send_json_success(array('code' => 1, 'message' => $cwa_id.' deleted successfully.'));
|
116 |
+
|
117 |
+
if($row>0)
|
118 |
+
wp_send_json(array('code' => 1, 'message' => $cwa_id.' deleted successfully.'));
|
119 |
+
else
|
120 |
+
wp_send_json(array('code' => 0, 'message' => 'Error accured!.'));
|
121 |
+
|
122 |
+
die();
|
123 |
+
}
|
124 |
+
public function check_cwa_id($id=null){
|
125 |
+
global $wpdb;
|
126 |
+
|
127 |
+
if(empty($id))
|
128 |
+
$cwa_id = $_POST['data']['cwa_id'];
|
129 |
+
else
|
130 |
+
$cwa_id = $id;
|
131 |
+
|
132 |
+
$valid = self::checSpecialChar($cwa_id);
|
133 |
+
|
134 |
+
if($valid){
|
135 |
+
|
136 |
+
$sql = "SELECT * FROM $this->table_name WHERE cwa_id='$cwa_id'";
|
137 |
+
|
138 |
+
|
139 |
+
$row = $wpdb->get_row( $sql, 'OBJECT');
|
140 |
+
|
141 |
+
if(empty($id)){
|
142 |
+
if($row)
|
143 |
+
wp_send_json(array('code' => 0, 'message' => 'Widget id already registered'));
|
144 |
+
else
|
145 |
+
wp_send_json(array('code' => 1, 'message' => 'Widget id available'));
|
146 |
+
die();
|
147 |
+
}
|
148 |
+
else{
|
149 |
+
if($row)
|
150 |
+
return false;
|
151 |
+
else
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
else{
|
156 |
+
if(empty($id)){
|
157 |
+
wp_send_json(array('code' => 0, 'message' => 'Invalid id, use [a-z]-[0-9]'));
|
158 |
+
}
|
159 |
+
else{
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
public function get_cwa(){
|
165 |
+
global $wpdb;
|
166 |
+
$cwa_id = $_POST['data']['cwa_id'];
|
167 |
+
//var_dump($cwa_id);
|
168 |
+
$sql = "SELECT * FROM $this->table_name WHERE cwa_id='$cwa_id'";
|
169 |
+
$row = $wpdb->get_row( $sql, 'OBJECT');
|
170 |
+
wp_send_json($row);
|
171 |
+
}
|
172 |
+
public function getall_cwa(){
|
173 |
+
global $wpdb;
|
174 |
+
$sql = "SELECT * FROM $this->table_name";
|
175 |
+
$row = $wpdb->get_results( $sql, 'OBJECT');
|
176 |
+
return $row;
|
177 |
+
}
|
178 |
+
public function registerSidebar(){
|
179 |
+
$data = $this->getall_cwa();
|
180 |
+
//var_dump($data);
|
181 |
+
foreach ($data as $row) {
|
182 |
+
# code...
|
183 |
+
$this->createSidebar($row);
|
184 |
+
}
|
185 |
+
|
186 |
+
}
|
187 |
+
public function createSidebar($row){
|
188 |
+
//register_widget( 'wp_custom_widget_area' );
|
189 |
+
register_sidebar( array(
|
190 |
+
'name' => __($row->cwa_name, 'wp_custom_widget_area' ),
|
191 |
+
'id' => $row->cwa_id,
|
192 |
+
'description' => __( $row->cwa_description, 'wp_custom_widget_area' ),
|
193 |
+
'before_widget' => '<'.$row->cwa_widget_wrapper.' id="%1$s" class="widget %2$s '.$row->cwa_widget_class.'">',
|
194 |
+
'after_widget' => '</'.$row->cwa_widget_wrapper.'>',
|
195 |
+
'before_title' => '<'.$row->cwa_widget_header_wrapper.' class="widgettitle '.$row->cwa_widget_header_class.'">',
|
196 |
+
'after_title' => '</'.$row->cwa_widget_header_wrapper.'>',
|
197 |
+
) );
|
198 |
+
}
|
199 |
+
public function validatePost(){
|
200 |
+
$data =$_POST['data'];
|
201 |
+
$new_data = array();
|
202 |
+
foreach ($data as $key => $value) {
|
203 |
+
# code...
|
204 |
+
$new_data[$key] = esc_html($value);
|
205 |
+
}
|
206 |
+
return $new_data;
|
207 |
+
}
|
208 |
+
public function checSpecialChar($string){
|
209 |
+
if(!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬]/', $string)){
|
210 |
+
return true;
|
211 |
+
}
|
212 |
+
else{
|
213 |
+
return false;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
/**
|
217 |
+
* Register the stylesheets for the Dashboard.
|
218 |
+
*
|
219 |
+
* @since 1.0.3
|
220 |
+
*/
|
221 |
+
public function enqueue_styles() {
|
222 |
+
|
223 |
+
/**
|
224 |
+
* This function is provided for demonstration purposes only.
|
225 |
+
*
|
226 |
+
* An instance of this class should be passed to the run() function
|
227 |
+
* defined in Custom_Widget_Area_Admin_Loader as all of the hooks are defined
|
228 |
+
* in that particular class.
|
229 |
+
*
|
230 |
+
* The Custom_Widget_Area_Admin_Loader will then create the relationship
|
231 |
+
* between the defined hooks and the functions defined in this
|
232 |
+
* class.
|
233 |
+
*/
|
234 |
+
|
235 |
+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-custom-widget-area-admin.css', array(), $this->version, 'all' );
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Register the JavaScript for the dashboard.
|
241 |
+
*
|
242 |
+
* @since 1.0.3
|
243 |
+
*/
|
244 |
+
public function enqueue_scripts() {
|
245 |
+
|
246 |
+
/**
|
247 |
+
* This function is provided for demonstration purposes only.
|
248 |
+
*
|
249 |
+
* An instance of this class should be passed to the run() function
|
250 |
+
* defined in Custom_Widget_Area_Admin_Loader as all of the hooks are defined
|
251 |
+
* in that particular class.
|
252 |
+
*
|
253 |
+
* The Custom_Widget_Area_Admin_Loader will then create the relationship
|
254 |
+
* between the defined hooks and the functions defined in this
|
255 |
+
* class.
|
256 |
+
*/
|
257 |
+
wp_enqueue_script( 'tooltip', plugin_dir_url( __FILE__ ) . 'js/jquery.tooltipster.min.js', array( ), $this->version, false );
|
258 |
+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-custom-widget-area-admin.js', array( 'jquery', 'tooltip'), $this->version, false );
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
}
|
admin/css/themes/tooltipster-light.css
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tooltipster-light {
|
2 |
+
border-radius: 5px;
|
3 |
+
border: 1px solid #cccccc;
|
4 |
+
background: #ededed;
|
5 |
+
color: #666666;
|
6 |
+
}
|
7 |
+
.tooltipster-light .tooltipster-content {
|
8 |
+
font-family: Arial, sans-serif;
|
9 |
+
font-size: 14px;
|
10 |
+
line-height: 16px;
|
11 |
+
padding: 8px 10px;
|
12 |
+
}
|
admin/css/themes/tooltipster-noir.css
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tooltipster-noir {
|
2 |
+
border-radius: 0px;
|
3 |
+
border: 3px solid #2c2c2c;
|
4 |
+
background: #fff;
|
5 |
+
color: #2c2c2c;
|
6 |
+
}
|
7 |
+
.tooltipster-noir .tooltipster-content {
|
8 |
+
font-family: 'Georgia', serif;
|
9 |
+
font-size: 14px;
|
10 |
+
line-height: 16px;
|
11 |
+
padding: 8px 10px;
|
12 |
+
}
|
admin/css/themes/tooltipster-punk.css
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tooltipster-punk {
|
2 |
+
border-radius: 5px;
|
3 |
+
border-bottom: 3px solid #f71169;
|
4 |
+
background: #2a2a2a;
|
5 |
+
color: #fff;
|
6 |
+
}
|
7 |
+
.tooltipster-punk .tooltipster-content {
|
8 |
+
font-family: 'Courier', monospace;
|
9 |
+
font-size: 14px;
|
10 |
+
line-height: 16px;
|
11 |
+
padding: 8px 10px;
|
12 |
+
}
|
admin/css/themes/tooltipster-shadow.css
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tooltipster-shadow {
|
2 |
+
border-radius: 5px;
|
3 |
+
background: #fff;
|
4 |
+
box-shadow: 0px 0px 14px rgba(0,0,0,0.3);
|
5 |
+
color: #2c2c2c;
|
6 |
+
}
|
7 |
+
.tooltipster-shadow .tooltipster-content {
|
8 |
+
font-family: 'Arial', sans-serif;
|
9 |
+
font-size: 14px;
|
10 |
+
line-height: 16px;
|
11 |
+
padding: 8px 10px;
|
12 |
+
}
|
admin/css/tooltipster.css
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* This is the default Tooltipster theme (feel free to modify or duplicate and create multiple themes!): */
|
2 |
+
.tooltipster-default {
|
3 |
+
border-radius: 5px;
|
4 |
+
border: 2px solid #000;
|
5 |
+
background: #4c4c4c;
|
6 |
+
color: #fff;
|
7 |
+
}
|
8 |
+
|
9 |
+
/* Use this next selector to style things like font-size and line-height: */
|
10 |
+
.tooltipster-default .tooltipster-content {
|
11 |
+
font-family: Arial, sans-serif;
|
12 |
+
font-size: 14px;
|
13 |
+
line-height: 16px;
|
14 |
+
padding: 8px 10px;
|
15 |
+
overflow: hidden;
|
16 |
+
}
|
17 |
+
|
18 |
+
/* This next selector defines the color of the border on the outside of the arrow. This will automatically match the color and size of the border set on the main tooltip styles. Set display: none; if you would like a border around the tooltip but no border around the arrow */
|
19 |
+
.tooltipster-default .tooltipster-arrow .tooltipster-arrow-border {
|
20 |
+
/* border-color: ... !important; */
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
/* If you're using the icon option, use this next selector to style them */
|
25 |
+
.tooltipster-icon {
|
26 |
+
cursor: help;
|
27 |
+
margin-left: 4px;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
/* This is the base styling required to make all Tooltipsters work */
|
38 |
+
.tooltipster-base {
|
39 |
+
padding: 0;
|
40 |
+
font-size: 0;
|
41 |
+
line-height: 0;
|
42 |
+
position: absolute;
|
43 |
+
left: 0;
|
44 |
+
top: 0;
|
45 |
+
z-index: 9999999;
|
46 |
+
pointer-events: none;
|
47 |
+
width: auto;
|
48 |
+
overflow: visible;
|
49 |
+
}
|
50 |
+
.tooltipster-base .tooltipster-content {
|
51 |
+
overflow: hidden;
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/* These next classes handle the styles for the little arrow attached to the tooltip. By default, the arrow will inherit the same colors and border as what is set on the main tooltip itself. */
|
56 |
+
.tooltipster-arrow {
|
57 |
+
display: block;
|
58 |
+
text-align: center;
|
59 |
+
width: 100%;
|
60 |
+
height: 100%;
|
61 |
+
position: absolute;
|
62 |
+
top: 0;
|
63 |
+
left: 0;
|
64 |
+
z-index: -1;
|
65 |
+
}
|
66 |
+
.tooltipster-arrow span, .tooltipster-arrow-border {
|
67 |
+
display: block;
|
68 |
+
width: 0;
|
69 |
+
height: 0;
|
70 |
+
position: absolute;
|
71 |
+
}
|
72 |
+
.tooltipster-arrow-top span, .tooltipster-arrow-top-right span, .tooltipster-arrow-top-left span {
|
73 |
+
border-left: 8px solid transparent !important;
|
74 |
+
border-right: 8px solid transparent !important;
|
75 |
+
border-top: 8px solid;
|
76 |
+
bottom: -7px;
|
77 |
+
}
|
78 |
+
.tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-top-left .tooltipster-arrow-border {
|
79 |
+
border-left: 9px solid transparent !important;
|
80 |
+
border-right: 9px solid transparent !important;
|
81 |
+
border-top: 9px solid;
|
82 |
+
bottom: -7px;
|
83 |
+
}
|
84 |
+
|
85 |
+
.tooltipster-arrow-bottom span, .tooltipster-arrow-bottom-right span, .tooltipster-arrow-bottom-left span {
|
86 |
+
border-left: 8px solid transparent !important;
|
87 |
+
border-right: 8px solid transparent !important;
|
88 |
+
border-bottom: 8px solid;
|
89 |
+
top: -7px;
|
90 |
+
}
|
91 |
+
.tooltipster-arrow-bottom .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
|
92 |
+
border-left: 9px solid transparent !important;
|
93 |
+
border-right: 9px solid transparent !important;
|
94 |
+
border-bottom: 9px solid;
|
95 |
+
top: -7px;
|
96 |
+
}
|
97 |
+
.tooltipster-arrow-top span, .tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-bottom span, .tooltipster-arrow-bottom .tooltipster-arrow-border {
|
98 |
+
left: 0;
|
99 |
+
right: 0;
|
100 |
+
margin: 0 auto;
|
101 |
+
}
|
102 |
+
.tooltipster-arrow-top-left span, .tooltipster-arrow-bottom-left span {
|
103 |
+
left: 6px;
|
104 |
+
}
|
105 |
+
.tooltipster-arrow-top-left .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
|
106 |
+
left: 5px;
|
107 |
+
}
|
108 |
+
.tooltipster-arrow-top-right span, .tooltipster-arrow-bottom-right span {
|
109 |
+
right: 6px;
|
110 |
+
}
|
111 |
+
.tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border {
|
112 |
+
right: 5px;
|
113 |
+
}
|
114 |
+
.tooltipster-arrow-left span, .tooltipster-arrow-left .tooltipster-arrow-border {
|
115 |
+
border-top: 8px solid transparent !important;
|
116 |
+
border-bottom: 8px solid transparent !important;
|
117 |
+
border-left: 8px solid;
|
118 |
+
top: 50%;
|
119 |
+
margin-top: -7px;
|
120 |
+
right: -7px;
|
121 |
+
}
|
122 |
+
.tooltipster-arrow-left .tooltipster-arrow-border {
|
123 |
+
border-top: 9px solid transparent !important;
|
124 |
+
border-bottom: 9px solid transparent !important;
|
125 |
+
border-left: 9px solid;
|
126 |
+
margin-top: -8px;
|
127 |
+
}
|
128 |
+
.tooltipster-arrow-right span, .tooltipster-arrow-right .tooltipster-arrow-border {
|
129 |
+
border-top: 8px solid transparent !important;
|
130 |
+
border-bottom: 8px solid transparent !important;
|
131 |
+
border-right: 8px solid;
|
132 |
+
top: 50%;
|
133 |
+
margin-top: -7px;
|
134 |
+
left: -7px;
|
135 |
+
}
|
136 |
+
.tooltipster-arrow-right .tooltipster-arrow-border {
|
137 |
+
border-top: 9px solid transparent !important;
|
138 |
+
border-bottom: 9px solid transparent !important;
|
139 |
+
border-right: 9px solid;
|
140 |
+
margin-top: -8px;
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
/* Some CSS magic for the awesome animations - feel free to make your own custom animations and reference it in your Tooltipster settings! */
|
145 |
+
|
146 |
+
.tooltipster-fade {
|
147 |
+
opacity: 0;
|
148 |
+
-webkit-transition-property: opacity;
|
149 |
+
-moz-transition-property: opacity;
|
150 |
+
-o-transition-property: opacity;
|
151 |
+
-ms-transition-property: opacity;
|
152 |
+
transition-property: opacity;
|
153 |
+
}
|
154 |
+
.tooltipster-fade-show {
|
155 |
+
opacity: 1;
|
156 |
+
}
|
157 |
+
|
158 |
+
.tooltipster-grow {
|
159 |
+
-webkit-transform: scale(0,0);
|
160 |
+
-moz-transform: scale(0,0);
|
161 |
+
-o-transform: scale(0,0);
|
162 |
+
-ms-transform: scale(0,0);
|
163 |
+
transform: scale(0,0);
|
164 |
+
-webkit-transition-property: -webkit-transform;
|
165 |
+
-moz-transition-property: -moz-transform;
|
166 |
+
-o-transition-property: -o-transform;
|
167 |
+
-ms-transition-property: -ms-transform;
|
168 |
+
transition-property: transform;
|
169 |
+
-webkit-backface-visibility: hidden;
|
170 |
+
}
|
171 |
+
.tooltipster-grow-show {
|
172 |
+
-webkit-transform: scale(1,1);
|
173 |
+
-moz-transform: scale(1,1);
|
174 |
+
-o-transform: scale(1,1);
|
175 |
+
-ms-transform: scale(1,1);
|
176 |
+
transform: scale(1,1);
|
177 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
|
178 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
179 |
+
-moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
180 |
+
-ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
181 |
+
-o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
182 |
+
transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
183 |
+
}
|
184 |
+
|
185 |
+
.tooltipster-swing {
|
186 |
+
opacity: 0;
|
187 |
+
-webkit-transform: rotateZ(4deg);
|
188 |
+
-moz-transform: rotateZ(4deg);
|
189 |
+
-o-transform: rotateZ(4deg);
|
190 |
+
-ms-transform: rotateZ(4deg);
|
191 |
+
transform: rotateZ(4deg);
|
192 |
+
-webkit-transition-property: -webkit-transform, opacity;
|
193 |
+
-moz-transition-property: -moz-transform;
|
194 |
+
-o-transition-property: -o-transform;
|
195 |
+
-ms-transition-property: -ms-transform;
|
196 |
+
transition-property: transform;
|
197 |
+
}
|
198 |
+
.tooltipster-swing-show {
|
199 |
+
opacity: 1;
|
200 |
+
-webkit-transform: rotateZ(0deg);
|
201 |
+
-moz-transform: rotateZ(0deg);
|
202 |
+
-o-transform: rotateZ(0deg);
|
203 |
+
-ms-transform: rotateZ(0deg);
|
204 |
+
transform: rotateZ(0deg);
|
205 |
+
-webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 1);
|
206 |
+
-webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
|
207 |
+
-moz-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
|
208 |
+
-ms-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
|
209 |
+
-o-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
|
210 |
+
transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
|
211 |
+
}
|
212 |
+
|
213 |
+
.tooltipster-fall {
|
214 |
+
top: 0;
|
215 |
+
-webkit-transition-property: top;
|
216 |
+
-moz-transition-property: top;
|
217 |
+
-o-transition-property: top;
|
218 |
+
-ms-transition-property: top;
|
219 |
+
transition-property: top;
|
220 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
|
221 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
222 |
+
-moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
223 |
+
-ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
224 |
+
-o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
225 |
+
transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
226 |
+
}
|
227 |
+
.tooltipster-fall-show {
|
228 |
+
}
|
229 |
+
.tooltipster-fall.tooltipster-dying {
|
230 |
+
-webkit-transition-property: all;
|
231 |
+
-moz-transition-property: all;
|
232 |
+
-o-transition-property: all;
|
233 |
+
-ms-transition-property: all;
|
234 |
+
transition-property: all;
|
235 |
+
top: 0px !important;
|
236 |
+
opacity: 0;
|
237 |
+
}
|
238 |
+
|
239 |
+
.tooltipster-slide {
|
240 |
+
left: -40px;
|
241 |
+
-webkit-transition-property: left;
|
242 |
+
-moz-transition-property: left;
|
243 |
+
-o-transition-property: left;
|
244 |
+
-ms-transition-property: left;
|
245 |
+
transition-property: left;
|
246 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
|
247 |
+
-webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
248 |
+
-moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
249 |
+
-ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
250 |
+
-o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
251 |
+
transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
|
252 |
+
}
|
253 |
+
.tooltipster-slide.tooltipster-slide-show {
|
254 |
+
}
|
255 |
+
.tooltipster-slide.tooltipster-dying {
|
256 |
+
-webkit-transition-property: all;
|
257 |
+
-moz-transition-property: all;
|
258 |
+
-o-transition-property: all;
|
259 |
+
-ms-transition-property: all;
|
260 |
+
transition-property: all;
|
261 |
+
left: 0px !important;
|
262 |
+
opacity: 0;
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
/* CSS transition for when contenting is changing in a tooltip that is still open. The only properties that will NOT transition are: width, height, top, and left */
|
267 |
+
.tooltipster-content-changing {
|
268 |
+
opacity: 0.5;
|
269 |
+
-webkit-transform: scale(1.1, 1.1);
|
270 |
+
-moz-transform: scale(1.1, 1.1);
|
271 |
+
-o-transform: scale(1.1, 1.1);
|
272 |
+
-ms-transform: scale(1.1, 1.1);
|
273 |
+
transform: scale(1.1, 1.1);
|
274 |
+
}
|
admin/css/wp-custom-widget-area-admin.css
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your dashboard-specific functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
5 |
+
@import url('tooltipster.css');
|
6 |
+
.hide{
|
7 |
+
display: none;
|
8 |
+
}
|
9 |
+
.cwa-warning{
|
10 |
+
color: red;
|
11 |
+
}
|
12 |
+
.cwa-success{
|
13 |
+
color: green;
|
14 |
+
}
|
15 |
+
.cwa-error{
|
16 |
+
border: 1px solid transparent;
|
17 |
+
padding: 10px;
|
18 |
+
margin-bottom: 10px;
|
19 |
+
width: 96%;
|
20 |
+
font-size: 14px;
|
21 |
+
border-radius: 5px;
|
22 |
+
background: rgba(255,255,255,0.8);
|
23 |
+
}
|
24 |
+
.cwa-error.cwa-success{
|
25 |
+
border-color: green;
|
26 |
+
}
|
27 |
+
|
28 |
+
.cwa-error.cwa-warning{
|
29 |
+
border-color: red;
|
30 |
+
}
|
31 |
+
.col{
|
32 |
+
float: left;
|
33 |
+
}
|
34 |
+
.col-8{
|
35 |
+
min-width: 400px;
|
36 |
+
width: 60%;
|
37 |
+
}
|
38 |
+
.col-4{
|
39 |
+
min-width: 300px;
|
40 |
+
width: 40%;
|
41 |
+
}
|
42 |
+
.cwa-form{
|
43 |
+
margin-right: 20px;
|
44 |
+
border: 1px solid #ddd;
|
45 |
+
/* margin-top: 10px; */
|
46 |
+
padding: 10px;
|
47 |
+
border-radius: 5px;
|
48 |
+
}
|
49 |
+
.cwa-form-label{
|
50 |
+
min-width: 200px;
|
51 |
+
display: inline-block;
|
52 |
+
font-size: 14px;
|
53 |
+
vertical-align: top;
|
54 |
+
line-height: 30px;
|
55 |
+
}
|
56 |
+
.cwa-form-row{
|
57 |
+
margin-bottom: 5px;
|
58 |
+
padding: 5px;
|
59 |
+
}
|
60 |
+
.cwa-form input[type=text], .cwa-form input[type=password], .cwa-form input[type=email], .cwa-form select, .cwa-form textarea{
|
61 |
+
padding: 5px 10px;
|
62 |
+
border-radius: 5px;
|
63 |
+
min-width: 40%;
|
64 |
+
line-height: 25px;
|
65 |
+
}
|
66 |
+
.custom-wp{
|
67 |
+
padding: 20px 10px;
|
68 |
+
}
|
69 |
+
|
70 |
+
.cwa-table{
|
71 |
+
width: 98%;
|
72 |
+
background: #fff;
|
73 |
+
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
74 |
+
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
75 |
+
line-height: 30px;
|
76 |
+
border-collapse:collapse;
|
77 |
+
}
|
78 |
+
.cwa-table>thead{
|
79 |
+
text-align: left;
|
80 |
+
}
|
81 |
+
.cwa-table>thead tr{
|
82 |
+
background-color: #999;
|
83 |
+
color: #fff;
|
84 |
+
}
|
85 |
+
.cwa-table th:first-child, .cwa-table td:first-child{
|
86 |
+
padding-left: 15px;
|
87 |
+
}
|
88 |
+
.cwa-table th:last-child, .cwa-table td:last-child{
|
89 |
+
padding-right: 15px;
|
90 |
+
}
|
91 |
+
.cwa-table>tbody tr:nth-child(even){
|
92 |
+
background-color: rgba(0, 0, 0, 0.1);
|
93 |
+
}
|
94 |
+
|
95 |
+
.cwa-btn{
|
96 |
+
border-radius: 5px;
|
97 |
+
border: 1px solid transparent;
|
98 |
+
padding: 8px 15px !important;
|
99 |
+
min-width: 120px !important;
|
100 |
+
font-weight: bold;
|
101 |
+
}
|
102 |
+
.cwa-btn.cwa-btn-primary{
|
103 |
+
background-color: #0074a2;
|
104 |
+
color: #fff;
|
105 |
+
}
|
106 |
+
.cwa-btn.cwa-btn-danger{
|
107 |
+
background-color: #B40404 !important;
|
108 |
+
color: #fff !important;
|
109 |
+
}
|
110 |
+
input[type=submit], input[type=reset], button{
|
111 |
+
cursor: pointer;
|
112 |
+
}
|
113 |
+
.how-to{
|
114 |
+
padding: 10px;
|
115 |
+
background: #ddd;
|
116 |
+
border-radius: 5px;
|
117 |
+
color: #333;
|
118 |
+
|
119 |
+
}
|
admin/img/x.png
ADDED
Binary file
|
admin/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
admin/js/jquery.tooltipster.js
ADDED
@@ -0,0 +1,1327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
|
3 |
+
Tooltipster 3.3.0 | 2014-11-08
|
4 |
+
A rockin' custom tooltip jQuery plugin
|
5 |
+
|
6 |
+
Developed by Caleb Jacob under the MIT license http://opensource.org/licenses/MIT
|
7 |
+
|
8 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9 |
+
|
10 |
+
*/
|
11 |
+
|
12 |
+
;(function ($, window, document) {
|
13 |
+
|
14 |
+
var pluginName = "tooltipster",
|
15 |
+
defaults = {
|
16 |
+
animation: 'fade',
|
17 |
+
arrow: true,
|
18 |
+
arrowColor: '',
|
19 |
+
autoClose: true,
|
20 |
+
content: null,
|
21 |
+
contentAsHTML: false,
|
22 |
+
contentCloning: true,
|
23 |
+
debug: true,
|
24 |
+
delay: 200,
|
25 |
+
minWidth: 0,
|
26 |
+
maxWidth: null,
|
27 |
+
functionInit: function(origin, content) {},
|
28 |
+
functionBefore: function(origin, continueTooltip) {
|
29 |
+
continueTooltip();
|
30 |
+
},
|
31 |
+
functionReady: function(origin, tooltip) {},
|
32 |
+
functionAfter: function(origin) {},
|
33 |
+
hideOnClick: false,
|
34 |
+
icon: '(?)',
|
35 |
+
iconCloning: true,
|
36 |
+
iconDesktop: false,
|
37 |
+
iconTouch: false,
|
38 |
+
iconTheme: 'tooltipster-icon',
|
39 |
+
interactive: false,
|
40 |
+
interactiveTolerance: 350,
|
41 |
+
multiple: false,
|
42 |
+
offsetX: 0,
|
43 |
+
offsetY: 0,
|
44 |
+
onlyOne: false,
|
45 |
+
position: 'top',
|
46 |
+
positionTracker: false,
|
47 |
+
positionTrackerCallback: function(origin){
|
48 |
+
// the default tracker callback will close the tooltip when the trigger is
|
49 |
+
// 'hover' (see https://github.com/iamceege/tooltipster/pull/253)
|
50 |
+
if(this.option('trigger') == 'hover' && this.option('autoClose')) {
|
51 |
+
this.hide();
|
52 |
+
}
|
53 |
+
},
|
54 |
+
restoration: 'current',
|
55 |
+
speed: 350,
|
56 |
+
timer: 0,
|
57 |
+
theme: 'tooltipster-default',
|
58 |
+
touchDevices: true,
|
59 |
+
trigger: 'hover',
|
60 |
+
updateAnimation: true
|
61 |
+
};
|
62 |
+
|
63 |
+
function Plugin(element, options) {
|
64 |
+
|
65 |
+
// list of instance variables
|
66 |
+
|
67 |
+
this.bodyOverflowX;
|
68 |
+
// stack of custom callbacks provided as parameters to API methods
|
69 |
+
this.callbacks = {
|
70 |
+
hide: [],
|
71 |
+
show: []
|
72 |
+
};
|
73 |
+
this.checkInterval = null;
|
74 |
+
// this will be the user content shown in the tooltip. A capital "C" is used because there is also a method called content()
|
75 |
+
this.Content;
|
76 |
+
// this is the original element which is being applied the tooltipster plugin
|
77 |
+
this.$el = $(element);
|
78 |
+
// this will be the element which triggers the appearance of the tooltip on hover/click/custom events.
|
79 |
+
// it will be the same as this.$el if icons are not used (see in the options), otherwise it will correspond to the created icon
|
80 |
+
this.$elProxy;
|
81 |
+
this.elProxyPosition;
|
82 |
+
this.enabled = true;
|
83 |
+
this.options = $.extend({}, defaults, options);
|
84 |
+
this.mouseIsOverProxy = false;
|
85 |
+
// a unique namespace per instance, for easy selective unbinding
|
86 |
+
this.namespace = 'tooltipster-'+ Math.round(Math.random()*100000);
|
87 |
+
// Status (capital S) can be either : appearing, shown, disappearing, hidden
|
88 |
+
this.Status = 'hidden';
|
89 |
+
this.timerHide = null;
|
90 |
+
this.timerShow = null;
|
91 |
+
// this will be the tooltip element (jQuery wrapped HTML element)
|
92 |
+
this.$tooltip;
|
93 |
+
|
94 |
+
// for backward compatibility
|
95 |
+
this.options.iconTheme = this.options.iconTheme.replace('.', '');
|
96 |
+
this.options.theme = this.options.theme.replace('.', '');
|
97 |
+
|
98 |
+
// launch
|
99 |
+
|
100 |
+
this._init();
|
101 |
+
}
|
102 |
+
|
103 |
+
Plugin.prototype = {
|
104 |
+
|
105 |
+
_init: function() {
|
106 |
+
|
107 |
+
var self = this;
|
108 |
+
|
109 |
+
// disable the plugin on old browsers (including IE7 and lower)
|
110 |
+
if (document.querySelector) {
|
111 |
+
|
112 |
+
// note : the content is null (empty) by default and can stay that way if the plugin remains initialized but not fed any content. The tooltip will just not appear.
|
113 |
+
|
114 |
+
// let's save the initial value of the title attribute for later restoration if need be.
|
115 |
+
var initialTitle = null;
|
116 |
+
// it will already have been saved in case of multiple tooltips
|
117 |
+
if (self.$el.data('tooltipster-initialTitle') === undefined) {
|
118 |
+
|
119 |
+
initialTitle = self.$el.attr('title');
|
120 |
+
|
121 |
+
// we do not want initialTitle to have the value "undefined" because of how jQuery's .data() method works
|
122 |
+
if (initialTitle === undefined) initialTitle = null;
|
123 |
+
|
124 |
+
self.$el.data('tooltipster-initialTitle', initialTitle);
|
125 |
+
}
|
126 |
+
|
127 |
+
// if content is provided in the options, its has precedence over the title attribute.
|
128 |
+
// Note : an empty string is considered content, only 'null' represents the absence of content.
|
129 |
+
// Also, an existing title="" attribute will result in an empty string content
|
130 |
+
if (self.options.content !== null){
|
131 |
+
self._content_set(self.options.content);
|
132 |
+
}
|
133 |
+
else {
|
134 |
+
self._content_set(initialTitle);
|
135 |
+
}
|
136 |
+
|
137 |
+
var c = self.options.functionInit.call(self.$el, self.$el, self.Content);
|
138 |
+
if(typeof c !== 'undefined') self._content_set(c);
|
139 |
+
|
140 |
+
self.$el
|
141 |
+
// strip the title off of the element to prevent the default tooltips from popping up
|
142 |
+
.removeAttr('title')
|
143 |
+
// to be able to find all instances on the page later (upon window events in particular)
|
144 |
+
.addClass('tooltipstered');
|
145 |
+
|
146 |
+
// detect if we're changing the tooltip origin to an icon
|
147 |
+
// note about this condition : if the device has touch capability and self.options.iconTouch is false, you'll have no icons event though you may consider your device as a desktop if it also has a mouse. Not sure why someone would have this use case though.
|
148 |
+
if ((!deviceHasTouchCapability && self.options.iconDesktop) || (deviceHasTouchCapability && self.options.iconTouch)) {
|
149 |
+
|
150 |
+
// TODO : the tooltip should be automatically be given an absolute position to be near the origin. Otherwise, when the origin is floating or what, it's going to be nowhere near it and disturb the position flow of the page elements. It will imply that the icon also detects when its origin moves, to follow it : not trivial.
|
151 |
+
// Until it's done, the icon feature does not really make sense since the user still has most of the work to do by himself
|
152 |
+
|
153 |
+
// if the icon provided is in the form of a string
|
154 |
+
if(typeof self.options.icon === 'string'){
|
155 |
+
// wrap it in a span with the icon class
|
156 |
+
self.$elProxy = $('<span class="'+ self.options.iconTheme +'"></span>');
|
157 |
+
self.$elProxy.text(self.options.icon);
|
158 |
+
}
|
159 |
+
// if it is an object (sensible choice)
|
160 |
+
else {
|
161 |
+
// (deep) clone the object if iconCloning == true, to make sure every instance has its own proxy. We use the icon without wrapping, no need to. We do not give it a class either, as the user will undoubtedly style the object on his own and since our css properties may conflict with his own
|
162 |
+
if (self.options.iconCloning) self.$elProxy = self.options.icon.clone(true);
|
163 |
+
else self.$elProxy = self.options.icon;
|
164 |
+
}
|
165 |
+
|
166 |
+
self.$elProxy.insertAfter(self.$el);
|
167 |
+
}
|
168 |
+
else {
|
169 |
+
self.$elProxy = self.$el;
|
170 |
+
}
|
171 |
+
|
172 |
+
// for 'click' and 'hover' triggers : bind on events to open the tooltip. Closing is now handled in _showNow() because of its bindings.
|
173 |
+
// Notes about touch events :
|
174 |
+
// - mouseenter, mouseleave and clicks happen even on pure touch devices because they are emulated. deviceIsPureTouch() is a simple attempt to detect them.
|
175 |
+
// - on hybrid devices, we do not prevent touch gesture from opening tooltips. It would be too complex to differentiate real mouse events from emulated ones.
|
176 |
+
// - we check deviceIsPureTouch() at each event rather than prior to binding because the situation may change during browsing
|
177 |
+
if (self.options.trigger == 'hover') {
|
178 |
+
|
179 |
+
// these binding are for mouse interaction only
|
180 |
+
self.$elProxy
|
181 |
+
.on('mouseenter.'+ self.namespace, function() {
|
182 |
+
if (!deviceIsPureTouch() || self.options.touchDevices) {
|
183 |
+
self.mouseIsOverProxy = true;
|
184 |
+
self._show();
|
185 |
+
}
|
186 |
+
})
|
187 |
+
.on('mouseleave.'+ self.namespace, function() {
|
188 |
+
if (!deviceIsPureTouch() || self.options.touchDevices) {
|
189 |
+
self.mouseIsOverProxy = false;
|
190 |
+
}
|
191 |
+
});
|
192 |
+
|
193 |
+
// for touch interaction only
|
194 |
+
if (deviceHasTouchCapability && self.options.touchDevices) {
|
195 |
+
|
196 |
+
// for touch devices, we immediately display the tooltip because we cannot rely on mouseleave to handle the delay
|
197 |
+
self.$elProxy.on('touchstart.'+ self.namespace, function() {
|
198 |
+
self._showNow();
|
199 |
+
});
|
200 |
+
}
|
201 |
+
}
|
202 |
+
else if (self.options.trigger == 'click') {
|
203 |
+
|
204 |
+
// note : for touch devices, we do not bind on touchstart, we only rely on the emulated clicks (triggered by taps)
|
205 |
+
self.$elProxy.on('click.'+ self.namespace, function() {
|
206 |
+
if (!deviceIsPureTouch() || self.options.touchDevices) {
|
207 |
+
self._show();
|
208 |
+
}
|
209 |
+
});
|
210 |
+
}
|
211 |
+
}
|
212 |
+
},
|
213 |
+
|
214 |
+
// this function will schedule the opening of the tooltip after the delay, if there is one
|
215 |
+
_show: function() {
|
216 |
+
|
217 |
+
var self = this;
|
218 |
+
|
219 |
+
if (self.Status != 'shown' && self.Status != 'appearing') {
|
220 |
+
|
221 |
+
if (self.options.delay) {
|
222 |
+
self.timerShow = setTimeout(function(){
|
223 |
+
|
224 |
+
// for hover trigger, we check if the mouse is still over the proxy, otherwise we do not show anything
|
225 |
+
if (self.options.trigger == 'click' || (self.options.trigger == 'hover' && self.mouseIsOverProxy)) {
|
226 |
+
self._showNow();
|
227 |
+
}
|
228 |
+
}, self.options.delay);
|
229 |
+
}
|
230 |
+
else self._showNow();
|
231 |
+
}
|
232 |
+
},
|
233 |
+
|
234 |
+
// this function will open the tooltip right away
|
235 |
+
_showNow: function(callback) {
|
236 |
+
|
237 |
+
var self = this;
|
238 |
+
|
239 |
+
// call our constructor custom function before continuing
|
240 |
+
self.options.functionBefore.call(self.$el, self.$el, function() {
|
241 |
+
|
242 |
+
// continue only if the tooltip is enabled and has any content
|
243 |
+
if (self.enabled && self.Content !== null) {
|
244 |
+
|
245 |
+
// save the method callback and cancel hide method callbacks
|
246 |
+
if (callback) self.callbacks.show.push(callback);
|
247 |
+
self.callbacks.hide = [];
|
248 |
+
|
249 |
+
//get rid of any appearance timer
|
250 |
+
clearTimeout(self.timerShow);
|
251 |
+
self.timerShow = null;
|
252 |
+
clearTimeout(self.timerHide);
|
253 |
+
self.timerHide = null;
|
254 |
+
|
255 |
+
// if we only want one tooltip open at a time, close all auto-closing tooltips currently open and not already disappearing
|
256 |
+
if (self.options.onlyOne) {
|
257 |
+
$('.tooltipstered').not(self.$el).each(function(i,el) {
|
258 |
+
|
259 |
+
var $el = $(el),
|
260 |
+
nss = $el.data('tooltipster-ns');
|
261 |
+
|
262 |
+
// iterate on all tooltips of the element
|
263 |
+
$.each(nss, function(i, ns){
|
264 |
+
var instance = $el.data(ns),
|
265 |
+
// we have to use the public methods here
|
266 |
+
s = instance.status(),
|
267 |
+
ac = instance.option('autoClose');
|
268 |
+
|
269 |
+
if (s !== 'hidden' && s !== 'disappearing' && ac) {
|
270 |
+
instance.hide();
|
271 |
+
}
|
272 |
+
});
|
273 |
+
});
|
274 |
+
}
|
275 |
+
|
276 |
+
var finish = function() {
|
277 |
+
self.Status = 'shown';
|
278 |
+
|
279 |
+
// trigger any show method custom callbacks and reset them
|
280 |
+
$.each(self.callbacks.show, function(i,c) { c.call(self.$el); });
|
281 |
+
self.callbacks.show = [];
|
282 |
+
};
|
283 |
+
|
284 |
+
// if this origin already has its tooltip open
|
285 |
+
if (self.Status !== 'hidden') {
|
286 |
+
|
287 |
+
// the timer (if any) will start (or restart) right now
|
288 |
+
var extraTime = 0;
|
289 |
+
|
290 |
+
// if it was disappearing, cancel that
|
291 |
+
if (self.Status === 'disappearing') {
|
292 |
+
|
293 |
+
self.Status = 'appearing';
|
294 |
+
|
295 |
+
if (supportsTransitions()) {
|
296 |
+
|
297 |
+
self.$tooltip
|
298 |
+
.clearQueue()
|
299 |
+
.removeClass('tooltipster-dying')
|
300 |
+
.addClass('tooltipster-'+ self.options.animation +'-show');
|
301 |
+
|
302 |
+
if (self.options.speed > 0) self.$tooltip.delay(self.options.speed);
|
303 |
+
|
304 |
+
self.$tooltip.queue(finish);
|
305 |
+
}
|
306 |
+
else {
|
307 |
+
// in case the tooltip was currently fading out, bring it back to life
|
308 |
+
self.$tooltip
|
309 |
+
.stop()
|
310 |
+
.fadeIn(finish);
|
311 |
+
}
|
312 |
+
}
|
313 |
+
// if the tooltip is already open, we still need to trigger the method custom callback
|
314 |
+
else if(self.Status === 'shown') {
|
315 |
+
finish();
|
316 |
+
}
|
317 |
+
}
|
318 |
+
// if the tooltip isn't already open, open that sucker up!
|
319 |
+
else {
|
320 |
+
|
321 |
+
self.Status = 'appearing';
|
322 |
+
|
323 |
+
// the timer (if any) will start when the tooltip has fully appeared after its transition
|
324 |
+
var extraTime = self.options.speed;
|
325 |
+
|
326 |
+
// disable horizontal scrollbar to keep overflowing tooltips from jacking with it and then restore it to its previous value
|
327 |
+
self.bodyOverflowX = $('body').css('overflow-x');
|
328 |
+
$('body').css('overflow-x', 'hidden');
|
329 |
+
|
330 |
+
// get some other settings related to building the tooltip
|
331 |
+
var animation = 'tooltipster-' + self.options.animation,
|
332 |
+
animationSpeed = '-webkit-transition-duration: '+ self.options.speed +'ms; -webkit-animation-duration: '+ self.options.speed +'ms; -moz-transition-duration: '+ self.options.speed +'ms; -moz-animation-duration: '+ self.options.speed +'ms; -o-transition-duration: '+ self.options.speed +'ms; -o-animation-duration: '+ self.options.speed +'ms; -ms-transition-duration: '+ self.options.speed +'ms; -ms-animation-duration: '+ self.options.speed +'ms; transition-duration: '+ self.options.speed +'ms; animation-duration: '+ self.options.speed +'ms;',
|
333 |
+
minWidth = self.options.minWidth ? 'min-width:'+ Math.round(self.options.minWidth) +'px;' : '',
|
334 |
+
maxWidth = self.options.maxWidth ? 'max-width:'+ Math.round(self.options.maxWidth) +'px;' : '',
|
335 |
+
pointerEvents = self.options.interactive ? 'pointer-events: auto;' : '';
|
336 |
+
|
337 |
+
// build the base of our tooltip
|
338 |
+
self.$tooltip = $('<div class="tooltipster-base '+ self.options.theme +'" style="'+ minWidth +' '+ maxWidth +' '+ pointerEvents +' '+ animationSpeed +'"><div class="tooltipster-content"></div></div>');
|
339 |
+
|
340 |
+
// only add the animation class if the user has a browser that supports animations
|
341 |
+
if (supportsTransitions()) self.$tooltip.addClass(animation);
|
342 |
+
|
343 |
+
// insert the content
|
344 |
+
self._content_insert();
|
345 |
+
|
346 |
+
// attach
|
347 |
+
self.$tooltip.appendTo('body');
|
348 |
+
|
349 |
+
// do all the crazy calculations and positioning
|
350 |
+
self.reposition();
|
351 |
+
|
352 |
+
// call our custom callback since the content of the tooltip is now part of the DOM
|
353 |
+
self.options.functionReady.call(self.$el, self.$el, self.$tooltip);
|
354 |
+
|
355 |
+
// animate in the tooltip
|
356 |
+
if (supportsTransitions()) {
|
357 |
+
|
358 |
+
self.$tooltip.addClass(animation + '-show');
|
359 |
+
|
360 |
+
if(self.options.speed > 0) self.$tooltip.delay(self.options.speed);
|
361 |
+
|
362 |
+
self.$tooltip.queue(finish);
|
363 |
+
}
|
364 |
+
else {
|
365 |
+
self.$tooltip.css('display', 'none').fadeIn(self.options.speed, finish);
|
366 |
+
}
|
367 |
+
|
368 |
+
// will check if our tooltip origin is removed while the tooltip is shown
|
369 |
+
self._interval_set();
|
370 |
+
|
371 |
+
// reposition on scroll (otherwise position:fixed element's tooltips will move away form their origin) and on resize (in case position can/has to be changed)
|
372 |
+
$(window).on('scroll.'+ self.namespace +' resize.'+ self.namespace, function() {
|
373 |
+
self.reposition();
|
374 |
+
});
|
375 |
+
|
376 |
+
// auto-close bindings
|
377 |
+
if (self.options.autoClose) {
|
378 |
+
|
379 |
+
// in case a listener is already bound for autoclosing (mouse or touch, hover or click), unbind it first
|
380 |
+
$('body').off('.'+ self.namespace);
|
381 |
+
|
382 |
+
// here we'll have to set different sets of bindings for both touch and mouse
|
383 |
+
if (self.options.trigger == 'hover') {
|
384 |
+
|
385 |
+
// if the user touches the body, hide
|
386 |
+
if (deviceHasTouchCapability) {
|
387 |
+
// timeout 0 : explanation below in click section
|
388 |
+
setTimeout(function() {
|
389 |
+
// we don't want to bind on click here because the initial touchstart event has not yet triggered its click event, which is thus about to happen
|
390 |
+
$('body').on('touchstart.'+ self.namespace, function() {
|
391 |
+
self.hide();
|
392 |
+
});
|
393 |
+
}, 0);
|
394 |
+
}
|
395 |
+
|
396 |
+
// if we have to allow interaction
|
397 |
+
if (self.options.interactive) {
|
398 |
+
|
399 |
+
// touch events inside the tooltip must not close it
|
400 |
+
if (deviceHasTouchCapability) {
|
401 |
+
self.$tooltip.on('touchstart.'+ self.namespace, function(event) {
|
402 |
+
event.stopPropagation();
|
403 |
+
});
|
404 |
+
}
|
405 |
+
|
406 |
+
// as for mouse interaction, we get rid of the tooltip only after the mouse has spent some time out of it
|
407 |
+
var tolerance = null;
|
408 |
+
|
409 |
+
self.$elProxy.add(self.$tooltip)
|
410 |
+
// hide after some time out of the proxy and the tooltip
|
411 |
+
.on('mouseleave.'+ self.namespace + '-autoClose', function() {
|
412 |
+
clearTimeout(tolerance);
|
413 |
+
tolerance = setTimeout(function(){
|
414 |
+
self.hide();
|
415 |
+
}, self.options.interactiveTolerance);
|
416 |
+
})
|
417 |
+
// suspend timeout when the mouse is over the proxy or the tooltip
|
418 |
+
.on('mouseenter.'+ self.namespace + '-autoClose', function() {
|
419 |
+
clearTimeout(tolerance);
|
420 |
+
});
|
421 |
+
}
|
422 |
+
// if this is a non-interactive tooltip, get rid of it if the mouse leaves
|
423 |
+
else {
|
424 |
+
self.$elProxy.on('mouseleave.'+ self.namespace + '-autoClose', function() {
|
425 |
+
self.hide();
|
426 |
+
});
|
427 |
+
}
|
428 |
+
|
429 |
+
// close the tooltip when the proxy gets a click (common behavior of native tooltips)
|
430 |
+
if (self.options.hideOnClick) {
|
431 |
+
|
432 |
+
self.$elProxy.on('click.'+ self.namespace + '-autoClose', function() {
|
433 |
+
self.hide();
|
434 |
+
});
|
435 |
+
}
|
436 |
+
}
|
437 |
+
// here we'll set the same bindings for both clicks and touch on the body to hide the tooltip
|
438 |
+
else if(self.options.trigger == 'click'){
|
439 |
+
|
440 |
+
// use a timeout to prevent immediate closing if the method was called on a click event and if options.delay == 0 (because of bubbling)
|
441 |
+
setTimeout(function() {
|
442 |
+
$('body').on('click.'+ self.namespace +' touchstart.'+ self.namespace, function() {
|
443 |
+
self.hide();
|
444 |
+
});
|
445 |
+
}, 0);
|
446 |
+
|
447 |
+
// if interactive, we'll stop the events that were emitted from inside the tooltip to stop autoClosing
|
448 |
+
if (self.options.interactive) {
|
449 |
+
|
450 |
+
// note : the touch events will just not be used if the plugin is not enabled on touch devices
|
451 |
+
self.$tooltip.on('click.'+ self.namespace +' touchstart.'+ self.namespace, function(event) {
|
452 |
+
event.stopPropagation();
|
453 |
+
});
|
454 |
+
}
|
455 |
+
}
|
456 |
+
}
|
457 |
+
}
|
458 |
+
|
459 |
+
// if we have a timer set, let the countdown begin
|
460 |
+
if (self.options.timer > 0) {
|
461 |
+
|
462 |
+
self.timerHide = setTimeout(function() {
|
463 |
+
self.timerHide = null;
|
464 |
+
self.hide();
|
465 |
+
}, self.options.timer + extraTime);
|
466 |
+
}
|
467 |
+
}
|
468 |
+
});
|
469 |
+
},
|
470 |
+
|
471 |
+
_interval_set: function() {
|
472 |
+
|
473 |
+
var self = this;
|
474 |
+
|
475 |
+
self.checkInterval = setInterval(function() {
|
476 |
+
|
477 |
+
// if the tooltip and/or its interval should be stopped
|
478 |
+
if (
|
479 |
+
// if the origin has been removed
|
480 |
+
$('body').find(self.$el).length === 0
|
481 |
+
// if the elProxy has been removed
|
482 |
+
|| $('body').find(self.$elProxy).length === 0
|
483 |
+
// if the tooltip has been closed
|
484 |
+
|| self.Status == 'hidden'
|
485 |
+
// if the tooltip has somehow been removed
|
486 |
+
|| $('body').find(self.$tooltip).length === 0
|
487 |
+
) {
|
488 |
+
// remove the tooltip if it's still here
|
489 |
+
if (self.Status == 'shown' || self.Status == 'appearing') self.hide();
|
490 |
+
|
491 |
+
// clear this interval as it is no longer necessary
|
492 |
+
self._interval_cancel();
|
493 |
+
}
|
494 |
+
// if everything is alright
|
495 |
+
else {
|
496 |
+
// compare the former and current positions of the elProxy to reposition the tooltip if need be
|
497 |
+
if(self.options.positionTracker){
|
498 |
+
|
499 |
+
var p = self._repositionInfo(self.$elProxy),
|
500 |
+
identical = false;
|
501 |
+
|
502 |
+
// compare size first (a change requires repositioning too)
|
503 |
+
if(areEqual(p.dimension, self.elProxyPosition.dimension)){
|
504 |
+
|
505 |
+
// for elements with a fixed position, we track the top and left properties (relative to window)
|
506 |
+
if(self.$elProxy.css('position') === 'fixed'){
|
507 |
+
if(areEqual(p.position, self.elProxyPosition.position)) identical = true;
|
508 |
+
}
|
509 |
+
// otherwise, track total offset (relative to document)
|
510 |
+
else {
|
511 |
+
if(areEqual(p.offset, self.elProxyPosition.offset)) identical = true;
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
if(!identical){
|
516 |
+
self.reposition();
|
517 |
+
self.options.positionTrackerCallback.call(self, self.$el);
|
518 |
+
}
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}, 200);
|
522 |
+
},
|
523 |
+
|
524 |
+
_interval_cancel: function() {
|
525 |
+
clearInterval(this.checkInterval);
|
526 |
+
// clean delete
|
527 |
+
this.checkInterval = null;
|
528 |
+
},
|
529 |
+
|
530 |
+
_content_set: function(content) {
|
531 |
+
// clone if asked. Cloning the object makes sure that each instance has its own version of the content (in case a same object were provided for several instances)
|
532 |
+
// reminder : typeof null === object
|
533 |
+
if (typeof content === 'object' && content !== null && this.options.contentCloning) {
|
534 |
+
content = content.clone(true);
|
535 |
+
}
|
536 |
+
this.Content = content;
|
537 |
+
},
|
538 |
+
|
539 |
+
_content_insert: function() {
|
540 |
+
|
541 |
+
var self = this,
|
542 |
+
$d = this.$tooltip.find('.tooltipster-content');
|
543 |
+
|
544 |
+
if (typeof self.Content === 'string' && !self.options.contentAsHTML) {
|
545 |
+
$d.text(self.Content);
|
546 |
+
}
|
547 |
+
else {
|
548 |
+
$d
|
549 |
+
.empty()
|
550 |
+
.append(self.Content);
|
551 |
+
}
|
552 |
+
},
|
553 |
+
|
554 |
+
_update: function(content) {
|
555 |
+
|
556 |
+
var self = this;
|
557 |
+
|
558 |
+
// change the content
|
559 |
+
self._content_set(content);
|
560 |
+
|
561 |
+
if (self.Content !== null) {
|
562 |
+
|
563 |
+
// update the tooltip if it is open
|
564 |
+
if (self.Status !== 'hidden') {
|
565 |
+
|
566 |
+
// reset the content in the tooltip
|
567 |
+
self._content_insert();
|
568 |
+
|
569 |
+
// reposition and resize the tooltip
|
570 |
+
self.reposition();
|
571 |
+
|
572 |
+
// if we want to play a little animation showing the content changed
|
573 |
+
if (self.options.updateAnimation) {
|
574 |
+
|
575 |
+
if (supportsTransitions()) {
|
576 |
+
|
577 |
+
self.$tooltip.css({
|
578 |
+
'width': '',
|
579 |
+
'-webkit-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms',
|
580 |
+
'-moz-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms',
|
581 |
+
'-o-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms',
|
582 |
+
'-ms-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms',
|
583 |
+
'transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms'
|
584 |
+
}).addClass('tooltipster-content-changing');
|
585 |
+
|
586 |
+
// reset the CSS transitions and finish the change animation
|
587 |
+
setTimeout(function() {
|
588 |
+
|
589 |
+
if(self.Status != 'hidden'){
|
590 |
+
|
591 |
+
self.$tooltip.removeClass('tooltipster-content-changing');
|
592 |
+
|
593 |
+
// after the changing animation has completed, reset the CSS transitions
|
594 |
+
setTimeout(function() {
|
595 |
+
|
596 |
+
if(self.Status !== 'hidden'){
|
597 |
+
self.$tooltip.css({
|
598 |
+
'-webkit-transition': self.options.speed + 'ms',
|
599 |
+
'-moz-transition': self.options.speed + 'ms',
|
600 |
+
'-o-transition': self.options.speed + 'ms',
|
601 |
+
'-ms-transition': self.options.speed + 'ms',
|
602 |
+
'transition': self.options.speed + 'ms'
|
603 |
+
});
|
604 |
+
}
|
605 |
+
}, self.options.speed);
|
606 |
+
}
|
607 |
+
}, self.options.speed);
|
608 |
+
}
|
609 |
+
else {
|
610 |
+
self.$tooltip.fadeTo(self.options.speed, 0.5, function() {
|
611 |
+
if(self.Status != 'hidden'){
|
612 |
+
self.$tooltip.fadeTo(self.options.speed, 1);
|
613 |
+
}
|
614 |
+
});
|
615 |
+
}
|
616 |
+
}
|
617 |
+
}
|
618 |
+
}
|
619 |
+
else {
|
620 |
+
self.hide();
|
621 |
+
}
|
622 |
+
},
|
623 |
+
|
624 |
+
_repositionInfo: function($el) {
|
625 |
+
return {
|
626 |
+
dimension: {
|
627 |
+
height: $el.outerHeight(false),
|
628 |
+
width: $el.outerWidth(false)
|
629 |
+
},
|
630 |
+
offset: $el.offset(),
|
631 |
+
position: {
|
632 |
+
left: parseInt($el.css('left')),
|
633 |
+
top: parseInt($el.css('top'))
|
634 |
+
}
|
635 |
+
};
|
636 |
+
},
|
637 |
+
|
638 |
+
hide: function(callback) {
|
639 |
+
|
640 |
+
var self = this;
|
641 |
+
|
642 |
+
// save the method custom callback and cancel any show method custom callbacks
|
643 |
+
if (callback) self.callbacks.hide.push(callback);
|
644 |
+
self.callbacks.show = [];
|
645 |
+
|
646 |
+
// get rid of any appearance timeout
|
647 |
+
clearTimeout(self.timerShow);
|
648 |
+
self.timerShow = null;
|
649 |
+
clearTimeout(self.timerHide);
|
650 |
+
self.timerHide = null;
|
651 |
+
|
652 |
+
var finishCallbacks = function() {
|
653 |
+
// trigger any hide method custom callbacks and reset them
|
654 |
+
$.each(self.callbacks.hide, function(i,c) { c.call(self.$el); });
|
655 |
+
self.callbacks.hide = [];
|
656 |
+
};
|
657 |
+
|
658 |
+
// hide
|
659 |
+
if (self.Status == 'shown' || self.Status == 'appearing') {
|
660 |
+
|
661 |
+
self.Status = 'disappearing';
|
662 |
+
|
663 |
+
var finish = function() {
|
664 |
+
|
665 |
+
self.Status = 'hidden';
|
666 |
+
|
667 |
+
// detach our content object first, so the next jQuery's remove() call does not unbind its event handlers
|
668 |
+
if (typeof self.Content == 'object' && self.Content !== null) {
|
669 |
+
self.Content.detach();
|
670 |
+
}
|
671 |
+
|
672 |
+
self.$tooltip.remove();
|
673 |
+
self.$tooltip = null;
|
674 |
+
|
675 |
+
// unbind orientationchange, scroll and resize listeners
|
676 |
+
$(window).off('.'+ self.namespace);
|
677 |
+
|
678 |
+
$('body')
|
679 |
+
// unbind any auto-closing click/touch listeners
|
680 |
+
.off('.'+ self.namespace)
|
681 |
+
.css('overflow-x', self.bodyOverflowX);
|
682 |
+
|
683 |
+
// unbind any auto-closing click/touch listeners
|
684 |
+
$('body').off('.'+ self.namespace);
|
685 |
+
|
686 |
+
// unbind any auto-closing hover listeners
|
687 |
+
self.$elProxy.off('.'+ self.namespace + '-autoClose');
|
688 |
+
|
689 |
+
// call our constructor custom callback function
|
690 |
+
self.options.functionAfter.call(self.$el, self.$el);
|
691 |
+
|
692 |
+
// call our method custom callbacks functions
|
693 |
+
finishCallbacks();
|
694 |
+
};
|
695 |
+
|
696 |
+
if (supportsTransitions()) {
|
697 |
+
|
698 |
+
self.$tooltip
|
699 |
+
.clearQueue()
|
700 |
+
.removeClass('tooltipster-' + self.options.animation + '-show')
|
701 |
+
// for transitions only
|
702 |
+
.addClass('tooltipster-dying');
|
703 |
+
|
704 |
+
if(self.options.speed > 0) self.$tooltip.delay(self.options.speed);
|
705 |
+
|
706 |
+
self.$tooltip.queue(finish);
|
707 |
+
}
|
708 |
+
else {
|
709 |
+
self.$tooltip
|
710 |
+
.stop()
|
711 |
+
.fadeOut(self.options.speed, finish);
|
712 |
+
}
|
713 |
+
}
|
714 |
+
// if the tooltip is already hidden, we still need to trigger the method custom callback
|
715 |
+
else if(self.Status == 'hidden') {
|
716 |
+
finishCallbacks();
|
717 |
+
}
|
718 |
+
|
719 |
+
return self;
|
720 |
+
},
|
721 |
+
|
722 |
+
// the public show() method is actually an alias for the private showNow() method
|
723 |
+
show: function(callback) {
|
724 |
+
this._showNow(callback);
|
725 |
+
return this;
|
726 |
+
},
|
727 |
+
|
728 |
+
// 'update' is deprecated in favor of 'content' but is kept for backward compatibility
|
729 |
+
update: function(c) {
|
730 |
+
return this.content(c);
|
731 |
+
},
|
732 |
+
content: function(c) {
|
733 |
+
// getter method
|
734 |
+
if(typeof c === 'undefined'){
|
735 |
+
return this.Content;
|
736 |
+
}
|
737 |
+
// setter method
|
738 |
+
else {
|
739 |
+
this._update(c);
|
740 |
+
return this;
|
741 |
+
}
|
742 |
+
},
|
743 |
+
|
744 |
+
reposition: function() {
|
745 |
+
|
746 |
+
var self = this;
|
747 |
+
|
748 |
+
// in case the tooltip has been removed from DOM manually
|
749 |
+
if ($('body').find(self.$tooltip).length !== 0) {
|
750 |
+
|
751 |
+
// reset width
|
752 |
+
self.$tooltip.css('width', '');
|
753 |
+
|
754 |
+
// find variables to determine placement
|
755 |
+
self.elProxyPosition = self._repositionInfo(self.$elProxy);
|
756 |
+
var arrowReposition = null,
|
757 |
+
windowWidth = $(window).width(),
|
758 |
+
// shorthand
|
759 |
+
proxy = self.elProxyPosition,
|
760 |
+
tooltipWidth = self.$tooltip.outerWidth(false),
|
761 |
+
tooltipInnerWidth = self.$tooltip.innerWidth() + 1, // this +1 stops FireFox from sometimes forcing an additional text line
|
762 |
+
tooltipHeight = self.$tooltip.outerHeight(false);
|
763 |
+
|
764 |
+
// if this is an <area> tag inside a <map>, all hell breaks loose. Recalculate all the measurements based on coordinates
|
765 |
+
if (self.$elProxy.is('area')) {
|
766 |
+
var areaShape = self.$elProxy.attr('shape'),
|
767 |
+
mapName = self.$elProxy.parent().attr('name'),
|
768 |
+
map = $('img[usemap="#'+ mapName +'"]'),
|
769 |
+
mapOffsetLeft = map.offset().left,
|
770 |
+
mapOffsetTop = map.offset().top,
|
771 |
+
areaMeasurements = self.$elProxy.attr('coords') !== undefined ? self.$elProxy.attr('coords').split(',') : undefined;
|
772 |
+
|
773 |
+
if (areaShape == 'circle') {
|
774 |
+
var areaLeft = parseInt(areaMeasurements[0]),
|
775 |
+
areaTop = parseInt(areaMeasurements[1]),
|
776 |
+
areaWidth = parseInt(areaMeasurements[2]);
|
777 |
+
proxy.dimension.height = areaWidth * 2;
|
778 |
+
proxy.dimension.width = areaWidth * 2;
|
779 |
+
proxy.offset.top = mapOffsetTop + areaTop - areaWidth;
|
780 |
+
proxy.offset.left = mapOffsetLeft + areaLeft - areaWidth;
|
781 |
+
}
|
782 |
+
else if (areaShape == 'rect') {
|
783 |
+
var areaLeft = parseInt(areaMeasurements[0]),
|
784 |
+
areaTop = parseInt(areaMeasurements[1]),
|
785 |
+
areaRight = parseInt(areaMeasurements[2]),
|
786 |
+
areaBottom = parseInt(areaMeasurements[3]);
|
787 |
+
proxy.dimension.height = areaBottom - areaTop;
|
788 |
+
proxy.dimension.width = areaRight - areaLeft;
|
789 |
+
proxy.offset.top = mapOffsetTop + areaTop;
|
790 |
+
proxy.offset.left = mapOffsetLeft + areaLeft;
|
791 |
+
}
|
792 |
+
else if (areaShape == 'poly') {
|
793 |
+
var areaXs = [],
|
794 |
+
areaYs = [],
|
795 |
+
areaSmallestX = 0,
|
796 |
+
areaSmallestY = 0,
|
797 |
+
areaGreatestX = 0,
|
798 |
+
areaGreatestY = 0,
|
799 |
+
arrayAlternate = 'even';
|
800 |
+
|
801 |
+
for (var i = 0; i < areaMeasurements.length; i++) {
|
802 |
+
var areaNumber = parseInt(areaMeasurements[i]);
|
803 |
+
|
804 |
+
if (arrayAlternate == 'even') {
|
805 |
+
if (areaNumber > areaGreatestX) {
|
806 |
+
areaGreatestX = areaNumber;
|
807 |
+
if (i === 0) {
|
808 |
+
areaSmallestX = areaGreatestX;
|
809 |
+
}
|
810 |
+
}
|
811 |
+
|
812 |
+
if (areaNumber < areaSmallestX) {
|
813 |
+
areaSmallestX = areaNumber;
|
814 |
+
}
|
815 |
+
|
816 |
+
arrayAlternate = 'odd';
|
817 |
+
}
|
818 |
+
else {
|
819 |
+
if (areaNumber > areaGreatestY) {
|
820 |
+
areaGreatestY = areaNumber;
|
821 |
+
if (i == 1) {
|
822 |
+
areaSmallestY = areaGreatestY;
|
823 |
+
}
|
824 |
+
}
|
825 |
+
|
826 |
+
if (areaNumber < areaSmallestY) {
|
827 |
+
areaSmallestY = areaNumber;
|
828 |
+
}
|
829 |
+
|
830 |
+
arrayAlternate = 'even';
|
831 |
+
}
|
832 |
+
}
|
833 |
+
|
834 |
+
proxy.dimension.height = areaGreatestY - areaSmallestY;
|
835 |
+
proxy.dimension.width = areaGreatestX - areaSmallestX;
|
836 |
+
proxy.offset.top = mapOffsetTop + areaSmallestY;
|
837 |
+
proxy.offset.left = mapOffsetLeft + areaSmallestX;
|
838 |
+
}
|
839 |
+
else {
|
840 |
+
proxy.dimension.height = map.outerHeight(false);
|
841 |
+
proxy.dimension.width = map.outerWidth(false);
|
842 |
+
proxy.offset.top = mapOffsetTop;
|
843 |
+
proxy.offset.left = mapOffsetLeft;
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
+
// our function and global vars for positioning our tooltip
|
848 |
+
var myLeft = 0,
|
849 |
+
myLeftMirror = 0,
|
850 |
+
myTop = 0,
|
851 |
+
offsetY = parseInt(self.options.offsetY),
|
852 |
+
offsetX = parseInt(self.options.offsetX),
|
853 |
+
// this is the arrow position that will eventually be used. It may differ from the position option if the tooltip cannot be displayed in this position
|
854 |
+
practicalPosition = self.options.position;
|
855 |
+
|
856 |
+
// a function to detect if the tooltip is going off the screen horizontally. If so, reposition the crap out of it!
|
857 |
+
function dontGoOffScreenX() {
|
858 |
+
|
859 |
+
var windowLeft = $(window).scrollLeft();
|
860 |
+
|
861 |
+
// if the tooltip goes off the left side of the screen, line it up with the left side of the window
|
862 |
+
if((myLeft - windowLeft) < 0) {
|
863 |
+
arrowReposition = myLeft - windowLeft;
|
864 |
+
myLeft = windowLeft;
|
865 |
+
}
|
866 |
+
|
867 |
+
// if the tooltip goes off the right of the screen, line it up with the right side of the window
|
868 |
+
if (((myLeft + tooltipWidth) - windowLeft) > windowWidth) {
|
869 |
+
arrowReposition = myLeft - ((windowWidth + windowLeft) - tooltipWidth);
|
870 |
+
myLeft = (windowWidth + windowLeft) - tooltipWidth;
|
871 |
+
}
|
872 |
+
}
|
873 |
+
|
874 |
+
// a function to detect if the tooltip is going off the screen vertically. If so, switch to the opposite!
|
875 |
+
function dontGoOffScreenY(switchTo, switchFrom) {
|
876 |
+
// if it goes off the top off the page
|
877 |
+
if(((proxy.offset.top - $(window).scrollTop() - tooltipHeight - offsetY - 12) < 0) && (switchFrom.indexOf('top') > -1)) {
|
878 |
+
practicalPosition = switchTo;
|
879 |
+
}
|
880 |
+
|
881 |
+
// if it goes off the bottom of the page
|
882 |
+
if (((proxy.offset.top + proxy.dimension.height + tooltipHeight + 12 + offsetY) > ($(window).scrollTop() + $(window).height())) && (switchFrom.indexOf('bottom') > -1)) {
|
883 |
+
practicalPosition = switchTo;
|
884 |
+
myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12;
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
if(practicalPosition == 'top') {
|
889 |
+
var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width);
|
890 |
+
myLeft = (proxy.offset.left + offsetX) - (leftDifference / 2);
|
891 |
+
myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12;
|
892 |
+
dontGoOffScreenX();
|
893 |
+
dontGoOffScreenY('bottom', 'top');
|
894 |
+
}
|
895 |
+
|
896 |
+
if(practicalPosition == 'top-left') {
|
897 |
+
myLeft = proxy.offset.left + offsetX;
|
898 |
+
myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12;
|
899 |
+
dontGoOffScreenX();
|
900 |
+
dontGoOffScreenY('bottom-left', 'top-left');
|
901 |
+
}
|
902 |
+
|
903 |
+
if(practicalPosition == 'top-right') {
|
904 |
+
myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth;
|
905 |
+
myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12;
|
906 |
+
dontGoOffScreenX();
|
907 |
+
dontGoOffScreenY('bottom-right', 'top-right');
|
908 |
+
}
|
909 |
+
|
910 |
+
if(practicalPosition == 'bottom') {
|
911 |
+
var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width);
|
912 |
+
myLeft = proxy.offset.left - (leftDifference / 2) + offsetX;
|
913 |
+
myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12;
|
914 |
+
dontGoOffScreenX();
|
915 |
+
dontGoOffScreenY('top', 'bottom');
|
916 |
+
}
|
917 |
+
|
918 |
+
if(practicalPosition == 'bottom-left') {
|
919 |
+
myLeft = proxy.offset.left + offsetX;
|
920 |
+
myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12;
|
921 |
+
dontGoOffScreenX();
|
922 |
+
dontGoOffScreenY('top-left', 'bottom-left');
|
923 |
+
}
|
924 |
+
|
925 |
+
if(practicalPosition == 'bottom-right') {
|
926 |
+
myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth;
|
927 |
+
myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12;
|
928 |
+
dontGoOffScreenX();
|
929 |
+
dontGoOffScreenY('top-right', 'bottom-right');
|
930 |
+
}
|
931 |
+
|
932 |
+
if(practicalPosition == 'left') {
|
933 |
+
myLeft = proxy.offset.left - offsetX - tooltipWidth - 12;
|
934 |
+
myLeftMirror = proxy.offset.left + offsetX + proxy.dimension.width + 12;
|
935 |
+
var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height);
|
936 |
+
myTop = proxy.offset.top - (topDifference / 2) - offsetY;
|
937 |
+
|
938 |
+
// if the tooltip goes off boths sides of the page
|
939 |
+
if((myLeft < 0) && ((myLeftMirror + tooltipWidth) > windowWidth)) {
|
940 |
+
var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2,
|
941 |
+
newWidth = (tooltipWidth + myLeft) - borderWidth;
|
942 |
+
self.$tooltip.css('width', newWidth + 'px');
|
943 |
+
|
944 |
+
tooltipHeight = self.$tooltip.outerHeight(false);
|
945 |
+
myLeft = proxy.offset.left - offsetX - newWidth - 12 - borderWidth;
|
946 |
+
topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height);
|
947 |
+
myTop = proxy.offset.top - (topDifference / 2) - offsetY;
|
948 |
+
}
|
949 |
+
|
950 |
+
// if it only goes off one side, flip it to the other side
|
951 |
+
else if(myLeft < 0) {
|
952 |
+
myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12;
|
953 |
+
arrowReposition = 'left';
|
954 |
+
}
|
955 |
+
}
|
956 |
+
|
957 |
+
if(practicalPosition == 'right') {
|
958 |
+
myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12;
|
959 |
+
myLeftMirror = proxy.offset.left - offsetX - tooltipWidth - 12;
|
960 |
+
var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height);
|
961 |
+
myTop = proxy.offset.top - (topDifference / 2) - offsetY;
|
962 |
+
|
963 |
+
// if the tooltip goes off boths sides of the page
|
964 |
+
if(((myLeft + tooltipWidth) > windowWidth) && (myLeftMirror < 0)) {
|
965 |
+
var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2,
|
966 |
+
newWidth = (windowWidth - myLeft) - borderWidth;
|
967 |
+
self.$tooltip.css('width', newWidth + 'px');
|
968 |
+
|
969 |
+
tooltipHeight = self.$tooltip.outerHeight(false);
|
970 |
+
topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height);
|
971 |
+
myTop = proxy.offset.top - (topDifference / 2) - offsetY;
|
972 |
+
}
|
973 |
+
|
974 |
+
// if it only goes off one side, flip it to the other side
|
975 |
+
else if((myLeft + tooltipWidth) > windowWidth) {
|
976 |
+
myLeft = proxy.offset.left - offsetX - tooltipWidth - 12;
|
977 |
+
arrowReposition = 'right';
|
978 |
+
}
|
979 |
+
}
|
980 |
+
|
981 |
+
// if arrow is set true, style it and append it
|
982 |
+
if (self.options.arrow) {
|
983 |
+
|
984 |
+
var arrowClass = 'tooltipster-arrow-' + practicalPosition;
|
985 |
+
|
986 |
+
// set color of the arrow
|
987 |
+
if(self.options.arrowColor.length < 1) {
|
988 |
+
var arrowColor = self.$tooltip.css('background-color');
|
989 |
+
}
|
990 |
+
else {
|
991 |
+
var arrowColor = self.options.arrowColor;
|
992 |
+
}
|
993 |
+
|
994 |
+
// if the tooltip was going off the page and had to re-adjust, we need to update the arrow's position
|
995 |
+
if (!arrowReposition) {
|
996 |
+
arrowReposition = '';
|
997 |
+
}
|
998 |
+
else if (arrowReposition == 'left') {
|
999 |
+
arrowClass = 'tooltipster-arrow-right';
|
1000 |
+
arrowReposition = '';
|
1001 |
+
}
|
1002 |
+
else if (arrowReposition == 'right') {
|
1003 |
+
arrowClass = 'tooltipster-arrow-left';
|
1004 |
+
arrowReposition = '';
|
1005 |
+
}
|
1006 |
+
else {
|
1007 |
+
arrowReposition = 'left:'+ Math.round(arrowReposition) +'px;';
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
// building the logic to create the border around the arrow of the tooltip
|
1011 |
+
if ((practicalPosition == 'top') || (practicalPosition == 'top-left') || (practicalPosition == 'top-right')) {
|
1012 |
+
var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')),
|
1013 |
+
tooltipBorderColor = self.$tooltip.css('border-bottom-color');
|
1014 |
+
}
|
1015 |
+
else if ((practicalPosition == 'bottom') || (practicalPosition == 'bottom-left') || (practicalPosition == 'bottom-right')) {
|
1016 |
+
var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-top-width')),
|
1017 |
+
tooltipBorderColor = self.$tooltip.css('border-top-color');
|
1018 |
+
}
|
1019 |
+
else if (practicalPosition == 'left') {
|
1020 |
+
var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-right-width')),
|
1021 |
+
tooltipBorderColor = self.$tooltip.css('border-right-color');
|
1022 |
+
}
|
1023 |
+
else if (practicalPosition == 'right') {
|
1024 |
+
var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-left-width')),
|
1025 |
+
tooltipBorderColor = self.$tooltip.css('border-left-color');
|
1026 |
+
}
|
1027 |
+
else {
|
1028 |
+
var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')),
|
1029 |
+
tooltipBorderColor = self.$tooltip.css('border-bottom-color');
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
if (tooltipBorderWidth > 1) {
|
1033 |
+
tooltipBorderWidth++;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
var arrowBorder = '';
|
1037 |
+
if (tooltipBorderWidth !== 0) {
|
1038 |
+
var arrowBorderSize = '',
|
1039 |
+
arrowBorderColor = 'border-color: '+ tooltipBorderColor +';';
|
1040 |
+
if (arrowClass.indexOf('bottom') !== -1) {
|
1041 |
+
arrowBorderSize = 'margin-top: -'+ Math.round(tooltipBorderWidth) +'px;';
|
1042 |
+
}
|
1043 |
+
else if (arrowClass.indexOf('top') !== -1) {
|
1044 |
+
arrowBorderSize = 'margin-bottom: -'+ Math.round(tooltipBorderWidth) +'px;';
|
1045 |
+
}
|
1046 |
+
else if (arrowClass.indexOf('left') !== -1) {
|
1047 |
+
arrowBorderSize = 'margin-right: -'+ Math.round(tooltipBorderWidth) +'px;';
|
1048 |
+
}
|
1049 |
+
else if (arrowClass.indexOf('right') !== -1) {
|
1050 |
+
arrowBorderSize = 'margin-left: -'+ Math.round(tooltipBorderWidth) +'px;';
|
1051 |
+
}
|
1052 |
+
arrowBorder = '<span class="tooltipster-arrow-border" style="'+ arrowBorderSize +' '+ arrowBorderColor +';"></span>';
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
// if the arrow already exists, remove and replace it
|
1056 |
+
self.$tooltip.find('.tooltipster-arrow').remove();
|
1057 |
+
|
1058 |
+
// build out the arrow and append it
|
1059 |
+
var arrowConstruct = '<div class="'+ arrowClass +' tooltipster-arrow" style="'+ arrowReposition +'">'+ arrowBorder +'<span style="border-color:'+ arrowColor +';"></span></div>';
|
1060 |
+
self.$tooltip.append(arrowConstruct);
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
// position the tooltip
|
1064 |
+
self.$tooltip.css({'top': Math.round(myTop) + 'px', 'left': Math.round(myLeft) + 'px'});
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
return self;
|
1068 |
+
},
|
1069 |
+
|
1070 |
+
enable: function() {
|
1071 |
+
this.enabled = true;
|
1072 |
+
return this;
|
1073 |
+
},
|
1074 |
+
|
1075 |
+
disable: function() {
|
1076 |
+
// hide first, in case the tooltip would not disappear on its own (autoClose false)
|
1077 |
+
this.hide();
|
1078 |
+
this.enabled = false;
|
1079 |
+
return this;
|
1080 |
+
},
|
1081 |
+
|
1082 |
+
destroy: function() {
|
1083 |
+
|
1084 |
+
var self = this;
|
1085 |
+
|
1086 |
+
self.hide();
|
1087 |
+
|
1088 |
+
// remove the icon, if any
|
1089 |
+
if (self.$el[0] !== self.$elProxy[0]) {
|
1090 |
+
self.$elProxy.remove();
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
self.$el
|
1094 |
+
.removeData(self.namespace)
|
1095 |
+
.off('.'+ self.namespace);
|
1096 |
+
|
1097 |
+
var ns = self.$el.data('tooltipster-ns');
|
1098 |
+
|
1099 |
+
// if there are no more tooltips on this element
|
1100 |
+
if(ns.length === 1){
|
1101 |
+
|
1102 |
+
// optional restoration of a title attribute
|
1103 |
+
var title = null;
|
1104 |
+
if (self.options.restoration === 'previous'){
|
1105 |
+
title = self.$el.data('tooltipster-initialTitle');
|
1106 |
+
}
|
1107 |
+
else if(self.options.restoration === 'current'){
|
1108 |
+
|
1109 |
+
// old school technique to stringify when outerHTML is not supported
|
1110 |
+
title =
|
1111 |
+
(typeof self.Content === 'string') ?
|
1112 |
+
self.Content :
|
1113 |
+
$('<div></div>').append(self.Content).html();
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
if (title) {
|
1117 |
+
self.$el.attr('title', title);
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
// final cleaning
|
1121 |
+
self.$el
|
1122 |
+
.removeClass('tooltipstered')
|
1123 |
+
.removeData('tooltipster-ns')
|
1124 |
+
.removeData('tooltipster-initialTitle');
|
1125 |
+
}
|
1126 |
+
else {
|
1127 |
+
// remove the instance namespace from the list of namespaces of tooltips present on the element
|
1128 |
+
ns = $.grep(ns, function(el, i){
|
1129 |
+
return el !== self.namespace;
|
1130 |
+
});
|
1131 |
+
self.$el.data('tooltipster-ns', ns);
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
return self;
|
1135 |
+
},
|
1136 |
+
|
1137 |
+
elementIcon: function() {
|
1138 |
+
return (this.$el[0] !== this.$elProxy[0]) ? this.$elProxy[0] : undefined;
|
1139 |
+
},
|
1140 |
+
|
1141 |
+
elementTooltip: function() {
|
1142 |
+
return this.$tooltip ? this.$tooltip[0] : undefined;
|
1143 |
+
},
|
1144 |
+
|
1145 |
+
// public methods but for internal use only
|
1146 |
+
// getter if val is ommitted, setter otherwise
|
1147 |
+
option: function(o, val) {
|
1148 |
+
if (typeof val == 'undefined') return this.options[o];
|
1149 |
+
else {
|
1150 |
+
this.options[o] = val;
|
1151 |
+
return this;
|
1152 |
+
}
|
1153 |
+
},
|
1154 |
+
status: function() {
|
1155 |
+
return this.Status;
|
1156 |
+
}
|
1157 |
+
};
|
1158 |
+
|
1159 |
+
$.fn[pluginName] = function () {
|
1160 |
+
|
1161 |
+
// for using in closures
|
1162 |
+
var args = arguments;
|
1163 |
+
|
1164 |
+
// if we are not in the context of jQuery wrapped HTML element(s) :
|
1165 |
+
// this happens when calling static methods in the form $.fn.tooltipster('methodName'), or when calling $(sel).tooltipster('methodName or options') where $(sel) does not match anything
|
1166 |
+
if (this.length === 0) {
|
1167 |
+
|
1168 |
+
// if the first argument is a method name
|
1169 |
+
if (typeof args[0] === 'string') {
|
1170 |
+
|
1171 |
+
var methodIsStatic = true;
|
1172 |
+
|
1173 |
+
// list static methods here (usable by calling $.fn.tooltipster('methodName');)
|
1174 |
+
switch (args[0]) {
|
1175 |
+
|
1176 |
+
case 'setDefaults':
|
1177 |
+
// change default options for all future instances
|
1178 |
+
$.extend(defaults, args[1]);
|
1179 |
+
break;
|
1180 |
+
|
1181 |
+
default:
|
1182 |
+
methodIsStatic = false;
|
1183 |
+
break;
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
// $.fn.tooltipster('methodName') calls will return true
|
1187 |
+
if (methodIsStatic) return true;
|
1188 |
+
// $(sel).tooltipster('methodName') calls will return the list of objects event though it's empty because chaining should work on empty lists
|
1189 |
+
else return this;
|
1190 |
+
}
|
1191 |
+
// the first argument is undefined or an object of options : we are initalizing but there is no element matched by selector
|
1192 |
+
else {
|
1193 |
+
// still chainable : same as above
|
1194 |
+
return this;
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
// this happens when calling $(sel).tooltipster('methodName or options') where $(sel) matches one or more elements
|
1198 |
+
else {
|
1199 |
+
|
1200 |
+
// method calls
|
1201 |
+
if (typeof args[0] === 'string') {
|
1202 |
+
|
1203 |
+
var v = '#*$~&';
|
1204 |
+
|
1205 |
+
this.each(function() {
|
1206 |
+
|
1207 |
+
// retrieve the namepaces of the tooltip(s) that exist on that element. We will interact with the first tooltip only.
|
1208 |
+
var ns = $(this).data('tooltipster-ns'),
|
1209 |
+
// self represents the instance of the first tooltipster plugin associated to the current HTML object of the loop
|
1210 |
+
self = ns ? $(this).data(ns[0]) : null;
|
1211 |
+
|
1212 |
+
// if the current element holds a tooltipster instance
|
1213 |
+
if (self) {
|
1214 |
+
|
1215 |
+
if (typeof self[args[0]] === 'function') {
|
1216 |
+
// note : args[1] and args[2] may not be defined
|
1217 |
+
var resp = self[args[0]](args[1], args[2]);
|
1218 |
+
}
|
1219 |
+
else {
|
1220 |
+
throw new Error('Unknown method .tooltipster("' + args[0] + '")');
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
// if the function returned anything other than the instance itself (which implies chaining)
|
1224 |
+
if (resp !== self){
|
1225 |
+
v = resp;
|
1226 |
+
// return false to stop .each iteration on the first element matched by the selector
|
1227 |
+
return false;
|
1228 |
+
}
|
1229 |
+
}
|
1230 |
+
else {
|
1231 |
+
throw new Error('You called Tooltipster\'s "' + args[0] + '" method on an uninitialized element');
|
1232 |
+
}
|
1233 |
+
});
|
1234 |
+
|
1235 |
+
return (v !== '#*$~&') ? v : this;
|
1236 |
+
}
|
1237 |
+
// first argument is undefined or an object : the tooltip is initializing
|
1238 |
+
else {
|
1239 |
+
|
1240 |
+
var instances = [],
|
1241 |
+
// is there a defined value for the multiple option in the options object ?
|
1242 |
+
multipleIsSet = args[0] && typeof args[0].multiple !== 'undefined',
|
1243 |
+
// if the multiple option is set to true, or if it's not defined but set to true in the defaults
|
1244 |
+
multiple = (multipleIsSet && args[0].multiple) || (!multipleIsSet && defaults.multiple),
|
1245 |
+
// same for debug
|
1246 |
+
debugIsSet = args[0] && typeof args[0].debug !== 'undefined',
|
1247 |
+
debug = (debugIsSet && args[0].debug) || (!debugIsSet && defaults.debug);
|
1248 |
+
|
1249 |
+
// initialize a tooltipster instance for each element if it doesn't already have one or if the multiple option is set, and attach the object to it
|
1250 |
+
this.each(function () {
|
1251 |
+
|
1252 |
+
var go = false,
|
1253 |
+
ns = $(this).data('tooltipster-ns'),
|
1254 |
+
instance = null;
|
1255 |
+
|
1256 |
+
if (!ns) {
|
1257 |
+
go = true;
|
1258 |
+
}
|
1259 |
+
else if (multiple) {
|
1260 |
+
go = true;
|
1261 |
+
}
|
1262 |
+
else if (debug) {
|
1263 |
+
console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.');
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
if (go) {
|
1267 |
+
instance = new Plugin(this, args[0]);
|
1268 |
+
|
1269 |
+
// save the reference of the new instance
|
1270 |
+
if (!ns) ns = [];
|
1271 |
+
ns.push(instance.namespace);
|
1272 |
+
$(this).data('tooltipster-ns', ns)
|
1273 |
+
|
1274 |
+
// save the instance itself
|
1275 |
+
$(this).data(instance.namespace, instance);
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
instances.push(instance);
|
1279 |
+
});
|
1280 |
+
|
1281 |
+
if (multiple) return instances;
|
1282 |
+
else return this;
|
1283 |
+
}
|
1284 |
+
}
|
1285 |
+
};
|
1286 |
+
|
1287 |
+
// quick & dirty compare function (not bijective nor multidimensional)
|
1288 |
+
function areEqual(a,b) {
|
1289 |
+
var same = true;
|
1290 |
+
$.each(a, function(i, el){
|
1291 |
+
if(typeof b[i] === 'undefined' || a[i] !== b[i]){
|
1292 |
+
same = false;
|
1293 |
+
return false;
|
1294 |
+
}
|
1295 |
+
});
|
1296 |
+
return same;
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
// detect if this device can trigger touch events
|
1300 |
+
var deviceHasTouchCapability = !!('ontouchstart' in window);
|
1301 |
+
|
1302 |
+
// we'll assume the device has no mouse until we detect any mouse movement
|
1303 |
+
var deviceHasMouse = false;
|
1304 |
+
$('body').one('mousemove', function() {
|
1305 |
+
deviceHasMouse = true;
|
1306 |
+
});
|
1307 |
+
|
1308 |
+
function deviceIsPureTouch() {
|
1309 |
+
return (!deviceHasMouse && deviceHasTouchCapability);
|
1310 |
+
}
|
1311 |
+
|
1312 |
+
// detecting support for CSS transitions
|
1313 |
+
function supportsTransitions() {
|
1314 |
+
var b = document.body || document.documentElement,
|
1315 |
+
s = b.style,
|
1316 |
+
p = 'transition';
|
1317 |
+
|
1318 |
+
if(typeof s[p] == 'string') {return true; }
|
1319 |
+
|
1320 |
+
v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'],
|
1321 |
+
p = p.charAt(0).toUpperCase() + p.substr(1);
|
1322 |
+
for(var i=0; i<v.length; i++) {
|
1323 |
+
if(typeof s[v[i] + p] == 'string') { return true; }
|
1324 |
+
}
|
1325 |
+
return false;
|
1326 |
+
}
|
1327 |
+
})( jQuery, window, document );
|
admin/js/jquery.tooltipster.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
/* Tooltipster v3.3.0 */;(function(e,t,n){function s(t,n){this.bodyOverflowX;this.callbacks={hide:[],show:[]};this.checkInterval=null;this.Content;this.$el=e(t);this.$elProxy;this.elProxyPosition;this.enabled=true;this.options=e.extend({},i,n);this.mouseIsOverProxy=false;this.namespace="tooltipster-"+Math.round(Math.random()*1e5);this.Status="hidden";this.timerHide=null;this.timerShow=null;this.$tooltip;this.options.iconTheme=this.options.iconTheme.replace(".","");this.options.theme=this.options.theme.replace(".","");this._init()}function o(t,n){var r=true;e.each(t,function(e,i){if(typeof n[e]==="undefined"||t[e]!==n[e]){r=false;return false}});return r}function f(){return!a&&u}function l(){var e=n.body||n.documentElement,t=e.style,r="transition";if(typeof t[r]=="string"){return true}v=["Moz","Webkit","Khtml","O","ms"],r=r.charAt(0).toUpperCase()+r.substr(1);for(var i=0;i<v.length;i++){if(typeof t[v[i]+r]=="string"){return true}}return false}var r="tooltipster",i={animation:"fade",arrow:true,arrowColor:"",autoClose:true,content:null,contentAsHTML:false,contentCloning:true,debug:true,delay:200,minWidth:0,maxWidth:null,functionInit:function(e,t){},functionBefore:function(e,t){t()},functionReady:function(e,t){},functionAfter:function(e){},hideOnClick:false,icon:"(?)",iconCloning:true,iconDesktop:false,iconTouch:false,iconTheme:"tooltipster-icon",interactive:false,interactiveTolerance:350,multiple:false,offsetX:0,offsetY:0,onlyOne:false,position:"top",positionTracker:false,positionTrackerCallback:function(e){if(this.option("trigger")=="hover"&&this.option("autoClose")){this.hide()}},restoration:"current",speed:350,timer:0,theme:"tooltipster-default",touchDevices:true,trigger:"hover",updateAnimation:true};s.prototype={_init:function(){var t=this;if(n.querySelector){var r=null;if(t.$el.data("tooltipster-initialTitle")===undefined){r=t.$el.attr("title");if(r===undefined)r=null;t.$el.data("tooltipster-initialTitle",r)}if(t.options.content!==null){t._content_set(t.options.content)}else{t._content_set(r)}var i=t.options.functionInit.call(t.$el,t.$el,t.Content);if(typeof i!=="undefined")t._content_set(i);t.$el.removeAttr("title").addClass("tooltipstered");if(!u&&t.options.iconDesktop||u&&t.options.iconTouch){if(typeof t.options.icon==="string"){t.$elProxy=e('<span class="'+t.options.iconTheme+'"></span>');t.$elProxy.text(t.options.icon)}else{if(t.options.iconCloning)t.$elProxy=t.options.icon.clone(true);else t.$elProxy=t.options.icon}t.$elProxy.insertAfter(t.$el)}else{t.$elProxy=t.$el}if(t.options.trigger=="hover"){t.$elProxy.on("mouseenter."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=true;t._show()}}).on("mouseleave."+t.namespace,function(){if(!f()||t.options.touchDevices){t.mouseIsOverProxy=false}});if(u&&t.options.touchDevices){t.$elProxy.on("touchstart."+t.namespace,function(){t._showNow()})}}else if(t.options.trigger=="click"){t.$elProxy.on("click."+t.namespace,function(){if(!f()||t.options.touchDevices){t._show()}})}}},_show:function(){var e=this;if(e.Status!="shown"&&e.Status!="appearing"){if(e.options.delay){e.timerShow=setTimeout(function(){if(e.options.trigger=="click"||e.options.trigger=="hover"&&e.mouseIsOverProxy){e._showNow()}},e.options.delay)}else e._showNow()}},_showNow:function(n){var r=this;r.options.functionBefore.call(r.$el,r.$el,function(){if(r.enabled&&r.Content!==null){if(n)r.callbacks.show.push(n);r.callbacks.hide=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;if(r.options.onlyOne){e(".tooltipstered").not(r.$el).each(function(t,n){var r=e(n),i=r.data("tooltipster-ns");e.each(i,function(e,t){var n=r.data(t),i=n.status(),s=n.option("autoClose");if(i!=="hidden"&&i!=="disappearing"&&s){n.hide()}})})}var i=function(){r.Status="shown";e.each(r.callbacks.show,function(e,t){t.call(r.$el)});r.callbacks.show=[]};if(r.Status!=="hidden"){var s=0;if(r.Status==="disappearing"){r.Status="appearing";if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-dying").addClass("tooltipster-"+r.options.animation+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.stop().fadeIn(i)}}else if(r.Status==="shown"){i()}}else{r.Status="appearing";var s=r.options.speed;r.bodyOverflowX=e("body").css("overflow-x");e("body").css("overflow-x","hidden");var o="tooltipster-"+r.options.animation,a="-webkit-transition-duration: "+r.options.speed+"ms; -webkit-animation-duration: "+r.options.speed+"ms; -moz-transition-duration: "+r.options.speed+"ms; -moz-animation-duration: "+r.options.speed+"ms; -o-transition-duration: "+r.options.speed+"ms; -o-animation-duration: "+r.options.speed+"ms; -ms-transition-duration: "+r.options.speed+"ms; -ms-animation-duration: "+r.options.speed+"ms; transition-duration: "+r.options.speed+"ms; animation-duration: "+r.options.speed+"ms;",f=r.options.minWidth?"min-width:"+Math.round(r.options.minWidth)+"px;":"",c=r.options.maxWidth?"max-width:"+Math.round(r.options.maxWidth)+"px;":"",h=r.options.interactive?"pointer-events: auto;":"";r.$tooltip=e('<div class="tooltipster-base '+r.options.theme+'" style="'+f+" "+c+" "+h+" "+a+'"><div class="tooltipster-content"></div></div>');if(l())r.$tooltip.addClass(o);r._content_insert();r.$tooltip.appendTo("body");r.reposition();r.options.functionReady.call(r.$el,r.$el,r.$tooltip);if(l()){r.$tooltip.addClass(o+"-show");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(i)}else{r.$tooltip.css("display","none").fadeIn(r.options.speed,i)}r._interval_set();e(t).on("scroll."+r.namespace+" resize."+r.namespace,function(){r.reposition()});if(r.options.autoClose){e("body").off("."+r.namespace);if(r.options.trigger=="hover"){if(u){setTimeout(function(){e("body").on("touchstart."+r.namespace,function(){r.hide()})},0)}if(r.options.interactive){if(u){r.$tooltip.on("touchstart."+r.namespace,function(e){e.stopPropagation()})}var p=null;r.$elProxy.add(r.$tooltip).on("mouseleave."+r.namespace+"-autoClose",function(){clearTimeout(p);p=setTimeout(function(){r.hide()},r.options.interactiveTolerance)}).on("mouseenter."+r.namespace+"-autoClose",function(){clearTimeout(p)})}else{r.$elProxy.on("mouseleave."+r.namespace+"-autoClose",function(){r.hide()})}if(r.options.hideOnClick){r.$elProxy.on("click."+r.namespace+"-autoClose",function(){r.hide()})}}else if(r.options.trigger=="click"){setTimeout(function(){e("body").on("click."+r.namespace+" touchstart."+r.namespace,function(){r.hide()})},0);if(r.options.interactive){r.$tooltip.on("click."+r.namespace+" touchstart."+r.namespace,function(e){e.stopPropagation()})}}}}if(r.options.timer>0){r.timerHide=setTimeout(function(){r.timerHide=null;r.hide()},r.options.timer+s)}}})},_interval_set:function(){var t=this;t.checkInterval=setInterval(function(){if(e("body").find(t.$el).length===0||e("body").find(t.$elProxy).length===0||t.Status=="hidden"||e("body").find(t.$tooltip).length===0){if(t.Status=="shown"||t.Status=="appearing")t.hide();t._interval_cancel()}else{if(t.options.positionTracker){var n=t._repositionInfo(t.$elProxy),r=false;if(o(n.dimension,t.elProxyPosition.dimension)){if(t.$elProxy.css("position")==="fixed"){if(o(n.position,t.elProxyPosition.position))r=true}else{if(o(n.offset,t.elProxyPosition.offset))r=true}}if(!r){t.reposition();t.options.positionTrackerCallback.call(t,t.$el)}}}},200)},_interval_cancel:function(){clearInterval(this.checkInterval);this.checkInterval=null},_content_set:function(e){if(typeof e==="object"&&e!==null&&this.options.contentCloning){e=e.clone(true)}this.Content=e},_content_insert:function(){var e=this,t=this.$tooltip.find(".tooltipster-content");if(typeof e.Content==="string"&&!e.options.contentAsHTML){t.text(e.Content)}else{t.empty().append(e.Content)}},_update:function(e){var t=this;t._content_set(e);if(t.Content!==null){if(t.Status!=="hidden"){t._content_insert();t.reposition();if(t.options.updateAnimation){if(l()){t.$tooltip.css({width:"","-webkit-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-moz-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-o-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms","-ms-transition":"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms",transition:"all "+t.options.speed+"ms, width 0ms, height 0ms, left 0ms, top 0ms"}).addClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!="hidden"){t.$tooltip.removeClass("tooltipster-content-changing");setTimeout(function(){if(t.Status!=="hidden"){t.$tooltip.css({"-webkit-transition":t.options.speed+"ms","-moz-transition":t.options.speed+"ms","-o-transition":t.options.speed+"ms","-ms-transition":t.options.speed+"ms",transition:t.options.speed+"ms"})}},t.options.speed)}},t.options.speed)}else{t.$tooltip.fadeTo(t.options.speed,.5,function(){if(t.Status!="hidden"){t.$tooltip.fadeTo(t.options.speed,1)}})}}}}else{t.hide()}},_repositionInfo:function(e){return{dimension:{height:e.outerHeight(false),width:e.outerWidth(false)},offset:e.offset(),position:{left:parseInt(e.css("left")),top:parseInt(e.css("top"))}}},hide:function(n){var r=this;if(n)r.callbacks.hide.push(n);r.callbacks.show=[];clearTimeout(r.timerShow);r.timerShow=null;clearTimeout(r.timerHide);r.timerHide=null;var i=function(){e.each(r.callbacks.hide,function(e,t){t.call(r.$el)});r.callbacks.hide=[]};if(r.Status=="shown"||r.Status=="appearing"){r.Status="disappearing";var s=function(){r.Status="hidden";if(typeof r.Content=="object"&&r.Content!==null){r.Content.detach()}r.$tooltip.remove();r.$tooltip=null;e(t).off("."+r.namespace);e("body").off("."+r.namespace).css("overflow-x",r.bodyOverflowX);e("body").off("."+r.namespace);r.$elProxy.off("."+r.namespace+"-autoClose");r.options.functionAfter.call(r.$el,r.$el);i()};if(l()){r.$tooltip.clearQueue().removeClass("tooltipster-"+r.options.animation+"-show").addClass("tooltipster-dying");if(r.options.speed>0)r.$tooltip.delay(r.options.speed);r.$tooltip.queue(s)}else{r.$tooltip.stop().fadeOut(r.options.speed,s)}}else if(r.Status=="hidden"){i()}return r},show:function(e){this._showNow(e);return this},update:function(e){return this.content(e)},content:function(e){if(typeof e==="undefined"){return this.Content}else{this._update(e);return this}},reposition:function(){var n=this;if(e("body").find(n.$tooltip).length!==0){n.$tooltip.css("width","");n.elProxyPosition=n._repositionInfo(n.$elProxy);var r=null,i=e(t).width(),s=n.elProxyPosition,o=n.$tooltip.outerWidth(false),u=n.$tooltip.innerWidth()+1,a=n.$tooltip.outerHeight(false);if(n.$elProxy.is("area")){var f=n.$elProxy.attr("shape"),l=n.$elProxy.parent().attr("name"),c=e('img[usemap="#'+l+'"]'),h=c.offset().left,p=c.offset().top,d=n.$elProxy.attr("coords")!==undefined?n.$elProxy.attr("coords").split(","):undefined;if(f=="circle"){var v=parseInt(d[0]),m=parseInt(d[1]),g=parseInt(d[2]);s.dimension.height=g*2;s.dimension.width=g*2;s.offset.top=p+m-g;s.offset.left=h+v-g}else if(f=="rect"){var v=parseInt(d[0]),m=parseInt(d[1]),y=parseInt(d[2]),b=parseInt(d[3]);s.dimension.height=b-m;s.dimension.width=y-v;s.offset.top=p+m;s.offset.left=h+v}else if(f=="poly"){var w=[],E=[],S=0,x=0,T=0,N=0,C="even";for(var k=0;k<d.length;k++){var L=parseInt(d[k]);if(C=="even"){if(L>T){T=L;if(k===0){S=T}}if(L<S){S=L}C="odd"}else{if(L>N){N=L;if(k==1){x=N}}if(L<x){x=L}C="even"}}s.dimension.height=N-x;s.dimension.width=T-S;s.offset.top=p+x;s.offset.left=h+S}else{s.dimension.height=c.outerHeight(false);s.dimension.width=c.outerWidth(false);s.offset.top=p;s.offset.left=h}}var A=0,O=0,M=0,_=parseInt(n.options.offsetY),D=parseInt(n.options.offsetX),P=n.options.position;function H(){var n=e(t).scrollLeft();if(A-n<0){r=A-n;A=n}if(A+o-n>i){r=A-(i+n-o);A=i+n-o}}function B(n,r){if(s.offset.top-e(t).scrollTop()-a-_-12<0&&r.indexOf("top")>-1){P=n}if(s.offset.top+s.dimension.height+a+12+_>e(t).scrollTop()+e(t).height()&&r.indexOf("bottom")>-1){P=n;M=s.offset.top-a-_-12}}if(P=="top"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left+D-j/2;M=s.offset.top-a-_-12;H();B("bottom","top")}if(P=="top-left"){A=s.offset.left+D;M=s.offset.top-a-_-12;H();B("bottom-left","top-left")}if(P=="top-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top-a-_-12;H();B("bottom-right","top-right")}if(P=="bottom"){var j=s.offset.left+o-(s.offset.left+s.dimension.width);A=s.offset.left-j/2+D;M=s.offset.top+s.dimension.height+_+12;H();B("top","bottom")}if(P=="bottom-left"){A=s.offset.left+D;M=s.offset.top+s.dimension.height+_+12;H();B("top-left","bottom-left")}if(P=="bottom-right"){A=s.offset.left+s.dimension.width+D-o;M=s.offset.top+s.dimension.height+_+12;H();B("top-right","bottom-right")}if(P=="left"){A=s.offset.left-D-o-12;O=s.offset.left+D+s.dimension.width+12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A<0&&O+o>i){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=o+A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);A=s.offset.left-D-q-12-I;F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A<0){A=s.offset.left+D+s.dimension.width+12;r="left"}}if(P=="right"){A=s.offset.left+D+s.dimension.width+12;O=s.offset.left-D-o-12;var F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_;if(A+o>i&&O<0){var I=parseFloat(n.$tooltip.css("border-width"))*2,q=i-A-I;n.$tooltip.css("width",q+"px");a=n.$tooltip.outerHeight(false);F=s.offset.top+a-(s.offset.top+s.dimension.height);M=s.offset.top-F/2-_}else if(A+o>i){A=s.offset.left-D-o-12;r="right"}}if(n.options.arrow){var R="tooltipster-arrow-"+P;if(n.options.arrowColor.length<1){var U=n.$tooltip.css("background-color")}else{var U=n.options.arrowColor}if(!r){r=""}else if(r=="left"){R="tooltipster-arrow-right";r=""}else if(r=="right"){R="tooltipster-arrow-left";r=""}else{r="left:"+Math.round(r)+"px;"}if(P=="top"||P=="top-left"||P=="top-right"){var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}else if(P=="bottom"||P=="bottom-left"||P=="bottom-right"){var z=parseFloat(n.$tooltip.css("border-top-width")),W=n.$tooltip.css("border-top-color")}else if(P=="left"){var z=parseFloat(n.$tooltip.css("border-right-width")),W=n.$tooltip.css("border-right-color")}else if(P=="right"){var z=parseFloat(n.$tooltip.css("border-left-width")),W=n.$tooltip.css("border-left-color")}else{var z=parseFloat(n.$tooltip.css("border-bottom-width")),W=n.$tooltip.css("border-bottom-color")}if(z>1){z++}var X="";if(z!==0){var V="",J="border-color: "+W+";";if(R.indexOf("bottom")!==-1){V="margin-top: -"+Math.round(z)+"px;"}else if(R.indexOf("top")!==-1){V="margin-bottom: -"+Math.round(z)+"px;"}else if(R.indexOf("left")!==-1){V="margin-right: -"+Math.round(z)+"px;"}else if(R.indexOf("right")!==-1){V="margin-left: -"+Math.round(z)+"px;"}X='<span class="tooltipster-arrow-border" style="'+V+" "+J+';"></span>'}n.$tooltip.find(".tooltipster-arrow").remove();var K='<div class="'+R+' tooltipster-arrow" style="'+r+'">'+X+'<span style="border-color:'+U+';"></span></div>';n.$tooltip.append(K)}n.$tooltip.css({top:Math.round(M)+"px",left:Math.round(A)+"px"})}return n},enable:function(){this.enabled=true;return this},disable:function(){this.hide();this.enabled=false;return this},destroy:function(){var t=this;t.hide();if(t.$el[0]!==t.$elProxy[0]){t.$elProxy.remove()}t.$el.removeData(t.namespace).off("."+t.namespace);var n=t.$el.data("tooltipster-ns");if(n.length===1){var r=null;if(t.options.restoration==="previous"){r=t.$el.data("tooltipster-initialTitle")}else if(t.options.restoration==="current"){r=typeof t.Content==="string"?t.Content:e("<div></div>").append(t.Content).html()}if(r){t.$el.attr("title",r)}t.$el.removeClass("tooltipstered").removeData("tooltipster-ns").removeData("tooltipster-initialTitle")}else{n=e.grep(n,function(e,n){return e!==t.namespace});t.$el.data("tooltipster-ns",n)}return t},elementIcon:function(){return this.$el[0]!==this.$elProxy[0]?this.$elProxy[0]:undefined},elementTooltip:function(){return this.$tooltip?this.$tooltip[0]:undefined},option:function(e,t){if(typeof t=="undefined")return this.options[e];else{this.options[e]=t;return this}},status:function(){return this.Status}};e.fn[r]=function(){var t=arguments;if(this.length===0){if(typeof t[0]==="string"){var n=true;switch(t[0]){case"setDefaults":e.extend(i,t[1]);break;default:n=false;break}if(n)return true;else return this}else{return this}}else{if(typeof t[0]==="string"){var r="#*$~&";this.each(function(){var n=e(this).data("tooltipster-ns"),i=n?e(this).data(n[0]):null;if(i){if(typeof i[t[0]]==="function"){var s=i[t[0]](t[1],t[2])}else{throw new Error('Unknown method .tooltipster("'+t[0]+'")')}if(s!==i){r=s;return false}}else{throw new Error("You called Tooltipster's \""+t[0]+'" method on an uninitialized element')}});return r!=="#*$~&"?r:this}else{var o=[],u=t[0]&&typeof t[0].multiple!=="undefined",a=u&&t[0].multiple||!u&&i.multiple,f=t[0]&&typeof t[0].debug!=="undefined",l=f&&t[0].debug||!f&&i.debug;this.each(function(){var n=false,r=e(this).data("tooltipster-ns"),i=null;if(!r){n=true}else if(a){n=true}else if(l){console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.')}if(n){i=new s(this,t[0]);if(!r)r=[];r.push(i.namespace);e(this).data("tooltipster-ns",r);e(this).data(i.namespace,i)}o.push(i)});if(a)return o;else return this}}};var u=!!("ontouchstart"in t);var a=false;e("body").one("mousemove",function(){a=true})})(jQuery,window,document);
|
admin/js/wp-custom-widget-area-admin.js
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
(function( $ ) {
|
8 |
+
'use strict';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* All of the code for your Dashboard-specific JavaScript source
|
12 |
+
* should reside in this file.
|
13 |
+
*
|
14 |
+
* Note that this assume you're going to use jQuery, so it prepares
|
15 |
+
* the $ function reference to be used within the scope of this
|
16 |
+
* function.
|
17 |
+
*
|
18 |
+
* From here, you're able to define handlers for when the DOM is
|
19 |
+
* ready:
|
20 |
+
*
|
21 |
+
* $(function() {
|
22 |
+
*
|
23 |
+
* });
|
24 |
+
*
|
25 |
+
* Or when the window is loaded:
|
26 |
+
*
|
27 |
+
* $( window ).load(function() {
|
28 |
+
*
|
29 |
+
* });
|
30 |
+
*
|
31 |
+
* ...and so on.
|
32 |
+
*
|
33 |
+
* Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
|
34 |
+
* for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
|
35 |
+
* be doing this, we should try to minimize doing that in our own work.
|
36 |
+
*/
|
37 |
+
$(document).ready(function(){
|
38 |
+
$('#cwa-form').on('submit', function(e){
|
39 |
+
e.preventDefault();
|
40 |
+
|
41 |
+
var flag = validateForm($(this).serializeArray());
|
42 |
+
if(flag){
|
43 |
+
//console.log();
|
44 |
+
var form_array = {};
|
45 |
+
$(this).serializeArray().map(function(item){
|
46 |
+
var vl = [];
|
47 |
+
if(item.value!==null)
|
48 |
+
form_array[item.name] = item.value;
|
49 |
+
|
50 |
+
});
|
51 |
+
//if(checkId(form_array.cwa_id)){
|
52 |
+
$.post(ajaxurl,{'action': 'add_cwa', 'data': form_array}, function(data){
|
53 |
+
console.log(data);
|
54 |
+
reloadCwaTable();
|
55 |
+
showCwaError(data);
|
56 |
+
|
57 |
+
resetForm();
|
58 |
+
});
|
59 |
+
//}
|
60 |
+
}
|
61 |
+
|
62 |
+
});
|
63 |
+
|
64 |
+
$('#cwa-form input[name=cwa_name]').on('change', function(){
|
65 |
+
var widget_id = $('#cwa-form input[name=cwa_id]'),
|
66 |
+
cwaId = $(this).val().replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-').replace(/ /g,"-");
|
67 |
+
|
68 |
+
if(widget_id.val() === ''){
|
69 |
+
widget_id.val(cwaId);
|
70 |
+
checkId(widget_id,cwaId);
|
71 |
+
}
|
72 |
+
|
73 |
+
});
|
74 |
+
$('#cwa-form input[name=cwa_id]').on('change', function(){
|
75 |
+
var self = this;
|
76 |
+
checkId(self, $(self).val());
|
77 |
+
});
|
78 |
+
|
79 |
+
|
80 |
+
$(document).on('click', '.cwa-delete-link', function(e){
|
81 |
+
e.preventDefault();
|
82 |
+
var id = $(this).data('id');
|
83 |
+
|
84 |
+
$.post(ajaxurl,{'action': 'delete_cwa', 'data': {'cwa_id': id}}, function(data){
|
85 |
+
console.log(data);
|
86 |
+
showCwaError(data);
|
87 |
+
|
88 |
+
reloadCwaTable();
|
89 |
+
});
|
90 |
+
});
|
91 |
+
|
92 |
+
$('#cwa-advance-btn').on('click', function(e){
|
93 |
+
e.preventDefault();
|
94 |
+
$('#cwa-form .advanced').toggle('show').toggleClass('hide');
|
95 |
+
//console.log($('#cwa-form .advanced.hide'));
|
96 |
+
if($('#cwa-form .advanced.hide').length===0)
|
97 |
+
$(this).text('Basic');
|
98 |
+
else
|
99 |
+
$(this).text('Advanced');
|
100 |
+
});
|
101 |
+
|
102 |
+
runTooltip();
|
103 |
+
|
104 |
+
});
|
105 |
+
|
106 |
+
function validateForm(arr){
|
107 |
+
window.xt = arr;
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
function checkId(self, cwa_id){
|
111 |
+
$.post(ajaxurl,{'action': 'check_cwa_id', 'data': {'cwa_id': cwa_id}}, function(data){
|
112 |
+
//console.log(data);
|
113 |
+
if(data.code === 0){
|
114 |
+
$(self).next('.cwa-form-message').html("<label class='cwa-warning' style='padding-left: 5px;'>"+data.message+"</label>");
|
115 |
+
}
|
116 |
+
else{
|
117 |
+
$(self).next('.cwa-form-message').html("<label class='cwa-success' style='padding-left: 5px;'>"+data.message+"</label>");
|
118 |
+
}
|
119 |
+
|
120 |
+
console.log(data);
|
121 |
+
});
|
122 |
+
};
|
123 |
+
function reloadCwaTable(){
|
124 |
+
$.post(ajaxurl,{'action': 'reloadTable'}, function(data){
|
125 |
+
|
126 |
+
$('#cwa-table-wrap').html(data);
|
127 |
+
runTooltip();
|
128 |
+
//console.log(data);
|
129 |
+
});
|
130 |
+
}
|
131 |
+
function showCwaError(obj){
|
132 |
+
|
133 |
+
var type = (obj.code === 0)? "cwa-warning" : "cwa-success" ;
|
134 |
+
console.log(obj.code === 0);
|
135 |
+
var message = obj.message;
|
136 |
+
$('.cwa-error').html(message).addClass(type).fadeIn();
|
137 |
+
setTimeout(function(){
|
138 |
+
$('.cwa-error').fadeOut().html("").removeClass(type);
|
139 |
+
}, 5000);
|
140 |
+
}
|
141 |
+
function resetForm(){
|
142 |
+
$('.cwa-form input[type="text"]' ).val('');
|
143 |
+
$('.cwa-form cwa-form-message' ).empty();
|
144 |
+
}
|
145 |
+
function runTooltip(){
|
146 |
+
$('.tooltip').tooltipster({
|
147 |
+
contentAsHTML: true,
|
148 |
+
animation: 'fade',
|
149 |
+
delay: 200,
|
150 |
+
interactive: true,
|
151 |
+
//theme: 'tooltipster-default',
|
152 |
+
trigger: 'click'
|
153 |
+
});
|
154 |
+
}
|
155 |
+
})( jQuery );
|
admin/partials/cwa-admin-display.php
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide a dashboard view for the plugin
|
5 |
+
*
|
6 |
+
* This file is used to markup the public-facing aspects of the plugin.
|
7 |
+
*
|
8 |
+
* @link http://example.com
|
9 |
+
* @since 1.0.3
|
10 |
+
*
|
11 |
+
* @package Custom_Widget_Area
|
12 |
+
* @subpackage Custom_Widget_Area/admin/partials
|
13 |
+
*/
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
class CWA_view
|
18 |
+
{
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
# code...
|
23 |
+
}
|
24 |
+
public function cwa_settings_page(){
|
25 |
+
add_action( 'add_meta_boxes', self::displayView());
|
26 |
+
}
|
27 |
+
public function displayView(){
|
28 |
+
|
29 |
+
|
30 |
+
global $purl;
|
31 |
+
?>
|
32 |
+
|
33 |
+
<div class="wrap">
|
34 |
+
|
35 |
+
<div id="icon-themes" class="icon32"><br /></div>
|
36 |
+
|
37 |
+
<h2><?php _e( 'Custom widget area', 'wp-custom-widget-area' ); ?></h2>
|
38 |
+
|
39 |
+
<div class="welcome-panel custom-wp">
|
40 |
+
<div class="col col-8">
|
41 |
+
<?php
|
42 |
+
self::widgetForm();
|
43 |
+
?>
|
44 |
+
</div>
|
45 |
+
<div class="col col-4">
|
46 |
+
<div class="how-to">
|
47 |
+
<h3>How to use?</h3>
|
48 |
+
<p>
|
49 |
+
<ol class="list">
|
50 |
+
<li>Create a new Widget area.</li>
|
51 |
+
<li>Click on the "get code" link.</li>
|
52 |
+
<li>Copy the code and Paste it in a wordpress theme where you want to display it.</li>
|
53 |
+
</ol>
|
54 |
+
</p>
|
55 |
+
<br/>
|
56 |
+
<h4 style="margin-top: 0;">How to Use it in page or post content?</h4>
|
57 |
+
<p>
|
58 |
+
<ol class="list">
|
59 |
+
<li>Click on the "get shortcode" link form widget area table below.</li>
|
60 |
+
<li>Copy the shortcode and Paste it in a post or page editor in which you want it to display it.</li>
|
61 |
+
</ol>
|
62 |
+
</p>
|
63 |
+
<br/>
|
64 |
+
<h4 style="margin-top: 0;">How to customize widget style?</h4>
|
65 |
+
<p>
|
66 |
+
<ol class="list">
|
67 |
+
<li>Click on the advance link while creating new widget area and add widget class.</li>
|
68 |
+
<li>Add custom css targeting your widget area class. i.e. <br>
|
69 |
+
<code>
|
70 |
+
.mynewwidgetareaclass a{
|
71 |
+
color: red;
|
72 |
+
}
|
73 |
+
</code><br>
|
74 |
+
at the bottom of your style.css
|
75 |
+
where ".mynewwidgetareaclass" is your widget area class.
|
76 |
+
</li>
|
77 |
+
</ol>
|
78 |
+
</p>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
<div class="cwa-error" style="display:none;">
|
86 |
+
|
87 |
+
</div>
|
88 |
+
<div id="cwa-table-wrap">
|
89 |
+
<?php
|
90 |
+
self::widgetTable();
|
91 |
+
?>
|
92 |
+
</div>
|
93 |
+
<?php
|
94 |
+
}
|
95 |
+
public function widgetForm(){
|
96 |
+
?>
|
97 |
+
<form class="cwa-form" method="post" action="" id="cwa-form">
|
98 |
+
<input type="hidden" name="id">
|
99 |
+
<div class="basic">
|
100 |
+
<div class="cwa-form-row">
|
101 |
+
<label class="cwa-form-label">Name </label><input type="text" name="cwa_name" placeholder="Widget area name" required> <span class="cwa-form-message"></span>
|
102 |
+
</div>
|
103 |
+
<div class="cwa-form-row">
|
104 |
+
<label class="cwa-form-label">Id </label><input type="text" name="cwa_id" placeholder="Widget area id" required><span class="cwa-form-message"></span>
|
105 |
+
</div>
|
106 |
+
<div class="cwa-form-row">
|
107 |
+
<label class="cwa-form-label">Description</label><input type="text" name="cwa_description" placeholder="Description"><span class="cwa-form-message"></span>
|
108 |
+
</div>
|
109 |
+
|
110 |
+
</div>
|
111 |
+
<div class="advanced hide">
|
112 |
+
<div class="cwa-form-row">
|
113 |
+
<label class="cwa-form-label">Widget class</label><input type="text" name="cwa_widget_class" placeholder="Class"><span class="cwa-form-message"></span>
|
114 |
+
</div>
|
115 |
+
<div class="cwa-form-row">
|
116 |
+
<label class="cwa-form-label">Before/After widget </label>
|
117 |
+
<select name="cwa_widget_wrapper">
|
118 |
+
<option selected value="li">li</option>
|
119 |
+
<option value="div">div</option>
|
120 |
+
<option value="aside">aside</option>
|
121 |
+
<option value="span">span</option>
|
122 |
+
</select>
|
123 |
+
<span class="cwa-form-message"></span>
|
124 |
+
</div>
|
125 |
+
<div class="cwa-form-row">
|
126 |
+
<label class="cwa-form-label">Widget title class</label><input type="text" name="cwa_widget_header_class" placeholder="Class"><span class="cwa-form-message"></span>
|
127 |
+
</div>
|
128 |
+
<div class="cwa-form-row">
|
129 |
+
<label class="cwa-form-label">Before/After widget title </label>
|
130 |
+
<select name="cwa_widget_header_wrapper">
|
131 |
+
<option value="h1">h1</option>
|
132 |
+
<option selected value="h2">h2</option>
|
133 |
+
<option value="h3">h3</option>
|
134 |
+
<option value="h4">h4</option>
|
135 |
+
<option value="h5">h5</option>
|
136 |
+
<option value="h6">h6</option>
|
137 |
+
</select>
|
138 |
+
<span class="cwa-form-message"></span>
|
139 |
+
</div>
|
140 |
+
|
141 |
+
</div>
|
142 |
+
|
143 |
+
<div class="cwa-form-row">
|
144 |
+
<a href="#" id="cwa-advance-btn">Advanced</a>
|
145 |
+
</div>
|
146 |
+
<div class="cwa-form-row">
|
147 |
+
<label class="cwa-form-label"> </label><input type="submit" name="create" value="Create" class="cwa-btn cwa-btn-primary"> <input type="reset" value="Cancel" name="cancel" class="cwa-btn cwa-btn-danger">
|
148 |
+
</div>
|
149 |
+
</form>
|
150 |
+
|
151 |
+
<?php
|
152 |
+
}
|
153 |
+
public function widgetTable(){
|
154 |
+
$data = self::getWidgetData();
|
155 |
+
//var_dump($data);
|
156 |
+
?>
|
157 |
+
<table class="cwa-table">
|
158 |
+
<thead>
|
159 |
+
<tr>
|
160 |
+
<th>Sn</th>
|
161 |
+
<th>Name</th>
|
162 |
+
<th>Id</th>
|
163 |
+
<th>Description</th>
|
164 |
+
<td>Widget class</th>
|
165 |
+
<td>Widget header class</th>
|
166 |
+
<th></th>
|
167 |
+
<th></th>
|
168 |
+
</tr>
|
169 |
+
</thead>
|
170 |
+
<tbody>
|
171 |
+
<?php
|
172 |
+
$count = 1;
|
173 |
+
foreach ($data as $table) {
|
174 |
+
# code...
|
175 |
+
?>
|
176 |
+
<tr>
|
177 |
+
<td><?php echo $count ?></td>
|
178 |
+
<td><?php echo $table->cwa_name; ?></td>
|
179 |
+
<td><?php echo $table->cwa_id; ?></td>
|
180 |
+
<td><?php echo $table->cwa_description; ?></td>
|
181 |
+
<td><?php echo $table->cwa_widget_class; ?></td>
|
182 |
+
<td><?php echo $table->cwa_widget_header_class; ?></td>
|
183 |
+
<td><a href="#get_shortcode" data-id="<?php echo $table->cwa_id; ?>" class="cwa-detail-link tooltip" title="[cwa id='<?php echo $table->cwa_id; ?>']">Get shortcode</a> </td>
|
184 |
+
<td><a href="#get_code" data-id="<?php echo $table->cwa_id; ?>" class="cwa-detail-link tooltip" title="dynamic_sidebar( '<?php echo $table->cwa_id; ?>' );">Get code</a> / <a href="#delete" data-id="<?php echo $table->cwa_id; ?>" class="cwa-delete-link">Delete</a></td>
|
185 |
+
</tr>
|
186 |
+
<?php
|
187 |
+
$count++;
|
188 |
+
}
|
189 |
+
?>
|
190 |
+
</tbody>
|
191 |
+
</table>
|
192 |
+
<?php
|
193 |
+
if(isset($_POST['action']))
|
194 |
+
die();
|
195 |
+
}
|
196 |
+
|
197 |
+
public function getWidgetData(){
|
198 |
+
global $wpdb, $table_name;
|
199 |
+
|
200 |
+
$sql = "SELECT * FROM $table_name";
|
201 |
+
|
202 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
203 |
+
$row = $wpdb->get_results( $sql, 'OBJECT');
|
204 |
+
return $row;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
208 |
+
?>
|
assets/screenshot-1.png
ADDED
Binary file
|
includes/class-custom-widget-area.php
ADDED
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The file that defines the core plugin class
|
5 |
+
*
|
6 |
+
* A class definition that includes attributes and functions used across both the
|
7 |
+
* public-facing side of the site and the dashboard.
|
8 |
+
*
|
9 |
+
* @link http://example.com
|
10 |
+
* @since 1.0.3
|
11 |
+
*
|
12 |
+
* @package Custom_Widget_Area
|
13 |
+
* @subpackage Custom_Widget_Area/includes
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* The core plugin class.
|
18 |
+
*
|
19 |
+
* This is used to define internationalization, dashboard-specific hooks, and
|
20 |
+
* public-facing site hooks.
|
21 |
+
*
|
22 |
+
* Also maintains the unique identifier of this plugin as well as the current
|
23 |
+
* version of the plugin.
|
24 |
+
*
|
25 |
+
* @since 1.0.3
|
26 |
+
* @package Custom_Widget_Area
|
27 |
+
* @subpackage Custom_Widget_Area/includes
|
28 |
+
* @author Your Name <email@example.com>
|
29 |
+
*/
|
30 |
+
class Custom_Widget_Area {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* The loader that's responsible for maintaining and registering all hooks that power
|
34 |
+
* the plugin.
|
35 |
+
*
|
36 |
+
* @since 1.0.3
|
37 |
+
* @access protected
|
38 |
+
* @var Custom_Widget_Area_Loader $loader Maintains and registers all hooks for the plugin.
|
39 |
+
*/
|
40 |
+
protected $loader;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* The unique identifier of this plugin.
|
44 |
+
*
|
45 |
+
* @since 1.0.3
|
46 |
+
* @access protected
|
47 |
+
* @var string $plugin_name The string used to uniquely identify this plugin.
|
48 |
+
*/
|
49 |
+
protected $plugin_name;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The current version of the plugin.
|
53 |
+
*
|
54 |
+
* @since 1.0.3
|
55 |
+
* @access protected
|
56 |
+
* @var string $version The current version of the plugin.
|
57 |
+
*/
|
58 |
+
protected $version;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Define the core functionality of the plugin.
|
62 |
+
*
|
63 |
+
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
64 |
+
* Load the dependencies, define the locale, and set the hooks for the Dashboard and
|
65 |
+
* the public-facing side of the site.
|
66 |
+
*
|
67 |
+
* @since 1.0.3
|
68 |
+
*/
|
69 |
+
public function __construct() {
|
70 |
+
|
71 |
+
$this->plugin_name = 'wp-custom-widget-area';
|
72 |
+
$this->version = '1.0.3';
|
73 |
+
|
74 |
+
$this->load_dependencies();
|
75 |
+
$this->set_locale();
|
76 |
+
$this->define_admin_hooks();
|
77 |
+
$this->register_shortcode();
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Load the required dependencies for this plugin.
|
83 |
+
*
|
84 |
+
* Include the following files that make up the plugin:
|
85 |
+
*
|
86 |
+
* - Custom_Widget_Area_Loader. Orchestrates the hooks of the plugin.
|
87 |
+
* - Custom_Widget_Area_i18n. Defines internationalization functionality.
|
88 |
+
* - Custom_Widget_Area_Admin. Defines all hooks for the dashboard.
|
89 |
+
* - Custom_Widget_Area_Public. Defines all hooks for the public side of the site.
|
90 |
+
*
|
91 |
+
* Create an instance of the loader which will be used to register the hooks
|
92 |
+
* with WordPress.
|
93 |
+
*
|
94 |
+
* @since 1.0.3
|
95 |
+
* @access private
|
96 |
+
*/
|
97 |
+
private function load_dependencies() {
|
98 |
+
|
99 |
+
/**
|
100 |
+
* The class responsible for orchestrating the actions and filters of the
|
101 |
+
* core plugin.
|
102 |
+
*/
|
103 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-custom-widget-area-loader.php';
|
104 |
+
|
105 |
+
/**
|
106 |
+
* The class responsible for defining internationalization functionality
|
107 |
+
* of the plugin.
|
108 |
+
*/
|
109 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-custom-widget-area-i18n.php';
|
110 |
+
|
111 |
+
/**
|
112 |
+
* The class responsible for defining all actions that occur in the Dashboard.
|
113 |
+
*/
|
114 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wp-custom-widget-area-admin.php';
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
$this->loader = new Custom_Widget_Area_Loader();
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Define the locale for this plugin for internationalization.
|
124 |
+
*
|
125 |
+
* Uses the Custom_Widget_Area_i18n class in order to set the domain and to register the hook
|
126 |
+
* with WordPress.
|
127 |
+
*
|
128 |
+
* @since 1.0.3
|
129 |
+
* @access private
|
130 |
+
*/
|
131 |
+
private function set_locale() {
|
132 |
+
|
133 |
+
$plugin_i18n = new Custom_Widget_Area_i18n();
|
134 |
+
$plugin_i18n->set_domain( $this->get_plugin_name() );
|
135 |
+
|
136 |
+
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Register all of the hooks related to the dashboard functionality
|
142 |
+
* of the plugin.
|
143 |
+
*
|
144 |
+
* @since 1.0.3
|
145 |
+
* @access private
|
146 |
+
*/
|
147 |
+
private function define_admin_hooks() {
|
148 |
+
|
149 |
+
$plugin_admin = new Custom_Widget_Area_Admin( $this->get_plugin_name(), $this->get_version() );
|
150 |
+
add_action( 'admin_menu', array($plugin_admin, 'menu_setup'));
|
151 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
|
152 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
private function register_shortcode() {
|
157 |
+
add_shortcode( 'cwa', array($this, 'cwa_short') );
|
158 |
+
//exit;
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
public function cwa_short($attr){
|
163 |
+
//var_dump($attr);
|
164 |
+
ob_start();
|
165 |
+
dynamic_sidebar( $attr['id'] );
|
166 |
+
$output = ob_get_contents();
|
167 |
+
ob_end_clean();
|
168 |
+
return $output;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Run the loader to execute all of the hooks with WordPress.
|
173 |
+
*
|
174 |
+
* @since 1.0.3
|
175 |
+
*/
|
176 |
+
public function run() {
|
177 |
+
$this->loader->run();
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* The name of the plugin used to uniquely identify it within the context of
|
182 |
+
* WordPress and to define internationalization functionality.
|
183 |
+
*
|
184 |
+
* @since 1.0.3
|
185 |
+
* @return string The name of the plugin.
|
186 |
+
*/
|
187 |
+
public function get_plugin_name() {
|
188 |
+
return $this->plugin_name;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* The reference to the class that orchestrates the hooks with the plugin.
|
193 |
+
*
|
194 |
+
* @since 1.0.3
|
195 |
+
* @return Custom_Widget_Area_Loader Orchestrates the hooks of the plugin.
|
196 |
+
*/
|
197 |
+
public function get_loader() {
|
198 |
+
return $this->loader;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Retrieve the version number of the plugin.
|
203 |
+
*
|
204 |
+
* @since 1.0.3
|
205 |
+
* @return string The version number of the plugin.
|
206 |
+
*/
|
207 |
+
public function get_version() {
|
208 |
+
return $this->version;
|
209 |
+
}
|
210 |
+
|
211 |
+
}
|
includes/class-wp-custom-widget-area-activator.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin activation
|
5 |
+
*
|
6 |
+
* @link http://example.com
|
7 |
+
* @since 1.0.3
|
8 |
+
*
|
9 |
+
* @package Custom_Widget_Area
|
10 |
+
* @subpackage Custom_Widget_Area/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Fired during plugin activation.
|
15 |
+
*
|
16 |
+
* This class defines all code necessary to run during the plugin's activation.
|
17 |
+
*
|
18 |
+
* @since 1.0.3
|
19 |
+
* @package Custom_Widget_Area
|
20 |
+
* @subpackage Custom_Widget_Area/includes
|
21 |
+
* @author Your Name <email@example.com>
|
22 |
+
*/
|
23 |
+
class Custom_Widget_Area_Activator {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Short Description. (use period)
|
27 |
+
*
|
28 |
+
* Long Description.
|
29 |
+
*
|
30 |
+
* @since 1.0.3
|
31 |
+
*/
|
32 |
+
public static function activate() {
|
33 |
+
|
34 |
+
self::install_db();
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
private function install_db(){
|
39 |
+
global $wpdb;
|
40 |
+
$kz_db_version = '1.0';
|
41 |
+
$table_name = $wpdb->prefix . 'cwa';
|
42 |
+
$charset_collate = '';
|
43 |
+
|
44 |
+
if ( ! empty( $wpdb->charset ) ) {
|
45 |
+
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( ! empty( $wpdb->collate ) ) {
|
49 |
+
$charset_collate .= " COLLATE {$wpdb->collate}";
|
50 |
+
}
|
51 |
+
|
52 |
+
$sql = "CREATE TABLE $table_name (
|
53 |
+
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
54 |
+
cwa_name tinytext NOT NULL,
|
55 |
+
cwa_description text NOT NULL,
|
56 |
+
cwa_id varchar(100) NOT NULL ,
|
57 |
+
cwa_widget_class text ,
|
58 |
+
cwa_widget_wrapper varchar(25),
|
59 |
+
cwa_widget_header_class text,
|
60 |
+
cwa_widget_header_wrapper varchar(25),
|
61 |
+
last_updated date NOT NULL,
|
62 |
+
UNIQUE KEY id (id)
|
63 |
+
) $charset_collate;";
|
64 |
+
|
65 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
66 |
+
dbDelta( $sql );
|
67 |
+
|
68 |
+
add_option( 'kz_db_version', $kz_db_version );
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
includes/class-wp-custom-widget-area-deactivator.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin deactivation
|
5 |
+
*
|
6 |
+
* @link http://example.com
|
7 |
+
* @since 1.0.3
|
8 |
+
*
|
9 |
+
* @package Custom_Widget_Area
|
10 |
+
* @subpackage Custom_Widget_Area/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Fired during plugin deactivation.
|
15 |
+
*
|
16 |
+
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
+
*
|
18 |
+
* @since 1.0.3
|
19 |
+
* @package Custom_Widget_Area
|
20 |
+
* @subpackage Custom_Widget_Area/includes
|
21 |
+
* @author Your Name <email@example.com>
|
22 |
+
*/
|
23 |
+
class Custom_Widget_Area_Deactivator {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Short Description. (use period)
|
27 |
+
*
|
28 |
+
* Long Description.
|
29 |
+
*
|
30 |
+
* @since 1.0.3
|
31 |
+
*/
|
32 |
+
public static function deactivate() {
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
includes/class-wp-custom-widget-area-i18n.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Define the internationalization functionality
|
5 |
+
*
|
6 |
+
* Loads and defines the internationalization files for this plugin
|
7 |
+
* so that its ready for translation.
|
8 |
+
*
|
9 |
+
* @link http://example.com
|
10 |
+
* @since 1.0.3
|
11 |
+
*
|
12 |
+
* @package Custom_Widget_Area
|
13 |
+
* @subpackage Custom_Widget_Area/includes
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Define the internationalization functionality.
|
18 |
+
*
|
19 |
+
* Loads and defines the internationalization files for this plugin
|
20 |
+
* so that its ready for translation.
|
21 |
+
*
|
22 |
+
* @since 1.0.3
|
23 |
+
* @package Custom_Widget_Area
|
24 |
+
* @subpackage Custom_Widget_Area/includes
|
25 |
+
* @author Your Name <email@example.com>
|
26 |
+
*/
|
27 |
+
class Custom_Widget_Area_i18n {
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The domain specified for this plugin.
|
31 |
+
*
|
32 |
+
* @since 1.0.3
|
33 |
+
* @access private
|
34 |
+
* @var string $domain The domain identifier for this plugin.
|
35 |
+
*/
|
36 |
+
private $domain;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Load the plugin text domain for translation.
|
40 |
+
*
|
41 |
+
* @since 1.0.3
|
42 |
+
*/
|
43 |
+
public function load_plugin_textdomain() {
|
44 |
+
|
45 |
+
load_plugin_textdomain(
|
46 |
+
$this->domain,
|
47 |
+
false,
|
48 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
49 |
+
);
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Set the domain equal to that of the specified domain.
|
55 |
+
*
|
56 |
+
* @since 1.0.3
|
57 |
+
* @param string $domain The domain that represents the locale of this plugin.
|
58 |
+
*/
|
59 |
+
public function set_domain( $domain ) {
|
60 |
+
$this->domain = $domain;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
includes/class-wp-custom-widget-area-loader.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register all actions and filters for the plugin
|
5 |
+
*
|
6 |
+
* @link http://example.com
|
7 |
+
* @since 1.0.3
|
8 |
+
*
|
9 |
+
* @package Custom_Widget_Area
|
10 |
+
* @subpackage Custom_Widget_Area/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Register all actions and filters for the plugin.
|
15 |
+
*
|
16 |
+
* Maintain a list of all hooks that are registered throughout
|
17 |
+
* the plugin, and register them with the WordPress API. Call the
|
18 |
+
* run function to execute the list of actions and filters.
|
19 |
+
*
|
20 |
+
* @package Custom_Widget_Area
|
21 |
+
* @subpackage Custom_Widget_Area/includes
|
22 |
+
* @author Your Name <email@example.com>
|
23 |
+
*/
|
24 |
+
class Custom_Widget_Area_Loader {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The array of actions registered with WordPress.
|
28 |
+
*
|
29 |
+
* @since 1.0.3
|
30 |
+
* @access protected
|
31 |
+
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
32 |
+
*/
|
33 |
+
protected $actions;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The array of filters registered with WordPress.
|
37 |
+
*
|
38 |
+
* @since 1.0.3
|
39 |
+
* @access protected
|
40 |
+
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
41 |
+
*/
|
42 |
+
protected $filters;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initialize the collections used to maintain the actions and filters.
|
46 |
+
*
|
47 |
+
* @since 1.0.3
|
48 |
+
*/
|
49 |
+
public function __construct() {
|
50 |
+
|
51 |
+
$this->actions = array();
|
52 |
+
$this->filters = array();
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add a new action to the collection to be registered with WordPress.
|
58 |
+
*
|
59 |
+
* @since 1.0.3
|
60 |
+
* @var string $hook The name of the WordPress action that is being registered.
|
61 |
+
* @var object $component A reference to the instance of the object on which the action is defined.
|
62 |
+
* @var string $callback The name of the function definition on the $component.
|
63 |
+
* @var int Optional $priority The priority at which the function should be fired.
|
64 |
+
* @var int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
65 |
+
*/
|
66 |
+
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
67 |
+
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add a new filter to the collection to be registered with WordPress.
|
72 |
+
*
|
73 |
+
* @since 1.0.3
|
74 |
+
* @var string $hook The name of the WordPress filter that is being registered.
|
75 |
+
* @var object $component A reference to the instance of the object on which the filter is defined.
|
76 |
+
* @var string $callback The name of the function definition on the $component.
|
77 |
+
* @var int Optional $priority The priority at which the function should be fired.
|
78 |
+
* @var int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
79 |
+
*/
|
80 |
+
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
+
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* A utility function that is used to register the actions and hooks into a single
|
86 |
+
* collection.
|
87 |
+
*
|
88 |
+
* @since 1.0.3
|
89 |
+
* @access private
|
90 |
+
* @var array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
91 |
+
* @var string $hook The name of the WordPress filter that is being registered.
|
92 |
+
* @var object $component A reference to the instance of the object on which the filter is defined.
|
93 |
+
* @var string $callback The name of the function definition on the $component.
|
94 |
+
* @var int Optional $priority The priority at which the function should be fired.
|
95 |
+
* @var int Optional $accepted_args The number of arguments that should be passed to the $callback.
|
96 |
+
* @return type The collection of actions and filters registered with WordPress.
|
97 |
+
*/
|
98 |
+
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
99 |
+
|
100 |
+
$hooks[] = array(
|
101 |
+
'hook' => $hook,
|
102 |
+
'component' => $component,
|
103 |
+
'callback' => $callback,
|
104 |
+
'priority' => $priority,
|
105 |
+
'accepted_args' => $accepted_args
|
106 |
+
);
|
107 |
+
|
108 |
+
return $hooks;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Register the filters and actions with WordPress.
|
114 |
+
*
|
115 |
+
* @since 1.0.3
|
116 |
+
*/
|
117 |
+
public function run() {
|
118 |
+
|
119 |
+
foreach ( $this->filters as $hook ) {
|
120 |
+
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
121 |
+
}
|
122 |
+
|
123 |
+
foreach ( $this->actions as $hook ) {
|
124 |
+
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
includes/config.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*plugin configs*/
|
3 |
+
$kz_db_version = '1.0.3';
|
4 |
+
$table_name = $wpdb->prefix . 'cwa';
|
5 |
+
$charset_collate = '';
|
6 |
+
?>
|
includes/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
languages/plugin-name.pot
ADDED
File without changes
|
uninstall.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired when the plugin is uninstalled.
|
5 |
+
*
|
6 |
+
* When populating this file, consider the following flow
|
7 |
+
* of control:
|
8 |
+
*
|
9 |
+
* - This method should be static
|
10 |
+
* - Check if the $_REQUEST content actually is the plugin name
|
11 |
+
* - Run an admin referrer check to make sure it goes through authentication
|
12 |
+
* - Verify the output of $_GET makes sense
|
13 |
+
* - Repeat with other user roles. Best directly by using the links/query string parameters.
|
14 |
+
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
|
15 |
+
*
|
16 |
+
* This file may be updated more in future version of the Boilerplate; however, this is the
|
17 |
+
* general skeleton and outline for how the file should work.
|
18 |
+
*
|
19 |
+
* For more information, see the following discussion:
|
20 |
+
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
21 |
+
*
|
22 |
+
* @link http://example.com
|
23 |
+
* @since 1.0.3
|
24 |
+
*
|
25 |
+
* @package Custom_Widget_Area
|
26 |
+
*/
|
27 |
+
|
28 |
+
// If uninstall not called from WordPress, then exit.
|
29 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
30 |
+
exit;
|
31 |
+
}
|
wp-custom-widget-area.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The plugin bootstrap file
|
5 |
+
*
|
6 |
+
* This file is read by WordPress to generate the plugin information in the plugin
|
7 |
+
* Dashboard. This file also includes all of the dependencies used by the plugin,
|
8 |
+
* registers the activation and deactivation functions, and defines a function
|
9 |
+
* that starts the plugin.
|
10 |
+
*
|
11 |
+
* @link http://example.com
|
12 |
+
* @since 1.0.3
|
13 |
+
* @package Custom widget area
|
14 |
+
*
|
15 |
+
* @wordpress-plugin
|
16 |
+
* Plugin Name: WP Custom Widget area
|
17 |
+
* Plugin URI: http://kishorkhambu.com.np/plugins/
|
18 |
+
* Description: A wordpress plugin to create custom dynamic widget area.
|
19 |
+
* Version: 1.0.3
|
20 |
+
* Author: Kishor Khambu
|
21 |
+
* Author URI: http://kishorkhambu.com.np
|
22 |
+
* License: GPL-2.0+
|
23 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
24 |
+
* Text Domain: wp-custom-widget-area
|
25 |
+
* Domain Path: /languages
|
26 |
+
*/
|
27 |
+
|
28 |
+
// If this file is called directly, abort.
|
29 |
+
if ( ! defined( 'WPINC' ) ) {
|
30 |
+
die;
|
31 |
+
}
|
32 |
+
$purl = plugin_dir_url( __FILE__ );
|
33 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/config.php';
|
34 |
+
/**
|
35 |
+
* The code that runs during plugin activation.
|
36 |
+
*/
|
37 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-custom-widget-area-activator.php';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* The code that runs during plugin deactivation.
|
41 |
+
*/
|
42 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-custom-widget-area-deactivator.php';
|
43 |
+
|
44 |
+
/** This action is documented in includes/class-wp-custom-widget-area-activator.php */
|
45 |
+
register_activation_hook( __FILE__, array( 'Custom_Widget_Area_Activator', 'activate' ) );
|
46 |
+
|
47 |
+
/** This action is documented in includes/class-wp-custom-widget-area-deactivator.php */
|
48 |
+
register_deactivation_hook( __FILE__, array( 'Custom_Widget_Area_Deactivator', 'deactivate' ) );
|
49 |
+
|
50 |
+
/**
|
51 |
+
* The core plugin class that is used to define internationalization,
|
52 |
+
* dashboard-specific hooks, and public-facing site hooks.
|
53 |
+
*/
|
54 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-custom-widget-area.php';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Begins execution of the plugin.
|
58 |
+
*
|
59 |
+
* Since everything within the plugin is registered via hooks,
|
60 |
+
* then kicking off the plugin from this point in the file does
|
61 |
+
* not affect the page life cycle.
|
62 |
+
*
|
63 |
+
* @since 1.0.3
|
64 |
+
*/
|
65 |
+
function run_plugin_name() {
|
66 |
+
$plugin = new Custom_Widget_Area();
|
67 |
+
$plugin->run();
|
68 |
+
|
69 |
+
}
|
70 |
+
run_plugin_name();
|
71 |
+
|
72 |
+
function cb(){
|
73 |
+
echo "welcome to first metabox showcase";
|
74 |
+
}
|