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

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