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

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