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

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