PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / src / includes / menu-pages / menu-pages.js

menu-pages.js in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260917, at src/includes/menu-pages/menu-pages.js

175 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Core JavaScript routines for administrative menu pages.
3 *
4 * This is the development version of the code.
5 * Which ultimately produces menu-pages.min.js.
6 *
7 * This file is included with all WordPress themes/plugins by WebSharks, Inc.
8 *
9 * Copyright: © 2009-2011
10 * {@link http://websharks-inc.com/ WebSharks, Inc.}
11 * (coded in the USA)
12 *
13 * Released under the terms of the GNU General Public License.
14 * You should have received a copy of the GNU General Public License,
15 * along with this software. In the main directory, see: /licensing/
16 * If not, see: {@link http://www.gnu.org/licenses/}.
17 *
18 * @package WebSharks\Menu Pages
19 * @since x.xx
20 */
21 jQuery(document).ready( // DOM ready handler.
22 function($ /* jQuery passed through this arg. */)
23 {
24 $(window).resize(window.tb_position = function()
25 {
26 var w = ($(window).width() > 720) ? 720 : $(window).width(), h = $(window).height(), admin_bar_h = ($('body.admin-bar').length) ? 28 : 0;
27 $('#TB_window').css({'width': w - 50 + 'px', 'height': h - 45 - admin_bar_h + 'px', 'top': 25 + admin_bar_h + 'px', 'margin-top': 0, 'margin-left': '-' + parseInt(((w - 50) / 2), 10) + 'px'});
28 $('#TB_ajaxContent').css({'width': w - 50 + 'px', 'height': h - 75 - admin_bar_h + 'px', 'margin': 0, 'padding': 0});
29 });
30 var $rs = $('table.ws-menu-page-table td.ws-menu-page-table-r'),
31 $rsToggler = $('> .toggler', $rs), $rsWrapper = $('> .wrapper', $rs);
32
33 var $groups = $('div.ws-menu-page-group'/* Query groups. */);
34 $groups.each(function(index/* Go through each group, one at a time. */)
35 {
36 var $this = $(this), $group = $this,
37 title = $.trim($group.attr('title')),
38 $header = $('<div class="ws-menu-page-group-header">' + title + '</div>');
39
40 $header.css({'z-index': 1}), $header.insertBefore($group),
41 $header.click(function()
42 {
43 var $this = $(this),
44 $group = $this.next();
45
46 if($this.hasClass('open'))
47 $this.add($group).removeClass('open');
48 else $this.add($group).addClass('open');
49
50 return false;
51 });
52 if($groups.length > 1 && index === 0)
53 {
54 $('<div class="ws-menu-page-groups-hide"><i class="fa fa-chevron-up"></i></div>')
55 .insertBefore('div.ws-menu-page-toolbox')
56 .click(function(/* Toggle all closed. */)
57 {
58 $('div.ws-menu-page-group-header')
59 .each(function()
60 {
61 var $this = $(this), $group = $this.next();
62 $this.add($group).removeClass('open');
63 });
64 return false;
65 });
66 $('<div class="ws-menu-page-groups-show"><i class="fa fa-chevron-down"></i></div>')
67 .insertBefore('div.ws-menu-page-toolbox')
68 .click(function(/* Toggle all open. */)
69 {
70 $('div.ws-menu-page-group-header')
71 .each(function()
72 {
73 var $this = $(this), $group = $this.next();
74 $this.add($group).addClass('open');
75 });
76 return false;
77 });
78 }
79 if($group.attr('default-state') === 'open')
80 $header.trigger('click');
81 });
82 //260813 Re-scroll to hash targets after accordion groups have opened.
83 if(location.hash && document.getElementById(location.hash.substring(1)))
84 window.setTimeout(function(){ document.getElementById(location.hash.substring(1)).scrollIntoView(); }, 0);
85 $rsToggler.click(function()
86 {
87 if($rs.hasClass('open'))
88 $rsWrapper.hide(), $rs.removeClass('open');
89 else $rsWrapper.show(), $rs.addClass('open');
90 });
91 if($rsToggler.attr('default-state') === 'open') $rsToggler.click();
92
93 $('div.ws-menu-page-r-group-header')
94 .click(function(/* Toggle groups in sidebar. */)
95 {
96 var $this = $(this),
97 $group = $this.next();
98
99 if($this.hasClass('open'))
100 $this.add($group).removeClass('open');
101 else $this.add($group).addClass('open');
102
103 return false;
104 });
105 $('div.ws-menu-page-group-header:first, div.ws-menu-page-r-group-header:first').css({'margin-top': '0'});
106 $('div.ws-menu-page-group-header:last, div.ws-menu-page-r-group-header:last, div.ws-menu-page-group:last').css({'margin-bottom': '0'});
107
108 $('input.ws-menu-page-media-btn').filter(function(){ return ($(this).attr('rel')) ? true : false; })
109 .click(function()
110 {
111 var $this = $(this);
112
113 window.send_to_editor = function(html)
114 {
115 var $inp, $txt, rel = $.trim($this.attr('rel')), oBg, src;
116
117 if(rel && ($inp = $('input#' + rel)).length > 0)
118 {
119 oBg = $inp.css('background-color'),
120 src = $.trim($(html).attr('src'));
121 src = (!src) ? $.trim($('img', html).attr('src')) : src;
122
123 $inp.val(src),
124 $inp.css({'background-color': '#485230'}),
125 setTimeout(function()
126 {
127 $inp.css({'background-color': oBg});
128 }, 2000);
129 tb_remove();
130 }
131 else if(rel && ($txt = $('textarea#' + rel)).length > 0)
132 {
133 oBg = $txt.css('background-color'),
134 src = $.trim($(html).attr('src'));
135 src = (!src) ? $.trim($('img', html).attr('src')) : src;
136
137 $txt.val($.trim($txt.val()) + '\n' + src),
138 $txt.css({'background-color': '#485230'}),
139 setTimeout(function()
140 {
141 $txt.css({'background-color': oBg});
142 }, 2000);
143 tb_remove();
144 }
145 };
146 tb_show('', './media-upload.php?type=image&TB_iframe=true');
147
148 return false;
149 });
150 $('form#ws-updates-form')
151 .submit(function(/* MailChimp validation. */)
152 {
153 var errors = ''; // Initialize.
154
155 if(!$.trim($('input#ws-updates-fname').val()))
156 errors += 'First Name missing, please try again.\n\n';
157
158 if(!$.trim($('input#ws-updates-lname').val()))
159 errors += 'Last Name missing, please try again.\n\n';
160
161 if(!$.trim($('input#ws-updates-email').val()))
162 errors += 'Email missing, please try again.\n\n';
163
164 else if(!$('input#ws-updates-email').val().match(/^([a-z_~0-9\+\-]+)(((\.?)([a-z_~0-9\+\-]+))*)(@)([a-z0-9]+)(((-*)([a-z0-9]+))*)(((\.)([a-z0-9]+)(((-*)([a-z0-9]+))*))*)(\.)([a-z]{2,6})$/i))
165 errors += 'Invalid email address, please try again.\n\n';
166
167 if(errors = $.trim(errors))
168 {
169 alert('— Oops, you missed something: —\n\n' + errors);
170 return false;
171 }
172 return true;
173 });
174 });
175