PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 120213
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v120213
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 / includes / menu-pages / menu-pages.js

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

189 lines 7.0 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://www.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 (function($)
22 {
23 $('div#ws-menu-page-js-c-w').hide /* Hide JavaScript conflict warning. */ ();
24 /**/
25 $(window).resize ( /* Global function. */tb_position /* Thickbox resizer/positioner. */ = function()
26 {
27 var w = ($(window).width () > 720) ? 720 : $(window).width (), h = $(window).height (), admin_bar_h = ($('body.admin-bar').length) ? 28 : 0;
28 $('#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'});
29 $('#TB_ajaxContent').css ({'width': w - 50 + 'px', 'height': h - 75 - admin_bar_h + 'px', 'margin': 0, 'padding': 0});
30 });
31 /**/
32 var $groups = /* Query groups. */ $('div.ws-menu-page-group');
33 $groups.each ( /* Go through each group, one at a time. */function(index)
34 {
35 var $this = $(this), ins = '<ins>+</ins>', $group = $this, title = $.trim ($group.attr ('title'));
36 /**/
37 var $header = $('<div class="ws-menu-page-group-header">' + ins + title + '</div>');
38 /**/
39 $header.css /* Stack them sequentially, top to bottom. */ ({'z-index': 100 - index});
40 /**/
41 $header.insertBefore ($group), $group.hide (), $header.click (function()
42 {
43 var $this = $(this), $ins = $('ins', $this), $group = $this.next ();
44 /**/
45 if ($group.css ('display') === 'none')
46 $this.addClass ('open'), $ins.html ('-'), $group.show ();
47 /**/
48 else /* Else remove open class and hide group. */
49 $this.removeClass ('open'), $ins.html ('+'), $group.hide ();
50 /**/
51 return /* Return. */ false;
52 });
53 /**/
54 if /* These are the buttons for showing/hiding all groups. */ ($groups.length > 1 && index === 0)
55 {
56 $('<div class="ws-menu-page-groups-show">+</div>').insertBefore ($header).click (function()
57 {
58 $('div.ws-menu-page-group-header').each (function()
59 {
60 var $this = $(this), $ins = $('ins', $this), $group = $this.next ();
61 /**/
62 $this.addClass ('open'), $ins.html ('-'), $group.show ();
63 /**/
64 return; /* Return. */
65 });
66 /**/
67 return /* Return. */ false;
68 });
69 /**/
70 $('<div class="ws-menu-page-groups-hide">-</div>').insertBefore ($header).click (function()
71 {
72 $('div.ws-menu-page-group-header').each (function()
73 {
74 var $this = $(this), $ins = $('ins', $this), $group = $this.next ();
75 /**/
76 $this.removeClass ('open'), $ins.html ('+'), $group.hide ();
77 /**/
78 return; /* Return. */
79 });
80 /**/
81 return /* Return. */ false;
82 });
83 }
84 /**/
85 if ($group.attr ('default-state') === 'open')
86 $header.trigger ('click');
87 /**/
88 return; /* Return. */
89 });
90 /**/
91 if /* We only apply these special margins when there are multiple groups. */ ($groups.length > 1)
92 {
93 $('div.ws-menu-page-group-header:first').css ({'margin-right': '140px'});
94 $('div.ws-menu-page-group:first').css ({'margin-right': '145px'});
95 }
96 /**/
97 $('div.ws-menu-page-r-group-header').click (function()
98 {
99 var $this = $(this), $group = $this.next ('div.ws-menu-page-r-group');
100 /**/
101 if ($group.css ('display') === 'none')
102 $('ins', $this).html ('-'), $this.addClass ('open'), $group.show ();
103 /**/
104 else /* Otherwise, we hide this group. */
105 {
106 $('ins', $this).html ('+'), $this.removeClass ('open');
107 $group.hide ();
108 }
109 /**/
110 return /* Return. */ false;
111 });
112 /**/
113 $('div.ws-menu-page-group-header:first, div.ws-menu-page-r-group-header:first').css ({'margin-top': '0'});
114 $('div.ws-menu-page-group > div.ws-menu-page-section:first-child > h3').css ({'margin-top': '0'});
115 $('div.ws-menu-page-readme > div.readme > div.section:last-child').css ({'border-bottom-width': '0'});
116 /**/
117 $('input.ws-menu-page-media-btn').filter ( /* Only those that have a rel attribute. */function()
118 {
119 return /* Must have rel targeting an input id. */ ($(this).attr ('rel')) ? true : false;
120 })/**/
121 .click ( /* Attach click events to media buttons with send_to_editor(). */function()
122 {
123 var $this = /* Record a reference to the media button here. */ $(this);
124 /**/
125 window.send_to_editor = /* Works with Thickbox. */ function(html)
126 {
127 var $inp, $txt, rel = $.trim ($this.attr ('rel'));
128 /**/
129 if /* An input field? */ (rel && ($inp = $('input#' + rel)).length > 0)
130 {
131 var oBg = $inp.css ('background-color'), src = $.trim ($(html).attr ('src'));
132 src = (!src) ? $.trim ($('img', html).attr ('src')) : src;
133 /**/
134 $inp.val (src), $inp.css ({'background-color': '#FFFFCC'}), setTimeout(function()
135 {
136 $inp.css ({'background-color': oBg});
137 }, 2000);
138 /**/
139 tb_remove /* Close. */ ();
140 /**/
141 return; /* Return. */
142 }
143 else if /* Textarea? */ (rel && ($txt = $('textarea#' + rel)).length > 0)
144 {
145 var oBg = $txt.css ('background-color'), src = $.trim ($(html).attr ('src'));
146 src = (!src) ? $.trim ($('img', html).attr ('src')) : src;
147 /**/
148 $txt.val ($.trim ($txt.val ()) + '\n' + src), $txt.css ({'background-color': '#FFFFCC'}), setTimeout(function()
149 {
150 $txt.css ({'background-color': oBg});
151 }, 2000);
152 /**/
153 tb_remove /* Close. */ ();
154 /**/
155 return; /* Return. */
156 }
157 };
158 /**/
159 tb_show('', './media-upload.php?type=image&TB_iframe=true');
160 /**/
161 return /* Return. */ false;
162 });
163 /**/
164 $('form#ws-updates-form').submit (function()
165 {
166 var errors = /* Intialize string of errors. */ '';
167 /**/
168 if (!$.trim ($('input#ws-updates-fname').val ()))
169 errors += 'First Name missing, please try again.\n\n';
170 /**/
171 if (!$.trim ($('input#ws-updates-lname').val ()))
172 errors += 'Last Name missing, please try again.\n\n';
173 /**/
174 if (!$.trim ($('input#ws-updates-email').val ()))
175 errors += 'Email missing, please try again.\n\n';
176 /**/
177 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))
178 errors += 'Invalid email address, please try again.\n\n';
179 /**/
180 if (errors = $.trim (errors))
181 {
182 alert('— Oops, you missed something: —\n\n' + errors);
183 /**/
184 return false;
185 }
186 /**/
187 return true;
188 });
189 });