updates for the Usermanager
Showing
39 changed files
with
5243 additions
and
0 deletions
| ... | @@ -12,6 +12,14 @@ class Actions { | ... | @@ -12,6 +12,14 @@ class Actions { |
| 12 | public static function admin_print_styles() { | 12 | public static function admin_print_styles() { |
| 13 | _enqueue_style('branding-style', Tools\url('css/tenzing.css', __FILE__)); | 13 | _enqueue_style('branding-style', Tools\url('css/tenzing.css', __FILE__)); |
| 14 | } | 14 | } |
| 15 | |||
| 16 | public static function admin_print_scripts() { | ||
| 17 | _enqueue_script('jquery-alerts', Tools\url('jquery_alerts/jquery.alerts.js', __FILE__), Array('jquery'), '1.1'); | ||
| 18 | _enqueue_script('colorbox', Tools\url('scripts/jquery.colorbox.js', __FILE__), Array('jquery')); | ||
| 19 | |||
| 20 | _enqueue_script('date', Tools\url('scripts/date.js', __FILE__)); | ||
| 21 | _enqueue_script('jquery-datepicker', Tools\url('scripts/jquery.datePicker.js', __FILE__), Array('jquery','date')); | ||
| 22 | } | ||
| 15 | 23 | ||
| 16 | public static function admin_head() { | 24 | public static function admin_head() { |
| 17 | 25 | ... | ... |
| ... | @@ -108,7 +108,329 @@ border:none; | ... | @@ -108,7 +108,329 @@ border:none; |
| 108 | .cct-fields div textarea { width: 300px;} | 108 | .cct-fields div textarea { width: 300px;} |
| 109 | .cct-fields div textarea { height:80px;} | 109 | .cct-fields div textarea { height:80px;} |
| 110 | 110 | ||
| 111 | table.tabular-data {} | ||
| 112 | table.tabular-data thead td {} | ||
| 113 | table.tabular-data thead th { text-align: left; } | ||
| 114 | table.tabular-data tbody th {} | ||
| 115 | table.tabular-data tbody td {} | ||
| 111 | 116 | ||
| 117 | .spinner { background: transparent url(../images/spinner.gif) left no-repeat;} | ||
| 112 | 118 | ||
| 113 | 119 | ||
| 120 | #popup_container { | ||
| 121 | font-family: Arial, sans-serif; | ||
| 122 | font-size: 12px; | ||
| 123 | min-width: 300px; /* Dialog will be no smaller than this */ | ||
| 124 | max-width: 600px; /* Dialog will wrap after this width */ | ||
| 125 | background: #FFF; | ||
| 126 | border: solid 5px #333; | ||
| 127 | color: #000; | ||
| 128 | -moz-border-radius: 5px; | ||
| 129 | -webkit-border-radius: 5px; | ||
| 130 | border-radius: 5px; | ||
| 131 | } | ||
| 132 | |||
| 133 | #popup_title { | ||
| 134 | color:#f7bd55; | ||
| 135 | font-size: 12px; | ||
| 136 | font-weight: bold; | ||
| 137 | text-align: left; | ||
| 138 | line-height: 1.75em; | ||
| 139 | background: #3b0d32; | ||
| 140 | border: solid 1px #FFF; | ||
| 141 | border-bottom: solid 1px #999; | ||
| 142 | cursor: default; | ||
| 143 | padding: 0em; padding:3px 5px 3px 10px; | ||
| 144 | margin: 0em; | ||
| 145 | } | ||
| 146 | |||
| 147 | #popup_content { | ||
| 148 | background: 16px 16px no-repeat url(../jquery_alerts/images/info.gif); | ||
| 149 | padding: 1em 1.75em; | ||
| 150 | margin: 0em; | ||
| 151 | } | ||
| 152 | |||
| 153 | #popup_content.alert { | ||
| 154 | background-image: url(../jquery_alerts/images/info.gif); | ||
| 155 | } | ||
| 156 | |||
| 157 | #popup_content.confirm { | ||
| 158 | background-image: url(../jquery_alerts/images/important.gif); | ||
| 159 | } | ||
| 160 | |||
| 161 | #popup_content.prompt { | ||
| 162 | background-image: url(../jquery_alerts/images/help.gif); | ||
| 163 | } | ||
| 164 | |||
| 165 | #popup_message { | ||
| 166 | padding-left: 48px; | ||
| 167 | } | ||
| 168 | |||
| 169 | #popup_panel { | ||
| 170 | text-align: center; | ||
| 171 | margin: 1em 0em 0em 1em; | ||
| 172 | } | ||
| 173 | |||
| 174 | #popup_prompt { | ||
| 175 | margin: .5em 0em; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* | ||
| 179 | ColorBox Core Style | ||
| 180 | The following rules are the styles that are consistant between themes. | ||
| 181 | Avoid changing this area to maintain compatability with future versions of ColorBox. | ||
| 182 | */ | ||
| 183 | #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9998; overflow:hidden;} | ||
| 184 | #cboxOverlay{position:fixed; width:100%; height:100%;} | ||
| 185 | #cboxMiddleLeft, #cboxBottomLeft{clear:left;} | ||
| 186 | #cboxContent{position:relative; overflow:hidden;} | ||
| 187 | #cboxLoadedContent{overflow:auto;} | ||
| 188 | #cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0;} | ||
| 189 | #cboxTitle{margin:0;} | ||
| 190 | #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;} | ||
| 191 | #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} | ||
| 192 | |||
| 193 | /* | ||
| 194 | Example user style | ||
| 195 | The following rules are ordered and tabbed in a way that represents the | ||
| 196 | order/nesting of the generated HTML, so that the structure easier to understand. | ||
| 197 | */ | ||
| 198 | #cboxOverlay{ background: #3b0d32; } | ||
| 199 | #colorbox{} | ||
| 200 | #cboxTopLeft{width:21px; height:21px; background:url(../images/controls.png) no-repeat -100px 0;} | ||
| 201 | #cboxTopRight{width:21px; height:21px; background:url(../images/controls.png) no-repeat -129px 0;} | ||
| 202 | #cboxBottomLeft{width:21px; height:21px; background:url(../images/controls.png) no-repeat -100px -29px;} | ||
| 203 | #cboxBottomRight{width:21px; height:21px; background:url(../images/controls.png) no-repeat -129px -29px;} | ||
| 204 | #cboxMiddleLeft{width:21px; background:url(../images/controls.png) left top repeat-y;} | ||
| 205 | #cboxMiddleRight{width:21px; background:url(../images/controls.png) right top repeat-y;} | ||
| 206 | #cboxTopCenter{height:21px; background:url(../images/border.png) 0 0 repeat-x;} | ||
| 207 | #cboxBottomCenter{height:21px; background:url(../images/border.png) 0 -29px repeat-x;} | ||
| 208 | #cboxContent{background:#fff;} | ||
| 209 | #cboxLoadedContent{margin-bottom:28px;} | ||
| 210 | #cboxTitle{position:absolute; bottom:4px; left:0; text-align:center; width:100%; color:#949494;} | ||
| 211 | #cboxCurrent{position:absolute; bottom:4px; left:58px; color:#949494;} | ||
| 212 | #cboxSlideshow{position:absolute; bottom:4px; right:30px; color:#0092ef;} | ||
| 213 | #cboxPrevious{position:absolute; bottom:0; left:0px; background:url(../images/controls.png) no-repeat -75px 0px; width:25px; height:25px; text-indent:-9999px;} | ||
| 214 | #cboxPrevious.hover{background-position:-75px -25px;} | ||
| 215 | #cboxNext{position:absolute; bottom:0; left:27px; background:url(../images/controls.png) no-repeat -50px 0px; width:25px; height:25px; text-indent:-9999px;} | ||
| 216 | #cboxNext.hover{background-position:-50px -25px;} | ||
| 217 | #cboxLoadingOverlay{background:url(../images/loading_background.png) no-repeat center center;} | ||
| 218 | #cboxLoadingGraphic{background:url(../images/loading.gif) no-repeat center center;} | ||
| 219 | #cboxClose{position:absolute; bottom:0; right:0; background:url(../images/controls.png) no-repeat -25px 0px; width:25px; height:25px; text-indent:-9999px;} | ||
| 220 | #cboxClose.hover{background-position:-25px -25px;} | ||
| 221 | |||
| 222 | /* | ||
| 223 | The following fixes png-transparency for IE6. | ||
| 224 | It is also necessary for png-transparency in IE7 & IE8 to avoid 'black halos' with the fade transition | ||
| 225 | |||
| 226 | Since this method does not support CSS background-positioning, it is incompatible with CSS sprites. | ||
| 227 | Colorbox preloads navigation hover classes to account for this. | ||
| 228 | |||
| 229 | !! Important Note: AlphaImageLoader src paths are relative to the HTML document, | ||
| 230 | while regular CSS background images are relative to the CSS document. | ||
| 231 | */ | ||
| 232 | .cboxIE #cboxTopLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderTopLeft.png, sizingMethod='scale');} | ||
| 233 | .cboxIE #cboxTopCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=//images/internet_explorer/borderTopCenter.png, sizingMethod='scale');} | ||
| 234 | .cboxIE #cboxTopRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderTopRight.png, sizingMethod='scale');} | ||
| 235 | .cboxIE #cboxBottomLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderBottomLeft.png, sizingMethod='scale');} | ||
| 236 | .cboxIE #cboxBottomCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderBottomCenter.png, sizingMethod='scale');} | ||
| 237 | .cboxIE #cboxBottomRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderBottomRight.png, sizingMethod='scale');} | ||
| 238 | .cboxIE #cboxMiddleLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderMiddleLeft.png, sizingMethod='scale');} | ||
| 239 | .cboxIE #cboxMiddleRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=../images/internet_explorer/borderMiddleRight.png, sizingMethod='scale');} | ||
| 240 | |||
| 241 | .update-placeholder { padding-left:5px; color:green; } | ||
| 242 | |||
| 243 | |||
| 244 | .validation-errors { | ||
| 245 | background-color: pink; | ||
| 246 | margin-top:5px; | ||
| 247 | border:1px solid #DF1C24; | ||
| 248 | } | ||
| 249 | |||
| 250 | .error-wrap { padding:10px; } | ||
| 251 | .validation-errors h6 { | ||
| 252 | padding:0px; | ||
| 253 | margin: 0px 0px 10px 0px; | ||
| 254 | color:#DF1C24; | ||
| 255 | font-size:11px; | ||
| 256 | text-transform: uppercase; | ||
| 257 | } | ||
| 258 | |||
| 259 | .validation-errors ul { | ||
| 260 | margin:0; | ||
| 261 | padding:0; | ||
| 262 | } | ||
| 263 | .validation-errors ul li { | ||
| 264 | margin: 0px 0px 3px 0px; | ||
| 265 | padding:0px; | ||
| 266 | font-size:11px; | ||
| 267 | background: none; | ||
| 268 | } | ||
| 269 | |||
| 270 | .my-profile-table { margin-top:0px; padding-top:0px;} | ||
| 271 | .my-profile-table tbody th { text-align:left; font-size:11px; font-weight: normal; } | ||
| 272 | .my-profile-edit h4 { border-bottom:1px solid #ccc; margin-bottom:8px; padding-bottom:2px; margin-top:0px; padding-top:0; } | ||
| 273 | |||
| 274 | |||
| 275 | table.jCalendar { | ||
| 276 | border: 1px solid #000; | ||
| 277 | background: #aaa; | ||
| 278 | border-collapse: separate; | ||
| 279 | border-spacing: 2px; | ||
| 280 | } | ||
| 281 | table.jCalendar th { | ||
| 282 | background: #333; | ||
| 283 | color: #fff; | ||
| 284 | font-weight: bold; | ||
| 285 | padding: 3px 5px; | ||
| 286 | font-size:10px; | ||
| 287 | } | ||
| 288 | |||
| 289 | table.jCalendar td { | ||
| 290 | background: #ccc; | ||
| 291 | color: #000; | ||
| 292 | padding: 3px 5px; | ||
| 293 | text-align: center; | ||
| 294 | font-size:10px; | ||
| 295 | } | ||
| 296 | table.jCalendar td.other-month { | ||
| 297 | background: #ddd; | ||
| 298 | color: #aaa; | ||
| 299 | } | ||
| 300 | table.jCalendar td.today { | ||
| 301 | background: #666; | ||
| 302 | color: #fff; | ||
| 303 | } | ||
| 304 | table.jCalendar td.selected { | ||
| 305 | background: #f66; | ||
| 306 | color: #fff; | ||
| 307 | } | ||
| 308 | table.jCalendar td.selected.dp-hover { | ||
| 309 | background: #f33; | ||
| 310 | color: #fff; | ||
| 311 | } | ||
| 312 | table.jCalendar td.dp-hover, | ||
| 313 | table.jCalendar tr.activeWeekHover td { | ||
| 314 | background: #fff; | ||
| 315 | color: #000; | ||
| 316 | font-size:10px; | ||
| 317 | } | ||
| 318 | table.jCalendar tr.selectedWeek td { | ||
| 319 | background: #f66; | ||
| 320 | color: #fff; | ||
| 321 | font-size:10px; | ||
| 322 | } | ||
| 323 | table.jCalendar td.disabled, table.jCalendar td.disabled.dp-hover { | ||
| 324 | background: #bbb; | ||
| 325 | color: #888; | ||
| 326 | } | ||
| 327 | table.jCalendar td.unselectable, | ||
| 328 | table.jCalendar td.unselectable:hover, | ||
| 329 | table.jCalendar td.unselectable.dp-hover { | ||
| 330 | background: #bbb; | ||
| 331 | color: #888; | ||
| 332 | } | ||
| 333 | |||
| 334 | |||
| 335 | /* NOTE - you will probably want to style a.dp-choose-date - see how I did it in demo.css */ | ||
| 336 | /* | ||
| 337 | div.dp-popup { | ||
| 338 | position: relative; | ||
| 339 | background: #ccc; | ||
| 340 | font-size: 10px; | ||
| 341 | font-family: arial, sans-serif; | ||
| 342 | padding: 2px; | ||
| 343 | width: 171px; | ||
| 344 | line-height: 1.2em; | ||
| 345 | } | ||
| 346 | */ | ||
| 347 | div#dp-popup { | ||
| 348 | position: absolute; | ||
| 349 | z-index: 9999; | ||
| 350 | background: #ccc; | ||
| 351 | font-size: 10px; | ||
| 352 | font-family: arial, sans-serif; | ||
| 353 | padding: 2px; | ||
| 354 | width: 176px; | ||
| 355 | line-height: 1.2em; | ||
| 356 | } | ||
| 357 | div.dp-popup h2 { | ||
| 358 | font-size: 12px; | ||
| 359 | text-align: center; | ||
| 360 | margin: 2px 0; | ||
| 361 | padding: 0; | ||
| 362 | } | ||
| 363 | a#dp-close { | ||
| 364 | font-size: 11px; | ||
| 365 | padding: 4px 0; | ||
| 366 | text-align: center; | ||
| 367 | display: block; | ||
| 368 | } | ||
| 369 | a#dp-close:hover { | ||
| 370 | text-decoration: underline; | ||
| 371 | } | ||
| 372 | div.dp-popup a { | ||
| 373 | color: #000; | ||
| 374 | text-decoration: none; | ||
| 375 | padding: 3px 2px 0; | ||
| 376 | } | ||
| 377 | div.dp-popup div.dp-nav-prev { | ||
| 378 | position: absolute; | ||
| 379 | z-index:9999; | ||
| 380 | top: 2px; | ||
| 381 | left: 4px; | ||
| 382 | width: 100px; | ||
| 383 | } | ||
| 384 | div.dp-popup div.dp-nav-prev a { | ||
| 385 | float: left; | ||
| 386 | } | ||
| 387 | /* Opera needs the rules to be this specific otherwise it doesn't change the cursor back to pointer after you have disabled and re-enabled a link */ | ||
| 388 | div.dp-popup div.dp-nav-prev a, div.dp-popup div.dp-nav-next a { | ||
| 389 | cursor: pointer; | ||
| 390 | } | ||
| 391 | div.dp-popup div.dp-nav-prev a.disabled, div.dp-popup div.dp-nav-next a.disabled { | ||
| 392 | cursor: default; | ||
| 393 | } | ||
| 394 | div.dp-popup div.dp-nav-next { | ||
| 395 | position: absolute; | ||
| 396 | top: 2px; | ||
| 397 | right: 4px; | ||
| 398 | width: 100px; | ||
| 399 | } | ||
| 400 | div.dp-popup div.dp-nav-next a { | ||
| 401 | float: right; | ||
| 402 | } | ||
| 403 | div.dp-popup a.disabled { | ||
| 404 | cursor: default; | ||
| 405 | color: #aaa; | ||
| 406 | } | ||
| 407 | div.dp-popup td { | ||
| 408 | cursor: pointer; | ||
| 409 | } | ||
| 410 | div.dp-popup td.disabled { | ||
| 411 | cursor: default; | ||
| 412 | } | ||
| 413 | a.dp-choose-date { | ||
| 414 | float: left; | ||
| 415 | width: 16px; | ||
| 416 | height: 16px; | ||
| 417 | padding: 0; | ||
| 418 | margin: 2px 3px 0; | ||
| 419 | display: block; | ||
| 420 | text-indent: -2000px; | ||
| 421 | overflow: hidden; | ||
| 422 | background: url(../images/calendar.png) no-repeat; | ||
| 423 | } | ||
| 424 | a.dp-choose-date.dp-disabled { | ||
| 425 | background-position: 0 -20px; | ||
| 426 | cursor: default; | ||
| 427 | } | ||
| 428 | /* makes the input field shorter once the date picker code | ||
| 429 | * has run (to allow space for the calendar icon | ||
| 430 | */ | ||
| 431 | input.dp-applied { | ||
| 432 | width: 140px; | ||
| 433 | float: left; | ||
| 434 | } | ||
| 114 | 435 | ||
| 436 | .admin-member-id { font-size:14px; color:#777; } | ... | ... |
com/Branding/images/border.png
0 → 100755
112 Bytes
com/Branding/images/calendar.png
0 → 100644
1.07 KB
com/Branding/images/controls.png
0 → 100755
1.22 KB
111 Bytes
215 Bytes
217 Bytes
108 Bytes
108 Bytes
111 Bytes
216 Bytes
214 Bytes
com/Branding/images/loading.gif
0 → 100755
9.21 KB
com/Branding/images/loading_background.png
0 → 100755
157 Bytes
com/Branding/images/overlay.png
0 → 100755
182 Bytes
com/Branding/images/spinner.gif
0 → 100644
723 Bytes
com/Branding/jquery_alerts/images/help.gif
0 → 100755
1.54 KB
1.46 KB
com/Branding/jquery_alerts/images/info.gif
0 → 100755
1.45 KB
com/Branding/jquery_alerts/images/title.gif
0 → 100755
317 Bytes
com/Branding/jquery_alerts/jquery.alerts.css
0 → 100755
File mode changed
com/Branding/jquery_alerts/jquery.alerts.js
0 → 100755
| 1 | // jQuery Alert Dialogs Plugin | ||
| 2 | // | ||
| 3 | // Version 1.1 | ||
| 4 | // | ||
| 5 | // Cory S.N. LaViska | ||
| 6 | // A Beautiful Site (http://abeautifulsite.net/) | ||
| 7 | // 14 May 2009 | ||
| 8 | // | ||
| 9 | // Visit http://abeautifulsite.net/notebook/87 for more information | ||
| 10 | // | ||
| 11 | // Usage: | ||
| 12 | // jAlert( message, [title, callback] ) | ||
| 13 | // jConfirm( message, [title, callback] ) | ||
| 14 | // jPrompt( message, [value, title, callback] ) | ||
| 15 | // | ||
| 16 | // History: | ||
| 17 | // | ||
| 18 | // 1.00 - Released (29 December 2008) | ||
| 19 | // | ||
| 20 | // 1.01 - Fixed bug where unbinding would destroy all resize events | ||
| 21 | // | ||
| 22 | // License: | ||
| 23 | // | ||
| 24 | // This plugin is dual-licensed under the GNU General Public License and the MIT License and | ||
| 25 | // is copyright 2008 A Beautiful Site, LLC. | ||
| 26 | // | ||
| 27 | (function($) { | ||
| 28 | |||
| 29 | $.alerts = { | ||
| 30 | |||
| 31 | // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time | ||
| 32 | |||
| 33 | verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels | ||
| 34 | horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/ | ||
| 35 | repositionOnResize: true, // re-centers the dialog on window resize | ||
| 36 | overlayOpacity: .01, // transparency level of overlay | ||
| 37 | overlayColor: '#FFF', // base color of overlay | ||
| 38 | draggable: true, // make the dialogs draggable (requires UI Draggables plugin) | ||
| 39 | okButton: ' OK ', // text for the OK button | ||
| 40 | cancelButton: ' Cancel ', // text for the Cancel button | ||
| 41 | dialogClass: null, // if specified, this class will be applied to all dialogs | ||
| 42 | |||
| 43 | // Public methods | ||
| 44 | |||
| 45 | alert: function(message, title, callback) { | ||
| 46 | if( title == null ) title = 'Alert'; | ||
| 47 | $.alerts._show(title, message, null, 'alert', function(result) { | ||
| 48 | if( callback ) callback(result); | ||
| 49 | }); | ||
| 50 | }, | ||
| 51 | |||
| 52 | confirm: function(message, title, callback) { | ||
| 53 | if( title == null ) title = 'Confirm'; | ||
| 54 | $.alerts._show(title, message, null, 'confirm', function(result) { | ||
| 55 | if( callback ) callback(result); | ||
| 56 | }); | ||
| 57 | }, | ||
| 58 | |||
| 59 | prompt: function(message, value, title, callback) { | ||
| 60 | if( title == null ) title = 'Prompt'; | ||
| 61 | $.alerts._show(title, message, value, 'prompt', function(result) { | ||
| 62 | if( callback ) callback(result); | ||
| 63 | }); | ||
| 64 | }, | ||
| 65 | |||
| 66 | // Private methods | ||
| 67 | |||
| 68 | _show: function(title, msg, value, type, callback) { | ||
| 69 | |||
| 70 | $.alerts._hide(); | ||
| 71 | $.alerts._overlay('show'); | ||
| 72 | |||
| 73 | $("BODY").append( | ||
| 74 | '<div id="popup_container">' + | ||
| 75 | '<h1 id="popup_title"></h1>' + | ||
| 76 | '<div id="popup_content">' + | ||
| 77 | '<div id="popup_message"></div>' + | ||
| 78 | '</div>' + | ||
| 79 | '</div>'); | ||
| 80 | |||
| 81 | if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass); | ||
| 82 | |||
| 83 | // IE6 Fix | ||
| 84 | var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; | ||
| 85 | |||
| 86 | $("#popup_container").css({ | ||
| 87 | position: pos, | ||
| 88 | zIndex: 99999, | ||
| 89 | padding: 0, | ||
| 90 | margin: 0 | ||
| 91 | }); | ||
| 92 | |||
| 93 | $("#popup_title").text(title); | ||
| 94 | $("#popup_content").addClass(type); | ||
| 95 | $("#popup_message").text(msg); | ||
| 96 | $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') ); | ||
| 97 | |||
| 98 | $("#popup_container").css({ | ||
| 99 | minWidth: $("#popup_container").outerWidth(), | ||
| 100 | maxWidth: $("#popup_container").outerWidth() | ||
| 101 | }); | ||
| 102 | |||
| 103 | $.alerts._reposition(); | ||
| 104 | $.alerts._maintainPosition(true); | ||
| 105 | |||
| 106 | switch( type ) { | ||
| 107 | case 'alert': | ||
| 108 | $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>'); | ||
| 109 | $("#popup_ok").click( function() { | ||
| 110 | $.alerts._hide(); | ||
| 111 | callback(true); | ||
| 112 | }); | ||
| 113 | $("#popup_ok").focus().keypress( function(e) { | ||
| 114 | if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click'); | ||
| 115 | }); | ||
| 116 | break; | ||
| 117 | case 'confirm': | ||
| 118 | $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); | ||
| 119 | $("#popup_ok").click( function() { | ||
| 120 | $.alerts._hide(); | ||
| 121 | if( callback ) callback(true); | ||
| 122 | }); | ||
| 123 | $("#popup_cancel").click( function() { | ||
| 124 | $.alerts._hide(); | ||
| 125 | if( callback ) callback(false); | ||
| 126 | }); | ||
| 127 | $("#popup_ok").focus(); | ||
| 128 | $("#popup_ok, #popup_cancel").keypress( function(e) { | ||
| 129 | if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); | ||
| 130 | if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); | ||
| 131 | }); | ||
| 132 | break; | ||
| 133 | case 'prompt': | ||
| 134 | $("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); | ||
| 135 | $("#popup_prompt").width( $("#popup_message").width() ); | ||
| 136 | $("#popup_ok").click( function() { | ||
| 137 | var val = $("#popup_prompt").val(); | ||
| 138 | $.alerts._hide(); | ||
| 139 | if( callback ) callback( val ); | ||
| 140 | }); | ||
| 141 | $("#popup_cancel").click( function() { | ||
| 142 | $.alerts._hide(); | ||
| 143 | if( callback ) callback( null ); | ||
| 144 | }); | ||
| 145 | $("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) { | ||
| 146 | if( e.keyCode == 13 ) $("#popup_ok").trigger('click'); | ||
| 147 | if( e.keyCode == 27 ) $("#popup_cancel").trigger('click'); | ||
| 148 | }); | ||
| 149 | if( value ) $("#popup_prompt").val(value); | ||
| 150 | $("#popup_prompt").focus().select(); | ||
| 151 | break; | ||
| 152 | } | ||
| 153 | |||
| 154 | // Make draggable | ||
| 155 | if( $.alerts.draggable ) { | ||
| 156 | try { | ||
| 157 | $("#popup_container").draggable({ handle: $("#popup_title") }); | ||
| 158 | $("#popup_title").css({ cursor: 'move' }); | ||
| 159 | } catch(e) { /* requires jQuery UI draggables */ } | ||
| 160 | } | ||
| 161 | }, | ||
| 162 | |||
| 163 | _hide: function() { | ||
| 164 | $("#popup_container").remove(); | ||
| 165 | $.alerts._overlay('hide'); | ||
| 166 | $.alerts._maintainPosition(false); | ||
| 167 | }, | ||
| 168 | |||
| 169 | _overlay: function(status) { | ||
| 170 | switch( status ) { | ||
| 171 | case 'show': | ||
| 172 | $.alerts._overlay('hide'); | ||
| 173 | $("BODY").append('<div id="popup_overlay"></div>'); | ||
| 174 | $("#popup_overlay").css({ | ||
| 175 | position: 'absolute', | ||
| 176 | zIndex: 99998, | ||
| 177 | top: '0px', | ||
| 178 | left: '0px', | ||
| 179 | width: '100%', | ||
| 180 | height: $(document).height(), | ||
| 181 | background: $.alerts.overlayColor, | ||
| 182 | opacity: $.alerts.overlayOpacity | ||
| 183 | }); | ||
| 184 | break; | ||
| 185 | case 'hide': | ||
| 186 | $("#popup_overlay").remove(); | ||
| 187 | break; | ||
| 188 | } | ||
| 189 | }, | ||
| 190 | |||
| 191 | _reposition: function() { | ||
| 192 | var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset; | ||
| 193 | var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset; | ||
| 194 | if( top < 0 ) top = 0; | ||
| 195 | if( left < 0 ) left = 0; | ||
| 196 | |||
| 197 | // IE6 fix | ||
| 198 | if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop(); | ||
| 199 | |||
| 200 | $("#popup_container").css({ | ||
| 201 | top: top + 'px', | ||
| 202 | left: left + 'px' | ||
| 203 | }); | ||
| 204 | $("#popup_overlay").height( $(document).height() ); | ||
| 205 | }, | ||
| 206 | |||
| 207 | _maintainPosition: function(status) { | ||
| 208 | if( $.alerts.repositionOnResize ) { | ||
| 209 | switch(status) { | ||
| 210 | case true: | ||
| 211 | $(window).bind('resize', $.alerts._reposition); | ||
| 212 | break; | ||
| 213 | case false: | ||
| 214 | $(window).unbind('resize', $.alerts._reposition); | ||
| 215 | break; | ||
| 216 | } | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | } | ||
| 221 | |||
| 222 | // Shortuct functions | ||
| 223 | jAlert = function(message, title, callback) { | ||
| 224 | $.alerts.alert(message, title, callback); | ||
| 225 | } | ||
| 226 | |||
| 227 | jConfirm = function(message, title, callback) { | ||
| 228 | $.alerts.confirm(message, title, callback); | ||
| 229 | }; | ||
| 230 | |||
| 231 | jPrompt = function(message, value, title, callback) { | ||
| 232 | $.alerts.prompt(message, value, title, callback); | ||
| 233 | }; | ||
| 234 | |||
| 235 | })(jQuery); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/Branding/scripts/date.js
0 → 100644
| 1 | /* | ||
| 2 | * Date prototype extensions. Doesn't depend on any | ||
| 3 | * other code. Doens't overwrite existing methods. | ||
| 4 | * | ||
| 5 | * Adds dayNames, abbrDayNames, monthNames and abbrMonthNames static properties and isLeapYear, | ||
| 6 | * isWeekend, isWeekDay, getDaysInMonth, getDayName, getMonthName, getDayOfYear, getWeekOfYear, | ||
| 7 | * setDayOfYear, addYears, addMonths, addDays, addHours, addMinutes, addSeconds methods | ||
| 8 | * | ||
| 9 | * Copyright (c) 2006 Jörn Zaefferer and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) | ||
| 10 | * | ||
| 11 | * Additional methods and properties added by Kelvin Luck: firstDayOfWeek, dateFormat, zeroTime, asString, fromString - | ||
| 12 | * I've added my name to these methods so you know who to blame if they are broken! | ||
| 13 | * | ||
| 14 | * Dual licensed under the MIT and GPL licenses: | ||
| 15 | * http://www.opensource.org/licenses/mit-license.php | ||
| 16 | * http://www.gnu.org/licenses/gpl.html | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | |||
| 20 | /** | ||
| 21 | * An Array of day names starting with Sunday. | ||
| 22 | * | ||
| 23 | * @example dayNames[0] | ||
| 24 | * @result 'Sunday' | ||
| 25 | * | ||
| 26 | * @name dayNames | ||
| 27 | * @type Array | ||
| 28 | * @cat Plugins/Methods/Date | ||
| 29 | */ | ||
| 30 | Date.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * An Array of abbreviated day names starting with Sun. | ||
| 34 | * | ||
| 35 | * @example abbrDayNames[0] | ||
| 36 | * @result 'Sun' | ||
| 37 | * | ||
| 38 | * @name abbrDayNames | ||
| 39 | * @type Array | ||
| 40 | * @cat Plugins/Methods/Date | ||
| 41 | */ | ||
| 42 | Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; | ||
| 43 | |||
| 44 | /** | ||
| 45 | * An Array of month names starting with Janurary. | ||
| 46 | * | ||
| 47 | * @example monthNames[0] | ||
| 48 | * @result 'January' | ||
| 49 | * | ||
| 50 | * @name monthNames | ||
| 51 | * @type Array | ||
| 52 | * @cat Plugins/Methods/Date | ||
| 53 | */ | ||
| 54 | Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | ||
| 55 | |||
| 56 | /** | ||
| 57 | * An Array of abbreviated month names starting with Jan. | ||
| 58 | * | ||
| 59 | * @example abbrMonthNames[0] | ||
| 60 | * @result 'Jan' | ||
| 61 | * | ||
| 62 | * @name monthNames | ||
| 63 | * @type Array | ||
| 64 | * @cat Plugins/Methods/Date | ||
| 65 | */ | ||
| 66 | Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; | ||
| 67 | |||
| 68 | /** | ||
| 69 | * The first day of the week for this locale. | ||
| 70 | * | ||
| 71 | * @name firstDayOfWeek | ||
| 72 | * @type Number | ||
| 73 | * @cat Plugins/Methods/Date | ||
| 74 | * @author Kelvin Luck | ||
| 75 | */ | ||
| 76 | Date.firstDayOfWeek = 1; | ||
| 77 | |||
| 78 | /** | ||
| 79 | * The format that string dates should be represented as (e.g. 'dd/mm/yyyy' for UK, 'mm/dd/yyyy' for US, 'yyyy-mm-dd' for Unicode etc). | ||
| 80 | * | ||
| 81 | * @name format | ||
| 82 | * @type String | ||
| 83 | * @cat Plugins/Methods/Date | ||
| 84 | * @author Kelvin Luck | ||
| 85 | */ | ||
| 86 | Date.format = 'dd/mm/yyyy'; | ||
| 87 | //Date.format = 'mm/dd/yyyy'; | ||
| 88 | //Date.format = 'yyyy-mm-dd'; | ||
| 89 | //Date.format = 'dd mmm yy'; | ||
| 90 | |||
| 91 | /** | ||
| 92 | * The first two numbers in the century to be used when decoding a two digit year. Since a two digit year is ambiguous (and date.setYear | ||
| 93 | * only works with numbers < 99 and so doesn't allow you to set years after 2000) we need to use this to disambiguate the two digit year codes. | ||
| 94 | * | ||
| 95 | * @name format | ||
| 96 | * @type String | ||
| 97 | * @cat Plugins/Methods/Date | ||
| 98 | * @author Kelvin Luck | ||
| 99 | */ | ||
| 100 | Date.fullYearStart = '20'; | ||
| 101 | |||
| 102 | (function() { | ||
| 103 | |||
| 104 | /** | ||
| 105 | * Adds a given method under the given name | ||
| 106 | * to the Date prototype if it doesn't | ||
| 107 | * currently exist. | ||
| 108 | * | ||
| 109 | * @private | ||
| 110 | */ | ||
| 111 | function add(name, method) { | ||
| 112 | if( !Date.prototype[name] ) { | ||
| 113 | Date.prototype[name] = method; | ||
| 114 | } | ||
| 115 | }; | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Checks if the year is a leap year. | ||
| 119 | * | ||
| 120 | * @example var dtm = new Date("01/12/2008"); | ||
| 121 | * dtm.isLeapYear(); | ||
| 122 | * @result true | ||
| 123 | * | ||
| 124 | * @name isLeapYear | ||
| 125 | * @type Boolean | ||
| 126 | * @cat Plugins/Methods/Date | ||
| 127 | */ | ||
| 128 | add("isLeapYear", function() { | ||
| 129 | var y = this.getFullYear(); | ||
| 130 | return (y%4==0 && y%100!=0) || y%400==0; | ||
| 131 | }); | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Checks if the day is a weekend day (Sat or Sun). | ||
| 135 | * | ||
| 136 | * @example var dtm = new Date("01/12/2008"); | ||
| 137 | * dtm.isWeekend(); | ||
| 138 | * @result false | ||
| 139 | * | ||
| 140 | * @name isWeekend | ||
| 141 | * @type Boolean | ||
| 142 | * @cat Plugins/Methods/Date | ||
| 143 | */ | ||
| 144 | add("isWeekend", function() { | ||
| 145 | return this.getDay()==0 || this.getDay()==6; | ||
| 146 | }); | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Check if the day is a day of the week (Mon-Fri) | ||
| 150 | * | ||
| 151 | * @example var dtm = new Date("01/12/2008"); | ||
| 152 | * dtm.isWeekDay(); | ||
| 153 | * @result false | ||
| 154 | * | ||
| 155 | * @name isWeekDay | ||
| 156 | * @type Boolean | ||
| 157 | * @cat Plugins/Methods/Date | ||
| 158 | */ | ||
| 159 | add("isWeekDay", function() { | ||
| 160 | return !this.isWeekend(); | ||
| 161 | }); | ||
| 162 | |||
| 163 | /** | ||
| 164 | * Gets the number of days in the month. | ||
| 165 | * | ||
| 166 | * @example var dtm = new Date("01/12/2008"); | ||
| 167 | * dtm.getDaysInMonth(); | ||
| 168 | * @result 31 | ||
| 169 | * | ||
| 170 | * @name getDaysInMonth | ||
| 171 | * @type Number | ||
| 172 | * @cat Plugins/Methods/Date | ||
| 173 | */ | ||
| 174 | add("getDaysInMonth", function() { | ||
| 175 | return [31,(this.isLeapYear() ? 29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()]; | ||
| 176 | }); | ||
| 177 | |||
| 178 | /** | ||
| 179 | * Gets the name of the day. | ||
| 180 | * | ||
| 181 | * @example var dtm = new Date("01/12/2008"); | ||
| 182 | * dtm.getDayName(); | ||
| 183 | * @result 'Saturday' | ||
| 184 | * | ||
| 185 | * @example var dtm = new Date("01/12/2008"); | ||
| 186 | * dtm.getDayName(true); | ||
| 187 | * @result 'Sat' | ||
| 188 | * | ||
| 189 | * @param abbreviated Boolean When set to true the name will be abbreviated. | ||
| 190 | * @name getDayName | ||
| 191 | * @type String | ||
| 192 | * @cat Plugins/Methods/Date | ||
| 193 | */ | ||
| 194 | add("getDayName", function(abbreviated) { | ||
| 195 | return abbreviated ? Date.abbrDayNames[this.getDay()] : Date.dayNames[this.getDay()]; | ||
| 196 | }); | ||
| 197 | |||
| 198 | /** | ||
| 199 | * Gets the name of the month. | ||
| 200 | * | ||
| 201 | * @example var dtm = new Date("01/12/2008"); | ||
| 202 | * dtm.getMonthName(); | ||
| 203 | * @result 'Janurary' | ||
| 204 | * | ||
| 205 | * @example var dtm = new Date("01/12/2008"); | ||
| 206 | * dtm.getMonthName(true); | ||
| 207 | * @result 'Jan' | ||
| 208 | * | ||
| 209 | * @param abbreviated Boolean When set to true the name will be abbreviated. | ||
| 210 | * @name getDayName | ||
| 211 | * @type String | ||
| 212 | * @cat Plugins/Methods/Date | ||
| 213 | */ | ||
| 214 | add("getMonthName", function(abbreviated) { | ||
| 215 | return abbreviated ? Date.abbrMonthNames[this.getMonth()] : Date.monthNames[this.getMonth()]; | ||
| 216 | }); | ||
| 217 | |||
| 218 | /** | ||
| 219 | * Get the number of the day of the year. | ||
| 220 | * | ||
| 221 | * @example var dtm = new Date("01/12/2008"); | ||
| 222 | * dtm.getDayOfYear(); | ||
| 223 | * @result 11 | ||
| 224 | * | ||
| 225 | * @name getDayOfYear | ||
| 226 | * @type Number | ||
| 227 | * @cat Plugins/Methods/Date | ||
| 228 | */ | ||
| 229 | add("getDayOfYear", function() { | ||
| 230 | var tmpdtm = new Date("1/1/" + this.getFullYear()); | ||
| 231 | return Math.floor((this.getTime() - tmpdtm.getTime()) / 86400000); | ||
| 232 | }); | ||
| 233 | |||
| 234 | /** | ||
| 235 | * Get the number of the week of the year. | ||
| 236 | * | ||
| 237 | * @example var dtm = new Date("01/12/2008"); | ||
| 238 | * dtm.getWeekOfYear(); | ||
| 239 | * @result 2 | ||
| 240 | * | ||
| 241 | * @name getWeekOfYear | ||
| 242 | * @type Number | ||
| 243 | * @cat Plugins/Methods/Date | ||
| 244 | */ | ||
| 245 | add("getWeekOfYear", function() { | ||
| 246 | return Math.ceil(this.getDayOfYear() / 7); | ||
| 247 | }); | ||
| 248 | |||
| 249 | /** | ||
| 250 | * Set the day of the year. | ||
| 251 | * | ||
| 252 | * @example var dtm = new Date("01/12/2008"); | ||
| 253 | * dtm.setDayOfYear(1); | ||
| 254 | * dtm.toString(); | ||
| 255 | * @result 'Tue Jan 01 2008 00:00:00' | ||
| 256 | * | ||
| 257 | * @name setDayOfYear | ||
| 258 | * @type Date | ||
| 259 | * @cat Plugins/Methods/Date | ||
| 260 | */ | ||
| 261 | add("setDayOfYear", function(day) { | ||
| 262 | this.setMonth(0); | ||
| 263 | this.setDate(day); | ||
| 264 | return this; | ||
| 265 | }); | ||
| 266 | |||
| 267 | /** | ||
| 268 | * Add a number of years to the date object. | ||
| 269 | * | ||
| 270 | * @example var dtm = new Date("01/12/2008"); | ||
| 271 | * dtm.addYears(1); | ||
| 272 | * dtm.toString(); | ||
| 273 | * @result 'Mon Jan 12 2009 00:00:00' | ||
| 274 | * | ||
| 275 | * @name addYears | ||
| 276 | * @type Date | ||
| 277 | * @cat Plugins/Methods/Date | ||
| 278 | */ | ||
| 279 | add("addYears", function(num) { | ||
| 280 | this.setFullYear(this.getFullYear() + num); | ||
| 281 | return this; | ||
| 282 | }); | ||
| 283 | |||
| 284 | /** | ||
| 285 | * Add a number of months to the date object. | ||
| 286 | * | ||
| 287 | * @example var dtm = new Date("01/12/2008"); | ||
| 288 | * dtm.addMonths(1); | ||
| 289 | * dtm.toString(); | ||
| 290 | * @result 'Tue Feb 12 2008 00:00:00' | ||
| 291 | * | ||
| 292 | * @name addMonths | ||
| 293 | * @type Date | ||
| 294 | * @cat Plugins/Methods/Date | ||
| 295 | */ | ||
| 296 | add("addMonths", function(num) { | ||
| 297 | var tmpdtm = this.getDate(); | ||
| 298 | |||
| 299 | this.setMonth(this.getMonth() + num); | ||
| 300 | |||
| 301 | if (tmpdtm > this.getDate()) | ||
| 302 | this.addDays(-this.getDate()); | ||
| 303 | |||
| 304 | return this; | ||
| 305 | }); | ||
| 306 | |||
| 307 | /** | ||
| 308 | * Add a number of days to the date object. | ||
| 309 | * | ||
| 310 | * @example var dtm = new Date("01/12/2008"); | ||
| 311 | * dtm.addDays(1); | ||
| 312 | * dtm.toString(); | ||
| 313 | * @result 'Sun Jan 13 2008 00:00:00' | ||
| 314 | * | ||
| 315 | * @name addDays | ||
| 316 | * @type Date | ||
| 317 | * @cat Plugins/Methods/Date | ||
| 318 | */ | ||
| 319 | add("addDays", function(num) { | ||
| 320 | //this.setDate(this.getDate() + num); | ||
| 321 | this.setTime(this.getTime() + (num*86400000) ); | ||
| 322 | return this; | ||
| 323 | }); | ||
| 324 | |||
| 325 | /** | ||
| 326 | * Add a number of hours to the date object. | ||
| 327 | * | ||
| 328 | * @example var dtm = new Date("01/12/2008"); | ||
| 329 | * dtm.addHours(24); | ||
| 330 | * dtm.toString(); | ||
| 331 | * @result 'Sun Jan 13 2008 00:00:00' | ||
| 332 | * | ||
| 333 | * @name addHours | ||
| 334 | * @type Date | ||
| 335 | * @cat Plugins/Methods/Date | ||
| 336 | */ | ||
| 337 | add("addHours", function(num) { | ||
| 338 | this.setHours(this.getHours() + num); | ||
| 339 | return this; | ||
| 340 | }); | ||
| 341 | |||
| 342 | /** | ||
| 343 | * Add a number of minutes to the date object. | ||
| 344 | * | ||
| 345 | * @example var dtm = new Date("01/12/2008"); | ||
| 346 | * dtm.addMinutes(60); | ||
| 347 | * dtm.toString(); | ||
| 348 | * @result 'Sat Jan 12 2008 01:00:00' | ||
| 349 | * | ||
| 350 | * @name addMinutes | ||
| 351 | * @type Date | ||
| 352 | * @cat Plugins/Methods/Date | ||
| 353 | */ | ||
| 354 | add("addMinutes", function(num) { | ||
| 355 | this.setMinutes(this.getMinutes() + num); | ||
| 356 | return this; | ||
| 357 | }); | ||
| 358 | |||
| 359 | /** | ||
| 360 | * Add a number of seconds to the date object. | ||
| 361 | * | ||
| 362 | * @example var dtm = new Date("01/12/2008"); | ||
| 363 | * dtm.addSeconds(60); | ||
| 364 | * dtm.toString(); | ||
| 365 | * @result 'Sat Jan 12 2008 00:01:00' | ||
| 366 | * | ||
| 367 | * @name addSeconds | ||
| 368 | * @type Date | ||
| 369 | * @cat Plugins/Methods/Date | ||
| 370 | */ | ||
| 371 | add("addSeconds", function(num) { | ||
| 372 | this.setSeconds(this.getSeconds() + num); | ||
| 373 | return this; | ||
| 374 | }); | ||
| 375 | |||
| 376 | /** | ||
| 377 | * Sets the time component of this Date to zero for cleaner, easier comparison of dates where time is not relevant. | ||
| 378 | * | ||
| 379 | * @example var dtm = new Date(); | ||
| 380 | * dtm.zeroTime(); | ||
| 381 | * dtm.toString(); | ||
| 382 | * @result 'Sat Jan 12 2008 00:01:00' | ||
| 383 | * | ||
| 384 | * @name zeroTime | ||
| 385 | * @type Date | ||
| 386 | * @cat Plugins/Methods/Date | ||
| 387 | * @author Kelvin Luck | ||
| 388 | */ | ||
| 389 | add("zeroTime", function() { | ||
| 390 | this.setMilliseconds(0); | ||
| 391 | this.setSeconds(0); | ||
| 392 | this.setMinutes(0); | ||
| 393 | this.setHours(0); | ||
| 394 | return this; | ||
| 395 | }); | ||
| 396 | |||
| 397 | /** | ||
| 398 | * Returns a string representation of the date object according to Date.format. | ||
| 399 | * (Date.toString may be used in other places so I purposefully didn't overwrite it) | ||
| 400 | * | ||
| 401 | * @example var dtm = new Date("01/12/2008"); | ||
| 402 | * dtm.asString(); | ||
| 403 | * @result '12/01/2008' // (where Date.format == 'dd/mm/yyyy' | ||
| 404 | * | ||
| 405 | * @name asString | ||
| 406 | * @type Date | ||
| 407 | * @cat Plugins/Methods/Date | ||
| 408 | * @author Kelvin Luck | ||
| 409 | */ | ||
| 410 | add("asString", function(format) { | ||
| 411 | var r = format || Date.format; | ||
| 412 | return r | ||
| 413 | .split('yyyy').join(this.getFullYear()) | ||
| 414 | .split('yy').join((this.getFullYear() + '').substring(2)) | ||
| 415 | .split('mmmm').join(this.getMonthName(false)) | ||
| 416 | .split('mmm').join(this.getMonthName(true)) | ||
| 417 | .split('mm').join(_zeroPad(this.getMonth()+1)) | ||
| 418 | .split('dd').join(_zeroPad(this.getDate())) | ||
| 419 | .split('hh').join(_zeroPad(this.getHours())) | ||
| 420 | .split('min').join(_zeroPad(this.getMinutes())) | ||
| 421 | .split('ss').join(_zeroPad(this.getSeconds())); | ||
| 422 | }); | ||
| 423 | |||
| 424 | /** | ||
| 425 | * Returns a new date object created from the passed String according to Date.format or false if the attempt to do this results in an invalid date object | ||
| 426 | * (We can't simple use Date.parse as it's not aware of locale and I chose not to overwrite it incase it's functionality is being relied on elsewhere) | ||
| 427 | * | ||
| 428 | * @example var dtm = Date.fromString("12/01/2008"); | ||
| 429 | * dtm.toString(); | ||
| 430 | * @result 'Sat Jan 12 2008 00:00:00' // (where Date.format == 'dd/mm/yyyy' | ||
| 431 | * | ||
| 432 | * @name fromString | ||
| 433 | * @type Date | ||
| 434 | * @cat Plugins/Methods/Date | ||
| 435 | * @author Kelvin Luck | ||
| 436 | */ | ||
| 437 | Date.fromString = function(s, format) | ||
| 438 | { | ||
| 439 | var f = format || Date.format; | ||
| 440 | var d = new Date('01/01/1977'); | ||
| 441 | |||
| 442 | var mLength = 0; | ||
| 443 | |||
| 444 | var iM = f.indexOf('mmmm'); | ||
| 445 | if (iM > -1) { | ||
| 446 | for (var i=0; i<Date.monthNames.length; i++) { | ||
| 447 | var mStr = s.substr(iM, Date.monthNames[i].length); | ||
| 448 | if (Date.monthNames[i] == mStr) { | ||
| 449 | mLength = Date.monthNames[i].length - 4; | ||
| 450 | break; | ||
| 451 | } | ||
| 452 | } | ||
| 453 | d.setMonth(i); | ||
| 454 | } else { | ||
| 455 | iM = f.indexOf('mmm'); | ||
| 456 | if (iM > -1) { | ||
| 457 | var mStr = s.substr(iM, 3); | ||
| 458 | for (var i=0; i<Date.abbrMonthNames.length; i++) { | ||
| 459 | if (Date.abbrMonthNames[i] == mStr) break; | ||
| 460 | } | ||
| 461 | d.setMonth(i); | ||
| 462 | } else { | ||
| 463 | d.setMonth(Number(s.substr(f.indexOf('mm'), 2)) - 1); | ||
| 464 | } | ||
| 465 | } | ||
| 466 | |||
| 467 | var iY = f.indexOf('yyyy'); | ||
| 468 | |||
| 469 | if (iY > -1) { | ||
| 470 | if (iM < iY) | ||
| 471 | { | ||
| 472 | iY += mLength; | ||
| 473 | } | ||
| 474 | d.setFullYear(Number(s.substr(iY, 4))); | ||
| 475 | } else { | ||
| 476 | if (iM < iY) | ||
| 477 | { | ||
| 478 | iY += mLength; | ||
| 479 | } | ||
| 480 | // TODO - this doesn't work very well - are there any rules for what is meant by a two digit year? | ||
| 481 | d.setFullYear(Number(Date.fullYearStart + s.substr(f.indexOf('yy'), 2))); | ||
| 482 | } | ||
| 483 | var iD = f.indexOf('dd'); | ||
| 484 | if (iM < iD) | ||
| 485 | { | ||
| 486 | iD += mLength; | ||
| 487 | } | ||
| 488 | d.setDate(Number(s.substr(iD, 2))); | ||
| 489 | if (isNaN(d.getTime())) { | ||
| 490 | return false; | ||
| 491 | } | ||
| 492 | return d; | ||
| 493 | }; | ||
| 494 | |||
| 495 | // utility method | ||
| 496 | var _zeroPad = function(num) { | ||
| 497 | var s = '0'+num; | ||
| 498 | return s.substring(s.length-2) | ||
| 499 | //return ('0'+num).substring(-2); // doesn't work on IE :( | ||
| 500 | }; | ||
| 501 | |||
| 502 | })(); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/Branding/scripts/jquery.colorbox.js
0 → 100755
| 1 | // ColorBox v1.3.15 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+ | ||
| 2 | // Copyright (c) 2010 Jack Moore - jack@colorpowered.com | ||
| 3 | // Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php | ||
| 4 | (function ($, window) { | ||
| 5 | |||
| 6 | var | ||
| 7 | // ColorBox Default Settings. | ||
| 8 | // See http://colorpowered.com/colorbox for details. | ||
| 9 | defaults = { | ||
| 10 | transition: "elastic", | ||
| 11 | speed: 300, | ||
| 12 | width: false, | ||
| 13 | initialWidth: "600", | ||
| 14 | innerWidth: false, | ||
| 15 | maxWidth: false, | ||
| 16 | height: false, | ||
| 17 | initialHeight: "450", | ||
| 18 | innerHeight: false, | ||
| 19 | maxHeight: false, | ||
| 20 | scalePhotos: true, | ||
| 21 | scrolling: true, | ||
| 22 | inline: false, | ||
| 23 | html: false, | ||
| 24 | iframe: false, | ||
| 25 | photo: false, | ||
| 26 | href: false, | ||
| 27 | title: false, | ||
| 28 | rel: false, | ||
| 29 | opacity: 0.9, | ||
| 30 | preloading: true, | ||
| 31 | current: "image {current} of {total}", | ||
| 32 | previous: "previous", | ||
| 33 | next: "next", | ||
| 34 | close: "close", | ||
| 35 | open: false, | ||
| 36 | returnFocus: true, | ||
| 37 | loop: true, | ||
| 38 | slideshow: false, | ||
| 39 | slideshowAuto: true, | ||
| 40 | slideshowSpeed: 2500, | ||
| 41 | slideshowStart: "start slideshow", | ||
| 42 | slideshowStop: "stop slideshow", | ||
| 43 | onOpen: false, | ||
| 44 | onLoad: false, | ||
| 45 | onComplete: false, | ||
| 46 | onCleanup: false, | ||
| 47 | onClosed: false, | ||
| 48 | overlayClose: true, | ||
| 49 | escKey: true, | ||
| 50 | arrowKey: true | ||
| 51 | }, | ||
| 52 | |||
| 53 | // Abstracting the HTML and event identifiers for easy rebranding | ||
| 54 | colorbox = 'colorbox', | ||
| 55 | prefix = 'cbox', | ||
| 56 | |||
| 57 | // Events | ||
| 58 | event_open = prefix + '_open', | ||
| 59 | event_load = prefix + '_load', | ||
| 60 | event_complete = prefix + '_complete', | ||
| 61 | event_cleanup = prefix + '_cleanup', | ||
| 62 | event_closed = prefix + '_closed', | ||
| 63 | event_purge = prefix + '_purge', | ||
| 64 | event_loaded = prefix + '_loaded', | ||
| 65 | |||
| 66 | // Special Handling for IE | ||
| 67 | isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome. | ||
| 68 | isIE6 = isIE && $.browser.version < 7, | ||
| 69 | event_ie6 = prefix + '_IE6', | ||
| 70 | |||
| 71 | // Cached jQuery Object Variables | ||
| 72 | $overlay, | ||
| 73 | $box, | ||
| 74 | $wrap, | ||
| 75 | $content, | ||
| 76 | $topBorder, | ||
| 77 | $leftBorder, | ||
| 78 | $rightBorder, | ||
| 79 | $bottomBorder, | ||
| 80 | $related, | ||
| 81 | $window, | ||
| 82 | $loaded, | ||
| 83 | $loadingBay, | ||
| 84 | $loadingOverlay, | ||
| 85 | $title, | ||
| 86 | $current, | ||
| 87 | $slideshow, | ||
| 88 | $next, | ||
| 89 | $prev, | ||
| 90 | $close, | ||
| 91 | |||
| 92 | // Variables for cached values or use across multiple functions | ||
| 93 | interfaceHeight, | ||
| 94 | interfaceWidth, | ||
| 95 | loadedHeight, | ||
| 96 | loadedWidth, | ||
| 97 | element, | ||
| 98 | index, | ||
| 99 | settings, | ||
| 100 | open, | ||
| 101 | active, | ||
| 102 | closing = false, | ||
| 103 | |||
| 104 | publicMethod, | ||
| 105 | boxElement = prefix + 'Element'; | ||
| 106 | |||
| 107 | // **************** | ||
| 108 | // HELPER FUNCTIONS | ||
| 109 | // **************** | ||
| 110 | |||
| 111 | // jQuery object generator to reduce code size | ||
| 112 | function $div(id, css) { | ||
| 113 | id = id ? ' id="' + prefix + id + '"' : ''; | ||
| 114 | css = css ? ' style="' + css + '"' : ''; | ||
| 115 | return $('<div' + id + css + '/>'); | ||
| 116 | } | ||
| 117 | |||
| 118 | // Convert % values to pixels | ||
| 119 | function setSize(size, dimension) { | ||
| 120 | dimension = dimension === 'x' ? $window.width() : $window.height(); | ||
| 121 | return (typeof size === 'string') ? Math.round((/%/.test(size) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size; | ||
| 122 | } | ||
| 123 | |||
| 124 | // Checks an href to see if it is a photo. | ||
| 125 | // There is a force photo option (photo: true) for hrefs that cannot be matched by this regex. | ||
| 126 | function isImage(url) { | ||
| 127 | return settings.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url); | ||
| 128 | } | ||
| 129 | |||
| 130 | // Assigns function results to their respective settings. This allows functions to be used as values. | ||
| 131 | function process(settings) { | ||
| 132 | for (var i in settings) { | ||
| 133 | if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time. | ||
| 134 | settings[i] = settings[i].call(element); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | settings.rel = settings.rel || element.rel || 'nofollow'; | ||
| 138 | settings.href = settings.href || $(element).attr('href'); | ||
| 139 | settings.title = settings.title || element.title; | ||
| 140 | return settings; | ||
| 141 | } | ||
| 142 | |||
| 143 | function trigger(event, callback) { | ||
| 144 | if (callback) { | ||
| 145 | callback.call(element); | ||
| 146 | } | ||
| 147 | $.event.trigger(event); | ||
| 148 | } | ||
| 149 | |||
| 150 | // Slideshow functionality | ||
| 151 | function slideshow() { | ||
| 152 | var | ||
| 153 | timeOut, | ||
| 154 | className = prefix + "Slideshow_", | ||
| 155 | click = "click." + prefix, | ||
| 156 | start, | ||
| 157 | stop, | ||
| 158 | clear; | ||
| 159 | |||
| 160 | if (settings.slideshow && $related[1]) { | ||
| 161 | start = function () { | ||
| 162 | $slideshow | ||
| 163 | .text(settings.slideshowStop) | ||
| 164 | .unbind(click) | ||
| 165 | .bind(event_complete, function () { | ||
| 166 | if (index < $related.length - 1 || settings.loop) { | ||
| 167 | timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed); | ||
| 168 | } | ||
| 169 | }) | ||
| 170 | .bind(event_load, function () { | ||
| 171 | clearTimeout(timeOut); | ||
| 172 | }) | ||
| 173 | .one(click + ' ' + event_cleanup, stop); | ||
| 174 | $box.removeClass(className + "off").addClass(className + "on"); | ||
| 175 | timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed); | ||
| 176 | }; | ||
| 177 | |||
| 178 | stop = function () { | ||
| 179 | clearTimeout(timeOut); | ||
| 180 | $slideshow | ||
| 181 | .text(settings.slideshowStart) | ||
| 182 | .unbind([event_complete, event_load, event_cleanup, click].join(' ')) | ||
| 183 | .one(click, start); | ||
| 184 | $box.removeClass(className + "on").addClass(className + "off"); | ||
| 185 | }; | ||
| 186 | |||
| 187 | if (settings.slideshowAuto) { | ||
| 188 | start(); | ||
| 189 | } else { | ||
| 190 | stop(); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | function launch(elem) { | ||
| 196 | if (!closing) { | ||
| 197 | |||
| 198 | element = elem; | ||
| 199 | |||
| 200 | settings = process($.extend({}, $.data(element, colorbox))); | ||
| 201 | |||
| 202 | $related = $(element); | ||
| 203 | |||
| 204 | index = 0; | ||
| 205 | |||
| 206 | if (settings.rel !== 'nofollow') { | ||
| 207 | $related = $('.' + boxElement).filter(function () { | ||
| 208 | var relRelated = $.data(this, colorbox).rel || this.rel; | ||
| 209 | return (relRelated === settings.rel); | ||
| 210 | }); | ||
| 211 | index = $related.index(element); | ||
| 212 | |||
| 213 | // Check direct calls to ColorBox. | ||
| 214 | if (index === -1) { | ||
| 215 | $related = $related.add(element); | ||
| 216 | index = $related.length - 1; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | if (!open) { | ||
| 221 | open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys. | ||
| 222 | |||
| 223 | $box.show(); | ||
| 224 | |||
| 225 | if (settings.returnFocus) { | ||
| 226 | try { | ||
| 227 | element.blur(); | ||
| 228 | $(element).one(event_closed, function () { | ||
| 229 | try { | ||
| 230 | this.focus(); | ||
| 231 | } catch (e) { | ||
| 232 | // do nothing | ||
| 233 | } | ||
| 234 | }); | ||
| 235 | } catch (e) { | ||
| 236 | // do nothing | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5' | ||
| 241 | $overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show(); | ||
| 242 | |||
| 243 | // Opens inital empty ColorBox prior to content being loaded. | ||
| 244 | settings.w = setSize(settings.initialWidth, 'x'); | ||
| 245 | settings.h = setSize(settings.initialHeight, 'y'); | ||
| 246 | publicMethod.position(0); | ||
| 247 | |||
| 248 | if (isIE6) { | ||
| 249 | $window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () { | ||
| 250 | $overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()}); | ||
| 251 | }).trigger('scroll.' + event_ie6); | ||
| 252 | } | ||
| 253 | |||
| 254 | trigger(event_open, settings.onOpen); | ||
| 255 | |||
| 256 | $current.add($prev).add($next).add($slideshow).add($title).hide(); | ||
| 257 | |||
| 258 | $close.html(settings.close).show(); | ||
| 259 | } | ||
| 260 | |||
| 261 | publicMethod.load(true); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | // **************** | ||
| 266 | // PUBLIC FUNCTIONS | ||
| 267 | // Usage format: $.fn.colorbox.close(); | ||
| 268 | // Usage from within an iframe: parent.$.fn.colorbox.close(); | ||
| 269 | // **************** | ||
| 270 | |||
| 271 | publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) { | ||
| 272 | var $this = this, autoOpen; | ||
| 273 | |||
| 274 | if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit. | ||
| 275 | return $this; | ||
| 276 | } | ||
| 277 | |||
| 278 | options = options || {}; | ||
| 279 | |||
| 280 | if (callback) { | ||
| 281 | options.onComplete = callback; | ||
| 282 | } | ||
| 283 | |||
| 284 | if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox() | ||
| 285 | $this = $('<a/>'); | ||
| 286 | options.open = true; // assume an immediate open | ||
| 287 | } | ||
| 288 | |||
| 289 | $this.each(function () { | ||
| 290 | $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options)); | ||
| 291 | $(this).addClass(boxElement); | ||
| 292 | }); | ||
| 293 | |||
| 294 | autoOpen = options.open; | ||
| 295 | |||
| 296 | if ($.isFunction(autoOpen)) { | ||
| 297 | autoOpen = autoOpen.call($this); | ||
| 298 | } | ||
| 299 | |||
| 300 | if (autoOpen) { | ||
| 301 | launch($this[0]); | ||
| 302 | } | ||
| 303 | |||
| 304 | return $this; | ||
| 305 | }; | ||
| 306 | |||
| 307 | // Initialize ColorBox: store common calculations, preload the interface graphics, append the html. | ||
| 308 | // This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only | ||
| 309 | // having to run once, instead of each time colorbox is opened. | ||
| 310 | publicMethod.init = function () { | ||
| 311 | // Create & Append jQuery Objects | ||
| 312 | $window = $(window); | ||
| 313 | $box = $div().attr({id: colorbox, 'class': isIE ? prefix + 'IE' : ''}); | ||
| 314 | $overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide(); | ||
| 315 | |||
| 316 | $wrap = $div("Wrapper"); | ||
| 317 | $content = $div("Content").append( | ||
| 318 | $loaded = $div("LoadedContent", 'width:0; height:0; overflow:hidden'), | ||
| 319 | $loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")), | ||
| 320 | $title = $div("Title"), | ||
| 321 | $current = $div("Current"), | ||
| 322 | $next = $div("Next"), | ||
| 323 | $prev = $div("Previous"), | ||
| 324 | $slideshow = $div("Slideshow").bind(event_open, slideshow), | ||
| 325 | $close = $div("Close") | ||
| 326 | ); | ||
| 327 | $wrap.append( // The 3x3 Grid that makes up ColorBox | ||
| 328 | $div().append( | ||
| 329 | $div("TopLeft"), | ||
| 330 | $topBorder = $div("TopCenter"), | ||
| 331 | $div("TopRight") | ||
| 332 | ), | ||
| 333 | $div(false, 'clear:left').append( | ||
| 334 | $leftBorder = $div("MiddleLeft"), | ||
| 335 | $content, | ||
| 336 | $rightBorder = $div("MiddleRight") | ||
| 337 | ), | ||
| 338 | $div(false, 'clear:left').append( | ||
| 339 | $div("BottomLeft"), | ||
| 340 | $bottomBorder = $div("BottomCenter"), | ||
| 341 | $div("BottomRight") | ||
| 342 | ) | ||
| 343 | ).children().children().css({'float': 'left'}); | ||
| 344 | |||
| 345 | $loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none'); | ||
| 346 | |||
| 347 | $('body').prepend($overlay, $box.append($wrap, $loadingBay)); | ||
| 348 | |||
| 349 | $content.children() | ||
| 350 | .hover(function () { | ||
| 351 | $(this).addClass('hover'); | ||
| 352 | }, function () { | ||
| 353 | $(this).removeClass('hover'); | ||
| 354 | }).addClass('hover'); | ||
| 355 | |||
| 356 | // Cache values needed for size calculations | ||
| 357 | interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6 | ||
| 358 | interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width(); | ||
| 359 | loadedHeight = $loaded.outerHeight(true); | ||
| 360 | loadedWidth = $loaded.outerWidth(true); | ||
| 361 | |||
| 362 | // Setting padding to remove the need to do size conversions during the animation step. | ||
| 363 | $box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide(); | ||
| 364 | |||
| 365 | // Setup button events. | ||
| 366 | $next.click(publicMethod.next); | ||
| 367 | $prev.click(publicMethod.prev); | ||
| 368 | $close.click(publicMethod.close); | ||
| 369 | |||
| 370 | // Adding the 'hover' class allowed the browser to load the hover-state | ||
| 371 | // background graphics. The class can now can be removed. | ||
| 372 | $content.children().removeClass('hover'); | ||
| 373 | |||
| 374 | $('.' + boxElement).live('click', function (e) { | ||
| 375 | // checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt. | ||
| 376 | if (!((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey)) { | ||
| 377 | e.preventDefault(); | ||
| 378 | launch(this); | ||
| 379 | } | ||
| 380 | }); | ||
| 381 | |||
| 382 | $overlay.click(function () { | ||
| 383 | if (settings.overlayClose) { | ||
| 384 | publicMethod.close(); | ||
| 385 | } | ||
| 386 | }); | ||
| 387 | |||
| 388 | // Set Navigation Key Bindings | ||
| 389 | $(document).bind("keydown", function (e) { | ||
| 390 | if (open && settings.escKey && e.keyCode === 27) { | ||
| 391 | e.preventDefault(); | ||
| 392 | publicMethod.close(); | ||
| 393 | } | ||
| 394 | if (open && settings.arrowKey && !active && $related[1]) { | ||
| 395 | if (e.keyCode === 37 && (index || settings.loop)) { | ||
| 396 | e.preventDefault(); | ||
| 397 | $prev.click(); | ||
| 398 | } else if (e.keyCode === 39 && (index < $related.length - 1 || settings.loop)) { | ||
| 399 | e.preventDefault(); | ||
| 400 | $next.click(); | ||
| 401 | } | ||
| 402 | } | ||
| 403 | }); | ||
| 404 | }; | ||
| 405 | |||
| 406 | publicMethod.remove = function () { | ||
| 407 | $box.add($overlay).remove(); | ||
| 408 | $('.' + boxElement).die('click').removeData(colorbox).removeClass(boxElement); | ||
| 409 | }; | ||
| 410 | |||
| 411 | publicMethod.position = function (speed, loadedCallback) { | ||
| 412 | var | ||
| 413 | animate_speed, | ||
| 414 | // keeps the top and left positions within the browser's viewport. | ||
| 415 | posTop = Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(), | ||
| 416 | posLeft = Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft(); | ||
| 417 | |||
| 418 | // setting the speed to 0 to reduce the delay between same-sized content. | ||
| 419 | animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed; | ||
| 420 | |||
| 421 | // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly, | ||
| 422 | // but it has to be shrank down around the size of div#colorbox when it's done. If not, | ||
| 423 | // it can invoke an obscure IE bug when using iframes. | ||
| 424 | $wrap[0].style.width = $wrap[0].style.height = "9999px"; | ||
| 425 | |||
| 426 | function modalDimensions(that) { | ||
| 427 | // loading overlay height has to be explicitly set for IE6. | ||
| 428 | $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width; | ||
| 429 | $loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height; | ||
| 430 | } | ||
| 431 | |||
| 432 | $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft}, { | ||
| 433 | duration: animate_speed, | ||
| 434 | complete: function () { | ||
| 435 | modalDimensions(this); | ||
| 436 | |||
| 437 | active = false; | ||
| 438 | |||
| 439 | // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation. | ||
| 440 | $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px"; | ||
| 441 | $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px"; | ||
| 442 | |||
| 443 | if (loadedCallback) { | ||
| 444 | loadedCallback(); | ||
| 445 | } | ||
| 446 | }, | ||
| 447 | step: function () { | ||
| 448 | modalDimensions(this); | ||
| 449 | } | ||
| 450 | }); | ||
| 451 | }; | ||
| 452 | |||
| 453 | publicMethod.resize = function (options) { | ||
| 454 | if (open) { | ||
| 455 | options = options || {}; | ||
| 456 | |||
| 457 | if (options.width) { | ||
| 458 | settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth; | ||
| 459 | } | ||
| 460 | if (options.innerWidth) { | ||
| 461 | settings.w = setSize(options.innerWidth, 'x'); | ||
| 462 | } | ||
| 463 | $loaded.css({width: settings.w}); | ||
| 464 | |||
| 465 | if (options.height) { | ||
| 466 | settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight; | ||
| 467 | } | ||
| 468 | if (options.innerHeight) { | ||
| 469 | settings.h = setSize(options.innerHeight, 'y'); | ||
| 470 | } | ||
| 471 | if (!options.innerHeight && !options.height) { | ||
| 472 | var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be. | ||
| 473 | settings.h = $child.height(); | ||
| 474 | $child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation | ||
| 475 | } | ||
| 476 | $loaded.css({height: settings.h}); | ||
| 477 | |||
| 478 | publicMethod.position(settings.transition === "none" ? 0 : settings.speed); | ||
| 479 | } | ||
| 480 | }; | ||
| 481 | |||
| 482 | publicMethod.prep = function (object) { | ||
| 483 | if (!open) { | ||
| 484 | return; | ||
| 485 | } | ||
| 486 | |||
| 487 | var photo, | ||
| 488 | speed = settings.transition === "none" ? 0 : settings.speed; | ||
| 489 | |||
| 490 | $window.unbind('resize.' + prefix); | ||
| 491 | $loaded.remove(); | ||
| 492 | $loaded = $div('LoadedContent').html(object); | ||
| 493 | |||
| 494 | function getWidth() { | ||
| 495 | settings.w = settings.w || $loaded.width(); | ||
| 496 | settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w; | ||
| 497 | return settings.w; | ||
| 498 | } | ||
| 499 | function getHeight() { | ||
| 500 | settings.h = settings.h || $loaded.height(); | ||
| 501 | settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h; | ||
| 502 | return settings.h; | ||
| 503 | } | ||
| 504 | |||
| 505 | $loaded.hide() | ||
| 506 | .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations. | ||
| 507 | .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'}) | ||
| 508 | .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height. | ||
| 509 | .prependTo($content); | ||
| 510 | |||
| 511 | $loadingBay.hide(); | ||
| 512 | |||
| 513 | // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width. | ||
| 514 | $('#' + prefix + 'Photo').css({cssFloat: 'none', marginLeft: 'auto', marginRight: 'auto'}); | ||
| 515 | |||
| 516 | // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay. | ||
| 517 | if (isIE6) { | ||
| 518 | $('select').not($box.find('select')).filter(function () { | ||
| 519 | return this.style.visibility !== 'hidden'; | ||
| 520 | }).css({'visibility': 'hidden'}).one(event_cleanup, function () { | ||
| 521 | this.style.visibility = 'inherit'; | ||
| 522 | }); | ||
| 523 | } | ||
| 524 | |||
| 525 | function setPosition(s) { | ||
| 526 | var prev, prevSrc, next, nextSrc, total = $related.length, loop = settings.loop; | ||
| 527 | publicMethod.position(s, function () { | ||
| 528 | function defilter() { | ||
| 529 | if (isIE) { | ||
| 530 | //IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs. | ||
| 531 | $box[0].style.removeAttribute("filter"); | ||
| 532 | } | ||
| 533 | } | ||
| 534 | |||
| 535 | if (!open) { | ||
| 536 | return; | ||
| 537 | } | ||
| 538 | |||
| 539 | if (isIE) { | ||
| 540 | //This fadeIn helps the bicubic resampling to kick-in. | ||
| 541 | if (photo) { | ||
| 542 | $loaded.fadeIn(100); | ||
| 543 | } | ||
| 544 | } | ||
| 545 | |||
| 546 | $loaded.show(); | ||
| 547 | |||
| 548 | trigger(event_loaded); | ||
| 549 | |||
| 550 | $title.show().html(settings.title); | ||
| 551 | |||
| 552 | if (total > 1) { // handle grouping | ||
| 553 | if (typeof settings.current === "string") { | ||
| 554 | $current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show(); | ||
| 555 | } | ||
| 556 | |||
| 557 | $next[(loop || index < total - 1) ? "show" : "hide"]().html(settings.next); | ||
| 558 | $prev[(loop || index) ? "show" : "hide"]().html(settings.previous); | ||
| 559 | |||
| 560 | prev = index ? $related[index - 1] : $related[total - 1]; | ||
| 561 | next = index < total - 1 ? $related[index + 1] : $related[0]; | ||
| 562 | |||
| 563 | if (settings.slideshow) { | ||
| 564 | $slideshow.show(); | ||
| 565 | } | ||
| 566 | |||
| 567 | // Preloads images within a rel group | ||
| 568 | if (settings.preloading) { | ||
| 569 | nextSrc = $.data(next, colorbox).href || next.href; | ||
| 570 | prevSrc = $.data(prev, colorbox).href || prev.href; | ||
| 571 | |||
| 572 | nextSrc = $.isFunction(nextSrc) ? nextSrc.call(next) : nextSrc; | ||
| 573 | prevSrc = $.isFunction(prevSrc) ? prevSrc.call(prev) : prevSrc; | ||
| 574 | |||
| 575 | if (isImage(nextSrc)) { | ||
| 576 | $('<img/>')[0].src = nextSrc; | ||
| 577 | } | ||
| 578 | |||
| 579 | if (isImage(prevSrc)) { | ||
| 580 | $('<img/>')[0].src = prevSrc; | ||
| 581 | } | ||
| 582 | } | ||
| 583 | } | ||
| 584 | |||
| 585 | $loadingOverlay.hide(); | ||
| 586 | |||
| 587 | if (settings.transition === 'fade') { | ||
| 588 | $box.fadeTo(speed, 1, function () { | ||
| 589 | defilter(); | ||
| 590 | }); | ||
| 591 | } else { | ||
| 592 | defilter(); | ||
| 593 | } | ||
| 594 | |||
| 595 | $window.bind('resize.' + prefix, function () { | ||
| 596 | publicMethod.position(0); | ||
| 597 | }); | ||
| 598 | |||
| 599 | trigger(event_complete, settings.onComplete); | ||
| 600 | }); | ||
| 601 | } | ||
| 602 | |||
| 603 | if (settings.transition === 'fade') { | ||
| 604 | $box.fadeTo(speed, 0, function () { | ||
| 605 | setPosition(0); | ||
| 606 | }); | ||
| 607 | } else { | ||
| 608 | setPosition(speed); | ||
| 609 | } | ||
| 610 | }; | ||
| 611 | |||
| 612 | publicMethod.load = function (launched) { | ||
| 613 | var href, img, setResize, prep = publicMethod.prep; | ||
| 614 | |||
| 615 | active = true; | ||
| 616 | element = $related[index]; | ||
| 617 | |||
| 618 | if (!launched) { | ||
| 619 | settings = process($.extend({}, $.data(element, colorbox))); | ||
| 620 | } | ||
| 621 | |||
| 622 | trigger(event_purge); | ||
| 623 | |||
| 624 | trigger(event_load, settings.onLoad); | ||
| 625 | |||
| 626 | settings.h = settings.height ? | ||
| 627 | setSize(settings.height, 'y') - loadedHeight - interfaceHeight : | ||
| 628 | settings.innerHeight && setSize(settings.innerHeight, 'y'); | ||
| 629 | |||
| 630 | settings.w = settings.width ? | ||
| 631 | setSize(settings.width, 'x') - loadedWidth - interfaceWidth : | ||
| 632 | settings.innerWidth && setSize(settings.innerWidth, 'x'); | ||
| 633 | |||
| 634 | // Sets the minimum dimensions for use in image scaling | ||
| 635 | settings.mw = settings.w; | ||
| 636 | settings.mh = settings.h; | ||
| 637 | |||
| 638 | // Re-evaluate the minimum width and height based on maxWidth and maxHeight values. | ||
| 639 | // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead. | ||
| 640 | if (settings.maxWidth) { | ||
| 641 | settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth; | ||
| 642 | settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw; | ||
| 643 | } | ||
| 644 | if (settings.maxHeight) { | ||
| 645 | settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight; | ||
| 646 | settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh; | ||
| 647 | } | ||
| 648 | |||
| 649 | href = settings.href; | ||
| 650 | |||
| 651 | $loadingOverlay.show(); | ||
| 652 | |||
| 653 | if (settings.inline) { | ||
| 654 | // Inserts an empty placeholder where inline content is being pulled from. | ||
| 655 | // An event is bound to put inline content back when ColorBox closes or loads new content. | ||
| 656 | $div().hide().insertBefore($(href)[0]).one(event_purge, function () { | ||
| 657 | $(this).replaceWith($loaded.children()); | ||
| 658 | }); | ||
| 659 | prep($(href)); | ||
| 660 | } else if (settings.iframe) { | ||
| 661 | // IFrame element won't be added to the DOM until it is ready to be displayed, | ||
| 662 | // to avoid problems with DOM-ready JS that might be trying to run in that iframe. | ||
| 663 | $box.one(event_loaded, function () { | ||
| 664 | var iframe = $("<iframe frameborder='0' style='width:100%; height:100%; border:0; display:block'/>")[0]; | ||
| 665 | iframe.name = prefix + (+new Date()); | ||
| 666 | iframe.src = settings.href; | ||
| 667 | |||
| 668 | if (!settings.scrolling) { | ||
| 669 | iframe.scrolling = "no"; | ||
| 670 | } | ||
| 671 | |||
| 672 | if (isIE) { | ||
| 673 | iframe.allowtransparency = "true"; | ||
| 674 | } | ||
| 675 | |||
| 676 | $(iframe).appendTo($loaded).one(event_purge, function () { | ||
| 677 | iframe.src = "//about:blank"; | ||
| 678 | }); | ||
| 679 | }); | ||
| 680 | |||
| 681 | prep(" "); | ||
| 682 | } else if (settings.html) { | ||
| 683 | prep(settings.html); | ||
| 684 | } else if (isImage(href)) { | ||
| 685 | img = new Image(); | ||
| 686 | img.onload = function () { | ||
| 687 | var percent; | ||
| 688 | img.onload = null; | ||
| 689 | img.id = prefix + 'Photo'; | ||
| 690 | $(img).css({border: 'none', display: 'block', cssFloat: 'left'}); | ||
| 691 | if (settings.scalePhotos) { | ||
| 692 | setResize = function () { | ||
| 693 | img.height -= img.height * percent; | ||
| 694 | img.width -= img.width * percent; | ||
| 695 | }; | ||
| 696 | if (settings.mw && img.width > settings.mw) { | ||
| 697 | percent = (img.width - settings.mw) / img.width; | ||
| 698 | setResize(); | ||
| 699 | } | ||
| 700 | if (settings.mh && img.height > settings.mh) { | ||
| 701 | percent = (img.height - settings.mh) / img.height; | ||
| 702 | setResize(); | ||
| 703 | } | ||
| 704 | } | ||
| 705 | |||
| 706 | if (settings.h) { | ||
| 707 | img.style.marginTop = Math.max(settings.h - img.height, 0) / 2 + 'px'; | ||
| 708 | } | ||
| 709 | |||
| 710 | if ($related[1] && (index < $related.length - 1 || settings.loop)) { | ||
| 711 | $(img).css({cursor: 'pointer'}).click(publicMethod.next); | ||
| 712 | } | ||
| 713 | |||
| 714 | if (isIE) { | ||
| 715 | img.style.msInterpolationMode = 'bicubic'; | ||
| 716 | } | ||
| 717 | |||
| 718 | setTimeout(function () { // Chrome will sometimes report a 0 by 0 size if there isn't pause in execution | ||
| 719 | prep(img); | ||
| 720 | }, 1); | ||
| 721 | }; | ||
| 722 | |||
| 723 | setTimeout(function () { // Opera 10.6+ will sometimes load the src before the onload function is set | ||
| 724 | img.src = href; | ||
| 725 | }, 1); | ||
| 726 | } else if (href) { | ||
| 727 | $loadingBay.load(href, function (data, status, xhr) { | ||
| 728 | prep(status === 'error' ? 'Request unsuccessful: ' + xhr.statusText : $(this).children()); | ||
| 729 | }); | ||
| 730 | } | ||
| 731 | }; | ||
| 732 | |||
| 733 | // Navigates to the next page/image in a set. | ||
| 734 | publicMethod.next = function () { | ||
| 735 | if (!active) { | ||
| 736 | index = index < $related.length - 1 ? index + 1 : 0; | ||
| 737 | publicMethod.load(); | ||
| 738 | } | ||
| 739 | }; | ||
| 740 | |||
| 741 | publicMethod.prev = function () { | ||
| 742 | if (!active) { | ||
| 743 | index = index ? index - 1 : $related.length - 1; | ||
| 744 | publicMethod.load(); | ||
| 745 | } | ||
| 746 | }; | ||
| 747 | |||
| 748 | // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close(); | ||
| 749 | publicMethod.close = function () { | ||
| 750 | if (open && !closing) { | ||
| 751 | closing = true; | ||
| 752 | |||
| 753 | open = false; | ||
| 754 | |||
| 755 | trigger(event_cleanup, settings.onCleanup); | ||
| 756 | |||
| 757 | $window.unbind('.' + prefix + ' .' + event_ie6); | ||
| 758 | |||
| 759 | $overlay.fadeTo('fast', 0); | ||
| 760 | |||
| 761 | $box.stop().fadeTo('fast', 0, function () { | ||
| 762 | |||
| 763 | trigger(event_purge); | ||
| 764 | |||
| 765 | $loaded.remove(); | ||
| 766 | |||
| 767 | $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide(); | ||
| 768 | |||
| 769 | setTimeout(function () { | ||
| 770 | closing = false; | ||
| 771 | trigger(event_closed, settings.onClosed); | ||
| 772 | }, 1); | ||
| 773 | }); | ||
| 774 | } | ||
| 775 | }; | ||
| 776 | |||
| 777 | // A method for fetching the current element ColorBox is referencing. | ||
| 778 | // returns a jQuery object. | ||
| 779 | publicMethod.element = function () { | ||
| 780 | return $(element); | ||
| 781 | }; | ||
| 782 | |||
| 783 | publicMethod.settings = defaults; | ||
| 784 | |||
| 785 | // Initializes ColorBox when the DOM has loaded | ||
| 786 | $(publicMethod.init); | ||
| 787 | |||
| 788 | }(jQuery, this)); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/Branding/scripts/jquery.datePicker.js
0 → 100644
| 1 | /** | ||
| 2 | * Copyright (c) 2008 Kelvin Luck (http://www.kelvinluck.com/) | ||
| 3 | * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) | ||
| 4 | * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. | ||
| 5 | * . | ||
| 6 | * $Id: jquery.datePicker.js 102 2010-09-13 14:00:54Z kelvin.luck $ | ||
| 7 | **/ | ||
| 8 | |||
| 9 | (function($){ | ||
| 10 | |||
| 11 | $.fn.extend({ | ||
| 12 | /** | ||
| 13 | * Render a calendar table into any matched elements. | ||
| 14 | * | ||
| 15 | * @param Object s (optional) Customize your calendars. | ||
| 16 | * @option Number month The month to render (NOTE that months are zero based). Default is today's month. | ||
| 17 | * @option Number year The year to render. Default is today's year. | ||
| 18 | * @option Function renderCallback A reference to a function that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Default is no callback. | ||
| 19 | * @option Number showHeader Whether or not to show the header row, possible values are: $.dpConst.SHOW_HEADER_NONE (no header), $.dpConst.SHOW_HEADER_SHORT (first letter of each day) and $.dpConst.SHOW_HEADER_LONG (full name of each day). Default is $.dpConst.SHOW_HEADER_SHORT. | ||
| 20 | * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class. | ||
| 21 | * @type jQuery | ||
| 22 | * @name renderCalendar | ||
| 23 | * @cat plugins/datePicker | ||
| 24 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 25 | * | ||
| 26 | * @example $('#calendar-me').renderCalendar({month:0, year:2007}); | ||
| 27 | * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. | ||
| 28 | * | ||
| 29 | * @example | ||
| 30 | * var testCallback = function($td, thisDate, month, year) | ||
| 31 | * { | ||
| 32 | * if ($td.is('.current-month') && thisDate.getDay() == 4) { | ||
| 33 | * var d = thisDate.getDate(); | ||
| 34 | * $td.bind( | ||
| 35 | * 'click', | ||
| 36 | * function() | ||
| 37 | * { | ||
| 38 | * alert('You clicked on ' + d + '/' + (Number(month)+1) + '/' + year); | ||
| 39 | * } | ||
| 40 | * ).addClass('thursday'); | ||
| 41 | * } else if (thisDate.getDay() == 5) { | ||
| 42 | * $td.html('Friday the ' + $td.html() + 'th'); | ||
| 43 | * } | ||
| 44 | * } | ||
| 45 | * $('#calendar-me').renderCalendar({month:0, year:2007, renderCallback:testCallback}); | ||
| 46 | * | ||
| 47 | * @desc Renders a calendar displaying January 2007 into the element with an id of calendar-me. Every Thursday in the current month has a class of "thursday" applied to it, is clickable and shows an alert when clicked. Every Friday on the calendar has the number inside replaced with text. | ||
| 48 | **/ | ||
| 49 | renderCalendar : function(s) | ||
| 50 | { | ||
| 51 | var dc = function(a) | ||
| 52 | { | ||
| 53 | return document.createElement(a); | ||
| 54 | }; | ||
| 55 | |||
| 56 | s = $.extend({}, $.fn.datePicker.defaults, s); | ||
| 57 | |||
| 58 | if (s.showHeader != $.dpConst.SHOW_HEADER_NONE) { | ||
| 59 | var headRow = $(dc('tr')); | ||
| 60 | for (var i=Date.firstDayOfWeek; i<Date.firstDayOfWeek+7; i++) { | ||
| 61 | var weekday = i%7; | ||
| 62 | var day = Date.dayNames[weekday]; | ||
| 63 | headRow.append( | ||
| 64 | jQuery(dc('th')).attr({'scope':'col', 'abbr':day, 'title':day, 'class':(weekday == 0 || weekday == 6 ? 'weekend' : 'weekday')}).html(s.showHeader == $.dpConst.SHOW_HEADER_SHORT ? day.substr(0, 1) : day) | ||
| 65 | ); | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | |||
| 69 | var calendarTable = $(dc('table')) | ||
| 70 | .attr( | ||
| 71 | { | ||
| 72 | 'cellspacing':2 | ||
| 73 | } | ||
| 74 | ) | ||
| 75 | .addClass('jCalendar') | ||
| 76 | .append( | ||
| 77 | (s.showHeader != $.dpConst.SHOW_HEADER_NONE ? | ||
| 78 | $(dc('thead')) | ||
| 79 | .append(headRow) | ||
| 80 | : | ||
| 81 | dc('thead') | ||
| 82 | ) | ||
| 83 | ); | ||
| 84 | var tbody = $(dc('tbody')); | ||
| 85 | |||
| 86 | var today = (new Date()).zeroTime(); | ||
| 87 | today.setHours(12); | ||
| 88 | |||
| 89 | var month = s.month == undefined ? today.getMonth() : s.month; | ||
| 90 | var year = s.year || today.getFullYear(); | ||
| 91 | |||
| 92 | var currentDate = (new Date(year, month, 1, 12, 0, 0)); | ||
| 93 | |||
| 94 | |||
| 95 | var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay() + 1; | ||
| 96 | if (firstDayOffset > 1) firstDayOffset -= 7; | ||
| 97 | var weeksToDraw = Math.ceil(( (-1*firstDayOffset+1) + currentDate.getDaysInMonth() ) /7); | ||
| 98 | currentDate.addDays(firstDayOffset-1); | ||
| 99 | |||
| 100 | var doHover = function(firstDayInBounds) | ||
| 101 | { | ||
| 102 | return function() | ||
| 103 | { | ||
| 104 | if (s.hoverClass) { | ||
| 105 | var $this = $(this); | ||
| 106 | if (!s.selectWeek) { | ||
| 107 | $this.addClass(s.hoverClass); | ||
| 108 | } else if (firstDayInBounds && !$this.is('.disabled')) { | ||
| 109 | $this.parent().addClass('activeWeekHover'); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | }; | ||
| 114 | var unHover = function() | ||
| 115 | { | ||
| 116 | if (s.hoverClass) { | ||
| 117 | var $this = $(this); | ||
| 118 | $this.removeClass(s.hoverClass); | ||
| 119 | $this.parent().removeClass('activeWeekHover'); | ||
| 120 | } | ||
| 121 | }; | ||
| 122 | |||
| 123 | var w = 0; | ||
| 124 | while (w++<weeksToDraw) { | ||
| 125 | var r = jQuery(dc('tr')); | ||
| 126 | var firstDayInBounds = s.dpController ? currentDate > s.dpController.startDate : false; | ||
| 127 | for (var i=0; i<7; i++) { | ||
| 128 | var thisMonth = currentDate.getMonth() == month; | ||
| 129 | var d = $(dc('td')) | ||
| 130 | .text(currentDate.getDate() + '') | ||
| 131 | .addClass((thisMonth ? 'current-month ' : 'other-month ') + | ||
| 132 | (currentDate.isWeekend() ? 'weekend ' : 'weekday ') + | ||
| 133 | (thisMonth && currentDate.getTime() == today.getTime() ? 'today ' : '') | ||
| 134 | ) | ||
| 135 | .data('datePickerDate', currentDate.asString()) | ||
| 136 | .hover(doHover(firstDayInBounds), unHover) | ||
| 137 | ; | ||
| 138 | r.append(d); | ||
| 139 | if (s.renderCallback) { | ||
| 140 | s.renderCallback(d, currentDate, month, year); | ||
| 141 | } | ||
| 142 | // addDays(1) fails in some locales due to daylight savings. See issue 39. | ||
| 143 | //currentDate.addDays(1); | ||
| 144 | // set the time to midday to avoid any weird timezone issues?? | ||
| 145 | currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 12, 0, 0); | ||
| 146 | } | ||
| 147 | tbody.append(r); | ||
| 148 | } | ||
| 149 | calendarTable.append(tbody); | ||
| 150 | |||
| 151 | return this.each( | ||
| 152 | function() | ||
| 153 | { | ||
| 154 | $(this).empty().append(calendarTable); | ||
| 155 | } | ||
| 156 | ); | ||
| 157 | }, | ||
| 158 | /** | ||
| 159 | * Create a datePicker associated with each of the matched elements. | ||
| 160 | * | ||
| 161 | * The matched element will receive a few custom events with the following signatures: | ||
| 162 | * | ||
| 163 | * dateSelected(event, date, $td, status) | ||
| 164 | * Triggered when a date is selected. event is a reference to the event, date is the Date selected, $td is a jquery object wrapped around the TD that was clicked on and status is whether the date was selected (true) or deselected (false) | ||
| 165 | * | ||
| 166 | * dpClosed(event, selected) | ||
| 167 | * Triggered when the date picker is closed. event is a reference to the event and selected is an Array containing Date objects. | ||
| 168 | * | ||
| 169 | * dpMonthChanged(event, displayedMonth, displayedYear) | ||
| 170 | * Triggered when the month of the popped up calendar is changed. event is a reference to the event, displayedMonth is the number of the month now displayed (zero based) and displayedYear is the year of the month. | ||
| 171 | * | ||
| 172 | * dpDisplayed(event, $datePickerDiv) | ||
| 173 | * Triggered when the date picker is created. $datePickerDiv is the div containing the date picker. Use this event to add custom content/ listeners to the popped up date picker. | ||
| 174 | * | ||
| 175 | * @param Object s (optional) Customize your date pickers. | ||
| 176 | * @option Number month The month to render when the date picker is opened (NOTE that months are zero based). Default is today's month. | ||
| 177 | * @option Number year The year to render when the date picker is opened. Default is today's year. | ||
| 178 | * @option String startDate The first date date can be selected. | ||
| 179 | * @option String endDate The last date that can be selected. | ||
| 180 | * @option Boolean inline Whether to create the datePicker as inline (e.g. always on the page) or as a model popup. Default is false (== modal popup) | ||
| 181 | * @option Boolean createButton Whether to create a .dp-choose-date anchor directly after the matched element which when clicked will trigger the showing of the date picker. Default is true. | ||
| 182 | * @option Boolean showYearNavigation Whether to display buttons which allow the user to navigate through the months a year at a time. Default is true. | ||
| 183 | * @option Boolean closeOnSelect Whether to close the date picker when a date is selected. Default is true. | ||
| 184 | * @option Boolean displayClose Whether to create a "Close" button within the date picker popup. Default is false. | ||
| 185 | * @option Boolean selectMultiple Whether a user should be able to select multiple dates with this date picker. Default is false. | ||
| 186 | * @option Number numSelectable The maximum number of dates that can be selected where selectMultiple is true. Default is a very high number. | ||
| 187 | * @option Boolean clickInput If the matched element is an input type="text" and this option is true then clicking on the input will cause the date picker to appear. | ||
| 188 | * @option Boolean rememberViewedMonth Whether the datePicker should remember the last viewed month and open on it. If false then the date picker will always open with the month for the first selected date visible. | ||
| 189 | * @option Boolean selectWeek Whether to select a complete week at a time... | ||
| 190 | * @option Number verticalPosition The vertical alignment of the popped up date picker to the matched element. One of $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM. Default is $.dpConst.POS_TOP. | ||
| 191 | * @option Number horizontalPosition The horizontal alignment of the popped up date picker to the matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT. | ||
| 192 | * @option Number verticalOffset The number of pixels offset from the defined verticalPosition of this date picker that it should pop up in. Default in 0. | ||
| 193 | * @option Number horizontalOffset The number of pixels offset from the defined horizontalPosition of this date picker that it should pop up in. Default in 0. | ||
| 194 | * @option (Function|Array) renderCallback A reference to a function (or an array of separate functions) that is called as each cell is rendered and which can add classes and event listeners to the created nodes. Each callback function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. Default is no callback. | ||
| 195 | * @option String hoverClass The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class. | ||
| 196 | * @option String autoFocusNextInput Whether focus should be passed onto the next input in the form (true) or remain on this input (false) when a date is selected and the calendar closes | ||
| 197 | * @type jQuery | ||
| 198 | * @name datePicker | ||
| 199 | * @cat plugins/datePicker | ||
| 200 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 201 | * | ||
| 202 | * @example $('input.date-picker').datePicker(); | ||
| 203 | * @desc Creates a date picker button next to all matched input elements. When the button is clicked on the value of the selected date will be placed in the corresponding input (formatted according to Date.format). | ||
| 204 | * | ||
| 205 | * @example demo/index.html | ||
| 206 | * @desc See the projects homepage for many more complex examples... | ||
| 207 | **/ | ||
| 208 | datePicker : function(s) | ||
| 209 | { | ||
| 210 | if (!$.event._dpCache) $.event._dpCache = []; | ||
| 211 | |||
| 212 | // initialise the date picker controller with the relevant settings... | ||
| 213 | s = $.extend({}, $.fn.datePicker.defaults, s); | ||
| 214 | |||
| 215 | return this.each( | ||
| 216 | function() | ||
| 217 | { | ||
| 218 | var $this = $(this); | ||
| 219 | var alreadyExists = true; | ||
| 220 | |||
| 221 | if (!this._dpId) { | ||
| 222 | this._dpId = $.event.guid++; | ||
| 223 | $.event._dpCache[this._dpId] = new DatePicker(this); | ||
| 224 | alreadyExists = false; | ||
| 225 | } | ||
| 226 | |||
| 227 | if (s.inline) { | ||
| 228 | s.createButton = false; | ||
| 229 | s.displayClose = false; | ||
| 230 | s.closeOnSelect = false; | ||
| 231 | $this.empty(); | ||
| 232 | } | ||
| 233 | |||
| 234 | var controller = $.event._dpCache[this._dpId]; | ||
| 235 | |||
| 236 | controller.init(s); | ||
| 237 | |||
| 238 | if (!alreadyExists && s.createButton) { | ||
| 239 | // create it! | ||
| 240 | controller.button = $('<a href="#" class="dp-choose-date" title="' + $.dpText.TEXT_CHOOSE_DATE + '">' + $.dpText.TEXT_CHOOSE_DATE + '</a>') | ||
| 241 | .bind( | ||
| 242 | 'click', | ||
| 243 | function() | ||
| 244 | { | ||
| 245 | $this.dpDisplay(this); | ||
| 246 | this.blur(); | ||
| 247 | return false; | ||
| 248 | } | ||
| 249 | ); | ||
| 250 | $this.after(controller.button); | ||
| 251 | } | ||
| 252 | |||
| 253 | if (!alreadyExists && $this.is(':text')) { | ||
| 254 | $this | ||
| 255 | .bind( | ||
| 256 | 'dateSelected', | ||
| 257 | function(e, selectedDate, $td) | ||
| 258 | { | ||
| 259 | this.value = selectedDate.asString(); | ||
| 260 | } | ||
| 261 | ).bind( | ||
| 262 | 'change', | ||
| 263 | function() | ||
| 264 | { | ||
| 265 | if (this.value == '') { | ||
| 266 | controller.clearSelected(); | ||
| 267 | } else { | ||
| 268 | var d = Date.fromString(this.value); | ||
| 269 | if (d) { | ||
| 270 | controller.setSelected(d, true, true); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | } | ||
| 274 | ); | ||
| 275 | if (s.clickInput) { | ||
| 276 | $this.bind( | ||
| 277 | 'click', | ||
| 278 | function() | ||
| 279 | { | ||
| 280 | // The change event doesn't happen until the input loses focus so we need to manually trigger it... | ||
| 281 | $this.trigger('change'); | ||
| 282 | $this.dpDisplay(); | ||
| 283 | } | ||
| 284 | ); | ||
| 285 | } | ||
| 286 | var d = Date.fromString(this.value); | ||
| 287 | if (this.value != '' && d) { | ||
| 288 | controller.setSelected(d, true, true); | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | $this.addClass('dp-applied'); | ||
| 293 | |||
| 294 | } | ||
| 295 | ) | ||
| 296 | }, | ||
| 297 | /** | ||
| 298 | * Disables or enables this date picker | ||
| 299 | * | ||
| 300 | * @param Boolean s Whether to disable (true) or enable (false) this datePicker | ||
| 301 | * @type jQuery | ||
| 302 | * @name dpSetDisabled | ||
| 303 | * @cat plugins/datePicker | ||
| 304 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 305 | * | ||
| 306 | * @example $('.date-picker').datePicker(); | ||
| 307 | * $('.date-picker').dpSetDisabled(true); | ||
| 308 | * @desc Prevents this date picker from displaying and adds a class of dp-disabled to it (and it's associated button if it has one) for styling purposes. If the matched element is an input field then it will also set the disabled attribute to stop people directly editing the field. | ||
| 309 | **/ | ||
| 310 | dpSetDisabled : function(s) | ||
| 311 | { | ||
| 312 | return _w.call(this, 'setDisabled', s); | ||
| 313 | }, | ||
| 314 | /** | ||
| 315 | * Updates the first selectable date for any date pickers on any matched elements. | ||
| 316 | * | ||
| 317 | * @param String d A string representing the first selectable date (formatted according to Date.format). | ||
| 318 | * @type jQuery | ||
| 319 | * @name dpSetStartDate | ||
| 320 | * @cat plugins/datePicker | ||
| 321 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 322 | * | ||
| 323 | * @example $('.date-picker').datePicker(); | ||
| 324 | * $('.date-picker').dpSetStartDate('01/01/2000'); | ||
| 325 | * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the first selectable date for each of these to the first day of the millenium. | ||
| 326 | **/ | ||
| 327 | dpSetStartDate : function(d) | ||
| 328 | { | ||
| 329 | return _w.call(this, 'setStartDate', d); | ||
| 330 | }, | ||
| 331 | /** | ||
| 332 | * Updates the last selectable date for any date pickers on any matched elements. | ||
| 333 | * | ||
| 334 | * @param String d A string representing the last selectable date (formatted according to Date.format). | ||
| 335 | * @type jQuery | ||
| 336 | * @name dpSetEndDate | ||
| 337 | * @cat plugins/datePicker | ||
| 338 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 339 | * | ||
| 340 | * @example $('.date-picker').datePicker(); | ||
| 341 | * $('.date-picker').dpSetEndDate('01/01/2010'); | ||
| 342 | * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the last selectable date for each of these to the first Janurary 2010. | ||
| 343 | **/ | ||
| 344 | dpSetEndDate : function(d) | ||
| 345 | { | ||
| 346 | return _w.call(this, 'setEndDate', d); | ||
| 347 | }, | ||
| 348 | /** | ||
| 349 | * Gets a list of Dates currently selected by this datePicker. This will be an empty array if no dates are currently selected or NULL if there is no datePicker associated with the matched element. | ||
| 350 | * | ||
| 351 | * @type Array | ||
| 352 | * @name dpGetSelected | ||
| 353 | * @cat plugins/datePicker | ||
| 354 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 355 | * | ||
| 356 | * @example $('.date-picker').datePicker(); | ||
| 357 | * alert($('.date-picker').dpGetSelected()); | ||
| 358 | * @desc Will alert an empty array (as nothing is selected yet) | ||
| 359 | **/ | ||
| 360 | dpGetSelected : function() | ||
| 361 | { | ||
| 362 | var c = _getController(this[0]); | ||
| 363 | if (c) { | ||
| 364 | return c.getSelected(); | ||
| 365 | } | ||
| 366 | return null; | ||
| 367 | }, | ||
| 368 | /** | ||
| 369 | * Selects or deselects a date on any matched element's date pickers. Deselcting is only useful on date pickers where selectMultiple==true. Selecting will only work if the passed date is within the startDate and endDate boundries for a given date picker. | ||
| 370 | * | ||
| 371 | * @param String d A string representing the date you want to select (formatted according to Date.format). | ||
| 372 | * @param Boolean v Whether you want to select (true) or deselect (false) this date. Optional - default = true. | ||
| 373 | * @param Boolean m Whether you want the date picker to open up on the month of this date when it is next opened. Optional - default = true. | ||
| 374 | * @param Boolean e Whether you want the date picker to dispatch events related to this change of selection. Optional - default = true. | ||
| 375 | * @type jQuery | ||
| 376 | * @name dpSetSelected | ||
| 377 | * @cat plugins/datePicker | ||
| 378 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 379 | * | ||
| 380 | * @example $('.date-picker').datePicker(); | ||
| 381 | * $('.date-picker').dpSetSelected('01/01/2010'); | ||
| 382 | * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010. | ||
| 383 | **/ | ||
| 384 | dpSetSelected : function(d, v, m, e) | ||
| 385 | { | ||
| 386 | if (v == undefined) v=true; | ||
| 387 | if (m == undefined) m=true; | ||
| 388 | if (e == undefined) e=true; | ||
| 389 | return _w.call(this, 'setSelected', Date.fromString(d), v, m, e); | ||
| 390 | }, | ||
| 391 | /** | ||
| 392 | * Sets the month that will be displayed when the date picker is next opened. If the passed month is before startDate then the month containing startDate will be displayed instead. If the passed month is after endDate then the month containing the endDate will be displayed instead. | ||
| 393 | * | ||
| 394 | * @param Number m The month you want the date picker to display. Optional - defaults to the currently displayed month. | ||
| 395 | * @param Number y The year you want the date picker to display. Optional - defaults to the currently displayed year. | ||
| 396 | * @type jQuery | ||
| 397 | * @name dpSetDisplayedMonth | ||
| 398 | * @cat plugins/datePicker | ||
| 399 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 400 | * | ||
| 401 | * @example $('.date-picker').datePicker(); | ||
| 402 | * $('.date-picker').dpSetDisplayedMonth(10, 2008); | ||
| 403 | * @desc Creates a date picker associated with all elements with a class of "date-picker" then sets the selected date on these date pickers to the first Janurary 2010. When the date picker is next opened it will display Janurary 2010. | ||
| 404 | **/ | ||
| 405 | dpSetDisplayedMonth : function(m, y) | ||
| 406 | { | ||
| 407 | return _w.call(this, 'setDisplayedMonth', Number(m), Number(y), true); | ||
| 408 | }, | ||
| 409 | /** | ||
| 410 | * Displays the date picker associated with the matched elements. Since only one date picker can be displayed at once then the date picker associated with the last matched element will be the one that is displayed. | ||
| 411 | * | ||
| 412 | * @param HTMLElement e An element that you want the date picker to pop up relative in position to. Optional - default behaviour is to pop up next to the element associated with this date picker. | ||
| 413 | * @type jQuery | ||
| 414 | * @name dpDisplay | ||
| 415 | * @cat plugins/datePicker | ||
| 416 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 417 | * | ||
| 418 | * @example $('#date-picker').datePicker(); | ||
| 419 | * $('#date-picker').dpDisplay(); | ||
| 420 | * @desc Creates a date picker associated with the element with an id of date-picker and then causes it to pop up. | ||
| 421 | **/ | ||
| 422 | dpDisplay : function(e) | ||
| 423 | { | ||
| 424 | return _w.call(this, 'display', e); | ||
| 425 | }, | ||
| 426 | /** | ||
| 427 | * Sets a function or array of functions that is called when each TD of the date picker popup is rendered to the page | ||
| 428 | * | ||
| 429 | * @param (Function|Array) a A function or an array of functions that are called when each td is rendered. Each function will receive four arguments; a jquery object wrapping the created TD, a Date object containing the date this TD represents, a number giving the currently rendered month and a number giving the currently rendered year. | ||
| 430 | * @type jQuery | ||
| 431 | * @name dpSetRenderCallback | ||
| 432 | * @cat plugins/datePicker | ||
| 433 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 434 | * | ||
| 435 | * @example $('#date-picker').datePicker(); | ||
| 436 | * $('#date-picker').dpSetRenderCallback(function($td, thisDate, month, year) | ||
| 437 | * { | ||
| 438 | * // do stuff as each td is rendered dependant on the date in the td and the displayed month and year | ||
| 439 | * }); | ||
| 440 | * @desc Creates a date picker associated with the element with an id of date-picker and then creates a function which is called as each td is rendered when this date picker is displayed. | ||
| 441 | **/ | ||
| 442 | dpSetRenderCallback : function(a) | ||
| 443 | { | ||
| 444 | return _w.call(this, 'setRenderCallback', a); | ||
| 445 | }, | ||
| 446 | /** | ||
| 447 | * Sets the position that the datePicker will pop up (relative to it's associated element) | ||
| 448 | * | ||
| 449 | * @param Number v The vertical alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_TOP and $.dpConst.POS_BOTTOM | ||
| 450 | * @param Number h The horizontal alignment of the created date picker to it's associated element. Possible values are $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT | ||
| 451 | * @type jQuery | ||
| 452 | * @name dpSetPosition | ||
| 453 | * @cat plugins/datePicker | ||
| 454 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 455 | * | ||
| 456 | * @example $('#date-picker').datePicker(); | ||
| 457 | * $('#date-picker').dpSetPosition($.dpConst.POS_BOTTOM, $.dpConst.POS_RIGHT); | ||
| 458 | * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be bottom and right aligned to the #date-picker element. | ||
| 459 | **/ | ||
| 460 | dpSetPosition : function(v, h) | ||
| 461 | { | ||
| 462 | return _w.call(this, 'setPosition', v, h); | ||
| 463 | }, | ||
| 464 | /** | ||
| 465 | * Sets the offset that the popped up date picker will have from it's default position relative to it's associated element (as set by dpSetPosition) | ||
| 466 | * | ||
| 467 | * @param Number v The vertical offset of the created date picker. | ||
| 468 | * @param Number h The horizontal offset of the created date picker. | ||
| 469 | * @type jQuery | ||
| 470 | * @name dpSetOffset | ||
| 471 | * @cat plugins/datePicker | ||
| 472 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 473 | * | ||
| 474 | * @example $('#date-picker').datePicker(); | ||
| 475 | * $('#date-picker').dpSetOffset(-20, 200); | ||
| 476 | * @desc Creates a date picker associated with the element with an id of date-picker and makes it so that when this date picker pops up it will be 20 pixels above and 200 pixels to the right of it's default position. | ||
| 477 | **/ | ||
| 478 | dpSetOffset : function(v, h) | ||
| 479 | { | ||
| 480 | return _w.call(this, 'setOffset', v, h); | ||
| 481 | }, | ||
| 482 | /** | ||
| 483 | * Closes the open date picker associated with this element. | ||
| 484 | * | ||
| 485 | * @type jQuery | ||
| 486 | * @name dpClose | ||
| 487 | * @cat plugins/datePicker | ||
| 488 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 489 | * | ||
| 490 | * @example $('.date-pick') | ||
| 491 | * .datePicker() | ||
| 492 | * .bind( | ||
| 493 | * 'focus', | ||
| 494 | * function() | ||
| 495 | * { | ||
| 496 | * $(this).dpDisplay(); | ||
| 497 | * } | ||
| 498 | * ).bind( | ||
| 499 | * 'blur', | ||
| 500 | * function() | ||
| 501 | * { | ||
| 502 | * $(this).dpClose(); | ||
| 503 | * } | ||
| 504 | * ); | ||
| 505 | **/ | ||
| 506 | dpClose : function() | ||
| 507 | { | ||
| 508 | return _w.call(this, '_closeCalendar', false, this[0]); | ||
| 509 | }, | ||
| 510 | /** | ||
| 511 | * Rerenders the date picker's current month (for use with inline calendars and renderCallbacks). | ||
| 512 | * | ||
| 513 | * @type jQuery | ||
| 514 | * @name dpRerenderCalendar | ||
| 515 | * @cat plugins/datePicker | ||
| 516 | * @author Kelvin Luck (http://www.kelvinluck.com/) | ||
| 517 | * | ||
| 518 | **/ | ||
| 519 | dpRerenderCalendar : function() | ||
| 520 | { | ||
| 521 | return _w.call(this, '_rerenderCalendar'); | ||
| 522 | }, | ||
| 523 | // private function called on unload to clean up any expandos etc and prevent memory links... | ||
| 524 | _dpDestroy : function() | ||
| 525 | { | ||
| 526 | // TODO - implement this? | ||
| 527 | } | ||
| 528 | }); | ||
| 529 | |||
| 530 | // private internal function to cut down on the amount of code needed where we forward | ||
| 531 | // dp* methods on the jQuery object on to the relevant DatePicker controllers... | ||
| 532 | var _w = function(f, a1, a2, a3, a4) | ||
| 533 | { | ||
| 534 | return this.each( | ||
| 535 | function() | ||
| 536 | { | ||
| 537 | var c = _getController(this); | ||
| 538 | if (c) { | ||
| 539 | c[f](a1, a2, a3, a4); | ||
| 540 | } | ||
| 541 | } | ||
| 542 | ); | ||
| 543 | }; | ||
| 544 | |||
| 545 | function DatePicker(ele) | ||
| 546 | { | ||
| 547 | this.ele = ele; | ||
| 548 | |||
| 549 | // initial values... | ||
| 550 | this.displayedMonth = null; | ||
| 551 | this.displayedYear = null; | ||
| 552 | this.startDate = null; | ||
| 553 | this.endDate = null; | ||
| 554 | this.showYearNavigation = null; | ||
| 555 | this.closeOnSelect = null; | ||
| 556 | this.displayClose = null; | ||
| 557 | this.rememberViewedMonth= null; | ||
| 558 | this.selectMultiple = null; | ||
| 559 | this.numSelectable = null; | ||
| 560 | this.numSelected = null; | ||
| 561 | this.verticalPosition = null; | ||
| 562 | this.horizontalPosition = null; | ||
| 563 | this.verticalOffset = null; | ||
| 564 | this.horizontalOffset = null; | ||
| 565 | this.button = null; | ||
| 566 | this.renderCallback = []; | ||
| 567 | this.selectedDates = {}; | ||
| 568 | this.inline = null; | ||
| 569 | this.context = '#dp-popup'; | ||
| 570 | this.settings = {}; | ||
| 571 | }; | ||
| 572 | $.extend( | ||
| 573 | DatePicker.prototype, | ||
| 574 | { | ||
| 575 | init : function(s) | ||
| 576 | { | ||
| 577 | this.setStartDate(s.startDate); | ||
| 578 | this.setEndDate(s.endDate); | ||
| 579 | this.setDisplayedMonth(Number(s.month), Number(s.year)); | ||
| 580 | this.setRenderCallback(s.renderCallback); | ||
| 581 | this.showYearNavigation = s.showYearNavigation; | ||
| 582 | this.closeOnSelect = s.closeOnSelect; | ||
| 583 | this.displayClose = s.displayClose; | ||
| 584 | this.rememberViewedMonth = s.rememberViewedMonth; | ||
| 585 | this.selectMultiple = s.selectMultiple; | ||
| 586 | this.numSelectable = s.selectMultiple ? s.numSelectable : 1; | ||
| 587 | this.numSelected = 0; | ||
| 588 | this.verticalPosition = s.verticalPosition; | ||
| 589 | this.horizontalPosition = s.horizontalPosition; | ||
| 590 | this.hoverClass = s.hoverClass; | ||
| 591 | this.setOffset(s.verticalOffset, s.horizontalOffset); | ||
| 592 | this.inline = s.inline; | ||
| 593 | this.settings = s; | ||
| 594 | if (this.inline) { | ||
| 595 | this.context = this.ele; | ||
| 596 | this.display(); | ||
| 597 | } | ||
| 598 | }, | ||
| 599 | setStartDate : function(d) | ||
| 600 | { | ||
| 601 | if (d) { | ||
| 602 | this.startDate = Date.fromString(d); | ||
| 603 | } | ||
| 604 | if (!this.startDate) { | ||
| 605 | this.startDate = (new Date()).zeroTime(); | ||
| 606 | } | ||
| 607 | this.setDisplayedMonth(this.displayedMonth, this.displayedYear); | ||
| 608 | }, | ||
| 609 | setEndDate : function(d) | ||
| 610 | { | ||
| 611 | if (d) { | ||
| 612 | this.endDate = Date.fromString(d); | ||
| 613 | } | ||
| 614 | if (!this.endDate) { | ||
| 615 | this.endDate = (new Date('12/31/2999')); // using the JS Date.parse function which expects mm/dd/yyyy | ||
| 616 | } | ||
| 617 | if (this.endDate.getTime() < this.startDate.getTime()) { | ||
| 618 | this.endDate = this.startDate; | ||
| 619 | } | ||
| 620 | this.setDisplayedMonth(this.displayedMonth, this.displayedYear); | ||
| 621 | }, | ||
| 622 | setPosition : function(v, h) | ||
| 623 | { | ||
| 624 | this.verticalPosition = v; | ||
| 625 | this.horizontalPosition = h; | ||
| 626 | }, | ||
| 627 | setOffset : function(v, h) | ||
| 628 | { | ||
| 629 | this.verticalOffset = parseInt(v) || 0; | ||
| 630 | this.horizontalOffset = parseInt(h) || 0; | ||
| 631 | }, | ||
| 632 | setDisabled : function(s) | ||
| 633 | { | ||
| 634 | $e = $(this.ele); | ||
| 635 | $e[s ? 'addClass' : 'removeClass']('dp-disabled'); | ||
| 636 | if (this.button) { | ||
| 637 | $but = $(this.button); | ||
| 638 | $but[s ? 'addClass' : 'removeClass']('dp-disabled'); | ||
| 639 | $but.attr('title', s ? '' : $.dpText.TEXT_CHOOSE_DATE); | ||
| 640 | } | ||
| 641 | if ($e.is(':text')) { | ||
| 642 | $e.attr('disabled', s ? 'disabled' : ''); | ||
| 643 | } | ||
| 644 | }, | ||
| 645 | setDisplayedMonth : function(m, y, rerender) | ||
| 646 | { | ||
| 647 | if (this.startDate == undefined || this.endDate == undefined) { | ||
| 648 | return; | ||
| 649 | } | ||
| 650 | var s = new Date(this.startDate.getTime()); | ||
| 651 | s.setDate(1); | ||
| 652 | var e = new Date(this.endDate.getTime()); | ||
| 653 | e.setDate(1); | ||
| 654 | |||
| 655 | var t; | ||
| 656 | if ((!m && !y) || (isNaN(m) && isNaN(y))) { | ||
| 657 | // no month or year passed - default to current month | ||
| 658 | t = new Date().zeroTime(); | ||
| 659 | t.setDate(1); | ||
| 660 | } else if (isNaN(m)) { | ||
| 661 | // just year passed in - presume we want the displayedMonth | ||
| 662 | t = new Date(y, this.displayedMonth, 1); | ||
| 663 | } else if (isNaN(y)) { | ||
| 664 | // just month passed in - presume we want the displayedYear | ||
| 665 | t = new Date(this.displayedYear, m, 1); | ||
| 666 | } else { | ||
| 667 | // year and month passed in - that's the date we want! | ||
| 668 | t = new Date(y, m, 1) | ||
| 669 | } | ||
| 670 | // check if the desired date is within the range of our defined startDate and endDate | ||
| 671 | if (t.getTime() < s.getTime()) { | ||
| 672 | t = s; | ||
| 673 | } else if (t.getTime() > e.getTime()) { | ||
| 674 | t = e; | ||
| 675 | } | ||
| 676 | var oldMonth = this.displayedMonth; | ||
| 677 | var oldYear = this.displayedYear; | ||
| 678 | this.displayedMonth = t.getMonth(); | ||
| 679 | this.displayedYear = t.getFullYear(); | ||
| 680 | |||
| 681 | if (rerender && (this.displayedMonth != oldMonth || this.displayedYear != oldYear)) | ||
| 682 | { | ||
| 683 | this._rerenderCalendar(); | ||
| 684 | $(this.ele).trigger('dpMonthChanged', [this.displayedMonth, this.displayedYear]); | ||
| 685 | } | ||
| 686 | }, | ||
| 687 | setSelected : function(d, v, moveToMonth, dispatchEvents) | ||
| 688 | { | ||
| 689 | if (d < this.startDate || d.zeroTime() > this.endDate.zeroTime()) { | ||
| 690 | // Don't allow people to select dates outside range... | ||
| 691 | return; | ||
| 692 | } | ||
| 693 | var s = this.settings; | ||
| 694 | if (s.selectWeek) | ||
| 695 | { | ||
| 696 | d = d.addDays(- (d.getDay() - Date.firstDayOfWeek + 7) % 7); | ||
| 697 | if (d < this.startDate) // The first day of this week is before the start date so is unselectable... | ||
| 698 | { | ||
| 699 | return; | ||
| 700 | } | ||
| 701 | } | ||
| 702 | if (v == this.isSelected(d)) // this date is already un/selected | ||
| 703 | { | ||
| 704 | return; | ||
| 705 | } | ||
| 706 | if (this.selectMultiple == false) { | ||
| 707 | this.clearSelected(); | ||
| 708 | } else if (v && this.numSelected == this.numSelectable) { | ||
| 709 | // can't select any more dates... | ||
| 710 | return; | ||
| 711 | } | ||
| 712 | if (moveToMonth && (this.displayedMonth != d.getMonth() || this.displayedYear != d.getFullYear())) { | ||
| 713 | this.setDisplayedMonth(d.getMonth(), d.getFullYear(), true); | ||
| 714 | } | ||
| 715 | this.selectedDates[d.asString()] = v; | ||
| 716 | this.numSelected += v ? 1 : -1; | ||
| 717 | var selectorString = 'td.' + (d.getMonth() == this.displayedMonth ? 'current-month' : 'other-month'); | ||
| 718 | var $td; | ||
| 719 | $(selectorString, this.context).each( | ||
| 720 | function() | ||
| 721 | { | ||
| 722 | if ($(this).data('datePickerDate') == d.asString()) { | ||
| 723 | $td = $(this); | ||
| 724 | if (s.selectWeek) | ||
| 725 | { | ||
| 726 | $td.parent()[v ? 'addClass' : 'removeClass']('selectedWeek'); | ||
| 727 | } | ||
| 728 | $td[v ? 'addClass' : 'removeClass']('selected'); | ||
| 729 | } | ||
| 730 | } | ||
| 731 | ); | ||
| 732 | $('td', this.context).not('.selected')[this.selectMultiple && this.numSelected == this.numSelectable ? 'addClass' : 'removeClass']('unselectable'); | ||
| 733 | |||
| 734 | if (dispatchEvents) | ||
| 735 | { | ||
| 736 | var s = this.isSelected(d); | ||
| 737 | $e = $(this.ele); | ||
| 738 | var dClone = Date.fromString(d.asString()); | ||
| 739 | $e.trigger('dateSelected', [dClone, $td, s]); | ||
| 740 | $e.trigger('change'); | ||
| 741 | } | ||
| 742 | }, | ||
| 743 | isSelected : function(d) | ||
| 744 | { | ||
| 745 | return this.selectedDates[d.asString()]; | ||
| 746 | }, | ||
| 747 | getSelected : function() | ||
| 748 | { | ||
| 749 | var r = []; | ||
| 750 | for(var s in this.selectedDates) { | ||
| 751 | if (this.selectedDates[s] == true) { | ||
| 752 | r.push(Date.fromString(s)); | ||
| 753 | } | ||
| 754 | } | ||
| 755 | return r; | ||
| 756 | }, | ||
| 757 | clearSelected : function() | ||
| 758 | { | ||
| 759 | this.selectedDates = {}; | ||
| 760 | this.numSelected = 0; | ||
| 761 | $('td.selected', this.context).removeClass('selected').parent().removeClass('selectedWeek'); | ||
| 762 | }, | ||
| 763 | display : function(eleAlignTo) | ||
| 764 | { | ||
| 765 | if ($(this.ele).is('.dp-disabled')) return; | ||
| 766 | |||
| 767 | eleAlignTo = eleAlignTo || this.ele; | ||
| 768 | var c = this; | ||
| 769 | var $ele = $(eleAlignTo); | ||
| 770 | var eleOffset = $ele.offset(); | ||
| 771 | |||
| 772 | var $createIn; | ||
| 773 | var attrs; | ||
| 774 | var attrsCalendarHolder; | ||
| 775 | var cssRules; | ||
| 776 | |||
| 777 | if (c.inline) { | ||
| 778 | $createIn = $(this.ele); | ||
| 779 | attrs = { | ||
| 780 | 'id' : 'calendar-' + this.ele._dpId, | ||
| 781 | 'class' : 'dp-popup dp-popup-inline' | ||
| 782 | }; | ||
| 783 | |||
| 784 | $('.dp-popup', $createIn).remove(); | ||
| 785 | cssRules = { | ||
| 786 | }; | ||
| 787 | } else { | ||
| 788 | $createIn = $('body'); | ||
| 789 | attrs = { | ||
| 790 | 'id' : 'dp-popup', | ||
| 791 | 'class' : 'dp-popup' | ||
| 792 | }; | ||
| 793 | cssRules = { | ||
| 794 | 'top' : eleOffset.top + c.verticalOffset, | ||
| 795 | 'left' : eleOffset.left + c.horizontalOffset | ||
| 796 | }; | ||
| 797 | |||
| 798 | var _checkMouse = function(e) | ||
| 799 | { | ||
| 800 | var el = e.target; | ||
| 801 | var cal = $('#dp-popup')[0]; | ||
| 802 | |||
| 803 | while (true){ | ||
| 804 | if (el == cal) { | ||
| 805 | return true; | ||
| 806 | } else if (el == document) { | ||
| 807 | c._closeCalendar(); | ||
| 808 | return false; | ||
| 809 | } else { | ||
| 810 | el = $(el).parent()[0]; | ||
| 811 | } | ||
| 812 | } | ||
| 813 | }; | ||
| 814 | this._checkMouse = _checkMouse; | ||
| 815 | |||
| 816 | c._closeCalendar(true); | ||
| 817 | $(document).bind( | ||
| 818 | 'keydown.datepicker', | ||
| 819 | function(event) | ||
| 820 | { | ||
| 821 | if (event.keyCode == 27) { | ||
| 822 | c._closeCalendar(); | ||
| 823 | } | ||
| 824 | } | ||
| 825 | ); | ||
| 826 | } | ||
| 827 | |||
| 828 | if (!c.rememberViewedMonth) | ||
| 829 | { | ||
| 830 | var selectedDate = this.getSelected()[0]; | ||
| 831 | if (selectedDate) { | ||
| 832 | selectedDate = new Date(selectedDate); | ||
| 833 | this.setDisplayedMonth(selectedDate.getMonth(), selectedDate.getFullYear(), false); | ||
| 834 | } | ||
| 835 | } | ||
| 836 | |||
| 837 | $createIn | ||
| 838 | .append( | ||
| 839 | $('<div></div>') | ||
| 840 | .attr(attrs) | ||
| 841 | .css(cssRules) | ||
| 842 | .append( | ||
| 843 | // $('<a href="#" class="selecteee">aaa</a>'), | ||
| 844 | $('<h2></h2>'), | ||
| 845 | $('<div class="dp-nav-prev"></div>') | ||
| 846 | .append( | ||
| 847 | $('<a class="dp-nav-prev-year" href="#" title="' + $.dpText.TEXT_PREV_YEAR + '"><<</a>') | ||
| 848 | .bind( | ||
| 849 | 'click', | ||
| 850 | function() | ||
| 851 | { | ||
| 852 | return c._displayNewMonth.call(c, this, 0, -1); | ||
| 853 | } | ||
| 854 | ), | ||
| 855 | $('<a class="dp-nav-prev-month" href="#" title="' + $.dpText.TEXT_PREV_MONTH + '"><</a>') | ||
| 856 | .bind( | ||
| 857 | 'click', | ||
| 858 | function() | ||
| 859 | { | ||
| 860 | return c._displayNewMonth.call(c, this, -1, 0); | ||
| 861 | } | ||
| 862 | ) | ||
| 863 | ), | ||
| 864 | $('<div class="dp-nav-next"></div>') | ||
| 865 | .append( | ||
| 866 | $('<a class="dp-nav-next-year" href="#" title="' + $.dpText.TEXT_NEXT_YEAR + '">>></a>') | ||
| 867 | .bind( | ||
| 868 | 'click', | ||
| 869 | function() | ||
| 870 | { | ||
| 871 | return c._displayNewMonth.call(c, this, 0, 1); | ||
| 872 | } | ||
| 873 | ), | ||
| 874 | $('<a class="dp-nav-next-month" href="#" title="' + $.dpText.TEXT_NEXT_MONTH + '">></a>') | ||
| 875 | .bind( | ||
| 876 | 'click', | ||
| 877 | function() | ||
| 878 | { | ||
| 879 | return c._displayNewMonth.call(c, this, 1, 0); | ||
| 880 | } | ||
| 881 | ) | ||
| 882 | ), | ||
| 883 | $('<div class="dp-calendar"></div>') | ||
| 884 | ) | ||
| 885 | .bgIframe() | ||
| 886 | ); | ||
| 887 | |||
| 888 | var $pop = this.inline ? $('.dp-popup', this.context) : $('#dp-popup'); | ||
| 889 | |||
| 890 | if (this.showYearNavigation == false) { | ||
| 891 | $('.dp-nav-prev-year, .dp-nav-next-year', c.context).css('display', 'none'); | ||
| 892 | } | ||
| 893 | if (this.displayClose) { | ||
| 894 | $pop.append( | ||
| 895 | $('<a href="#" id="dp-close">' + $.dpText.TEXT_CLOSE + '</a>') | ||
| 896 | .bind( | ||
| 897 | 'click', | ||
| 898 | function() | ||
| 899 | { | ||
| 900 | c._closeCalendar(); | ||
| 901 | return false; | ||
| 902 | } | ||
| 903 | ) | ||
| 904 | ); | ||
| 905 | } | ||
| 906 | c._renderCalendar(); | ||
| 907 | |||
| 908 | $(this.ele).trigger('dpDisplayed', $pop); | ||
| 909 | |||
| 910 | if (!c.inline) { | ||
| 911 | if (this.verticalPosition == $.dpConst.POS_BOTTOM) { | ||
| 912 | $pop.css('top', eleOffset.top + $ele.height() - $pop.height() + c.verticalOffset); | ||
| 913 | } | ||
| 914 | if (this.horizontalPosition == $.dpConst.POS_RIGHT) { | ||
| 915 | $pop.css('left', eleOffset.left + $ele.width() - $pop.width() + c.horizontalOffset); | ||
| 916 | } | ||
| 917 | // $('.selectee', this.context).focus(); | ||
| 918 | $(document).bind('mousedown.datepicker', this._checkMouse); | ||
| 919 | } | ||
| 920 | |||
| 921 | }, | ||
| 922 | setRenderCallback : function(a) | ||
| 923 | { | ||
| 924 | if (a == null) return; | ||
| 925 | if (a && typeof(a) == 'function') { | ||
| 926 | a = [a]; | ||
| 927 | } | ||
| 928 | this.renderCallback = this.renderCallback.concat(a); | ||
| 929 | }, | ||
| 930 | cellRender : function ($td, thisDate, month, year) { | ||
| 931 | var c = this.dpController; | ||
| 932 | var d = new Date(thisDate.getTime()); | ||
| 933 | |||
| 934 | // add our click handlers to deal with it when the days are clicked... | ||
| 935 | |||
| 936 | $td.bind( | ||
| 937 | 'click', | ||
| 938 | function() | ||
| 939 | { | ||
| 940 | var $this = $(this); | ||
| 941 | if (!$this.is('.disabled')) { | ||
| 942 | c.setSelected(d, !$this.is('.selected') || !c.selectMultiple, false, true); | ||
| 943 | if (c.closeOnSelect) { | ||
| 944 | // Focus the next input in the form… | ||
| 945 | if (c.settings.autoFocusNextInput) { | ||
| 946 | var ele = c.ele; | ||
| 947 | var found = false; | ||
| 948 | $(':input', ele.form).each( | ||
| 949 | function() | ||
| 950 | { | ||
| 951 | if (found) { | ||
| 952 | $(this).focus(); | ||
| 953 | return false; | ||
| 954 | } | ||
| 955 | if (this == ele) { | ||
| 956 | found = true; | ||
| 957 | } | ||
| 958 | } | ||
| 959 | ); | ||
| 960 | } else { | ||
| 961 | c.ele.focus(); | ||
| 962 | } | ||
| 963 | c._closeCalendar(); | ||
| 964 | } | ||
| 965 | } | ||
| 966 | } | ||
| 967 | ); | ||
| 968 | if (c.isSelected(d)) { | ||
| 969 | $td.addClass('selected'); | ||
| 970 | if (c.settings.selectWeek) | ||
| 971 | { | ||
| 972 | $td.parent().addClass('selectedWeek'); | ||
| 973 | } | ||
| 974 | } else if (c.selectMultiple && c.numSelected == c.numSelectable) { | ||
| 975 | $td.addClass('unselectable'); | ||
| 976 | } | ||
| 977 | |||
| 978 | }, | ||
| 979 | _applyRenderCallbacks : function() | ||
| 980 | { | ||
| 981 | var c = this; | ||
| 982 | $('td', this.context).each( | ||
| 983 | function() | ||
| 984 | { | ||
| 985 | for (var i=0; i<c.renderCallback.length; i++) { | ||
| 986 | $td = $(this); | ||
| 987 | c.renderCallback[i].apply(this, [$td, Date.fromString($td.data('datePickerDate')), c.displayedMonth, c.displayedYear]); | ||
| 988 | } | ||
| 989 | } | ||
| 990 | ); | ||
| 991 | return; | ||
| 992 | }, | ||
| 993 | // ele is the clicked button - only proceed if it doesn't have the class disabled... | ||
| 994 | // m and y are -1, 0 or 1 depending which direction we want to go in... | ||
| 995 | _displayNewMonth : function(ele, m, y) | ||
| 996 | { | ||
| 997 | if (!$(ele).is('.disabled')) { | ||
| 998 | this.setDisplayedMonth(this.displayedMonth + m, this.displayedYear + y, true); | ||
| 999 | } | ||
| 1000 | ele.blur(); | ||
| 1001 | return false; | ||
| 1002 | }, | ||
| 1003 | _rerenderCalendar : function() | ||
| 1004 | { | ||
| 1005 | this._clearCalendar(); | ||
| 1006 | this._renderCalendar(); | ||
| 1007 | }, | ||
| 1008 | _renderCalendar : function() | ||
| 1009 | { | ||
| 1010 | // set the title... | ||
| 1011 | $('h2', this.context).html((new Date(this.displayedYear, this.displayedMonth, 1)).asString($.dpText.HEADER_FORMAT)); | ||
| 1012 | |||
| 1013 | // render the calendar... | ||
| 1014 | $('.dp-calendar', this.context).renderCalendar( | ||
| 1015 | $.extend( | ||
| 1016 | {}, | ||
| 1017 | this.settings, | ||
| 1018 | { | ||
| 1019 | month : this.displayedMonth, | ||
| 1020 | year : this.displayedYear, | ||
| 1021 | renderCallback : this.cellRender, | ||
| 1022 | dpController : this, | ||
| 1023 | hoverClass : this.hoverClass | ||
| 1024 | }) | ||
| 1025 | ); | ||
| 1026 | |||
| 1027 | // update the status of the control buttons and disable dates before startDate or after endDate... | ||
| 1028 | // TODO: When should the year buttons be disabled? When you can't go forward a whole year from where you are or is that annoying? | ||
| 1029 | if (this.displayedYear == this.startDate.getFullYear() && this.displayedMonth == this.startDate.getMonth()) { | ||
| 1030 | $('.dp-nav-prev-year', this.context).addClass('disabled'); | ||
| 1031 | $('.dp-nav-prev-month', this.context).addClass('disabled'); | ||
| 1032 | $('.dp-calendar td.other-month', this.context).each( | ||
| 1033 | function() | ||
| 1034 | { | ||
| 1035 | var $this = $(this); | ||
| 1036 | if (Number($this.text()) > 20) { | ||
| 1037 | $this.addClass('disabled'); | ||
| 1038 | } | ||
| 1039 | } | ||
| 1040 | ); | ||
| 1041 | var d = this.startDate.getDate(); | ||
| 1042 | $('.dp-calendar td.current-month', this.context).each( | ||
| 1043 | function() | ||
| 1044 | { | ||
| 1045 | var $this = $(this); | ||
| 1046 | if (Number($this.text()) < d) { | ||
| 1047 | $this.addClass('disabled'); | ||
| 1048 | } | ||
| 1049 | } | ||
| 1050 | ); | ||
| 1051 | } else { | ||
| 1052 | $('.dp-nav-prev-year', this.context).removeClass('disabled'); | ||
| 1053 | $('.dp-nav-prev-month', this.context).removeClass('disabled'); | ||
| 1054 | var d = this.startDate.getDate(); | ||
| 1055 | if (d > 20) { | ||
| 1056 | // check if the startDate is last month as we might need to add some disabled classes... | ||
| 1057 | var st = this.startDate.getTime(); | ||
| 1058 | var sd = new Date(st); | ||
| 1059 | sd.addMonths(1); | ||
| 1060 | if (this.displayedYear == sd.getFullYear() && this.displayedMonth == sd.getMonth()) { | ||
| 1061 | $('.dp-calendar td.other-month', this.context).each( | ||
| 1062 | function() | ||
| 1063 | { | ||
| 1064 | var $this = $(this); | ||
| 1065 | if (Date.fromString($this.data('datePickerDate')).getTime() < st) { | ||
| 1066 | $this.addClass('disabled'); | ||
| 1067 | } | ||
| 1068 | } | ||
| 1069 | ); | ||
| 1070 | } | ||
| 1071 | } | ||
| 1072 | } | ||
| 1073 | if (this.displayedYear == this.endDate.getFullYear() && this.displayedMonth == this.endDate.getMonth()) { | ||
| 1074 | $('.dp-nav-next-year', this.context).addClass('disabled'); | ||
| 1075 | $('.dp-nav-next-month', this.context).addClass('disabled'); | ||
| 1076 | $('.dp-calendar td.other-month', this.context).each( | ||
| 1077 | function() | ||
| 1078 | { | ||
| 1079 | var $this = $(this); | ||
| 1080 | if (Number($this.text()) < 14) { | ||
| 1081 | $this.addClass('disabled'); | ||
| 1082 | } | ||
| 1083 | } | ||
| 1084 | ); | ||
| 1085 | var d = this.endDate.getDate(); | ||
| 1086 | $('.dp-calendar td.current-month', this.context).each( | ||
| 1087 | function() | ||
| 1088 | { | ||
| 1089 | var $this = $(this); | ||
| 1090 | if (Number($this.text()) > d) { | ||
| 1091 | $this.addClass('disabled'); | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | ); | ||
| 1095 | } else { | ||
| 1096 | $('.dp-nav-next-year', this.context).removeClass('disabled'); | ||
| 1097 | $('.dp-nav-next-month', this.context).removeClass('disabled'); | ||
| 1098 | var d = this.endDate.getDate(); | ||
| 1099 | if (d < 13) { | ||
| 1100 | // check if the endDate is next month as we might need to add some disabled classes... | ||
| 1101 | var ed = new Date(this.endDate.getTime()); | ||
| 1102 | ed.addMonths(-1); | ||
| 1103 | if (this.displayedYear == ed.getFullYear() && this.displayedMonth == ed.getMonth()) { | ||
| 1104 | $('.dp-calendar td.other-month', this.context).each( | ||
| 1105 | function() | ||
| 1106 | { | ||
| 1107 | var $this = $(this); | ||
| 1108 | var cellDay = Number($this.text()); | ||
| 1109 | if (cellDay < 13 && cellDay > d) { | ||
| 1110 | $this.addClass('disabled'); | ||
| 1111 | } | ||
| 1112 | } | ||
| 1113 | ); | ||
| 1114 | } | ||
| 1115 | } | ||
| 1116 | } | ||
| 1117 | this._applyRenderCallbacks(); | ||
| 1118 | }, | ||
| 1119 | _closeCalendar : function(programatic, ele) | ||
| 1120 | { | ||
| 1121 | if (!ele || ele == this.ele) | ||
| 1122 | { | ||
| 1123 | $(document).unbind('mousedown.datepicker'); | ||
| 1124 | $(document).unbind('keydown.datepicker'); | ||
| 1125 | this._clearCalendar(); | ||
| 1126 | $('#dp-popup a').unbind(); | ||
| 1127 | $('#dp-popup').empty().remove(); | ||
| 1128 | if (!programatic) { | ||
| 1129 | $(this.ele).trigger('dpClosed', [this.getSelected()]); | ||
| 1130 | } | ||
| 1131 | } | ||
| 1132 | }, | ||
| 1133 | // empties the current dp-calendar div and makes sure that all events are unbound | ||
| 1134 | // and expandos removed to avoid memory leaks... | ||
| 1135 | _clearCalendar : function() | ||
| 1136 | { | ||
| 1137 | // TODO. | ||
| 1138 | $('.dp-calendar td', this.context).unbind(); | ||
| 1139 | $('.dp-calendar', this.context).empty(); | ||
| 1140 | } | ||
| 1141 | } | ||
| 1142 | ); | ||
| 1143 | |||
| 1144 | // static constants | ||
| 1145 | $.dpConst = { | ||
| 1146 | SHOW_HEADER_NONE : 0, | ||
| 1147 | SHOW_HEADER_SHORT : 1, | ||
| 1148 | SHOW_HEADER_LONG : 2, | ||
| 1149 | POS_TOP : 0, | ||
| 1150 | POS_BOTTOM : 1, | ||
| 1151 | POS_LEFT : 0, | ||
| 1152 | POS_RIGHT : 1, | ||
| 1153 | DP_INTERNAL_FOCUS : 'dpInternalFocusTrigger' | ||
| 1154 | }; | ||
| 1155 | // localisable text | ||
| 1156 | $.dpText = { | ||
| 1157 | TEXT_PREV_YEAR : 'Previous year', | ||
| 1158 | TEXT_PREV_MONTH : 'Previous month', | ||
| 1159 | TEXT_NEXT_YEAR : 'Next year', | ||
| 1160 | TEXT_NEXT_MONTH : 'Next month', | ||
| 1161 | TEXT_CLOSE : 'Close', | ||
| 1162 | TEXT_CHOOSE_DATE : 'Choose date', | ||
| 1163 | HEADER_FORMAT : 'mmmm yyyy' | ||
| 1164 | }; | ||
| 1165 | // version | ||
| 1166 | $.dpVersion = '$Id: jquery.datePicker.js 102 2010-09-13 14:00:54Z kelvin.luck $'; | ||
| 1167 | |||
| 1168 | $.fn.datePicker.defaults = { | ||
| 1169 | month : undefined, | ||
| 1170 | year : undefined, | ||
| 1171 | showHeader : $.dpConst.SHOW_HEADER_SHORT, | ||
| 1172 | startDate : undefined, | ||
| 1173 | endDate : undefined, | ||
| 1174 | inline : false, | ||
| 1175 | renderCallback : null, | ||
| 1176 | createButton : true, | ||
| 1177 | showYearNavigation : true, | ||
| 1178 | closeOnSelect : true, | ||
| 1179 | displayClose : false, | ||
| 1180 | selectMultiple : false, | ||
| 1181 | numSelectable : Number.MAX_VALUE, | ||
| 1182 | clickInput : false, | ||
| 1183 | rememberViewedMonth : true, | ||
| 1184 | selectWeek : false, | ||
| 1185 | verticalPosition : $.dpConst.POS_TOP, | ||
| 1186 | horizontalPosition : $.dpConst.POS_LEFT, | ||
| 1187 | verticalOffset : 0, | ||
| 1188 | horizontalOffset : 0, | ||
| 1189 | hoverClass : 'dp-hover', | ||
| 1190 | autoFocusNextInput : false | ||
| 1191 | }; | ||
| 1192 | |||
| 1193 | function _getController(ele) | ||
| 1194 | { | ||
| 1195 | if (ele._dpId) return $.event._dpCache[ele._dpId]; | ||
| 1196 | return false; | ||
| 1197 | }; | ||
| 1198 | |||
| 1199 | // make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional | ||
| 1200 | // comments to only include bgIframe where it is needed in IE without breaking this plugin). | ||
| 1201 | if ($.fn.bgIframe == undefined) { | ||
| 1202 | $.fn.bgIframe = function() {return this; }; | ||
| 1203 | }; | ||
| 1204 | |||
| 1205 | |||
| 1206 | // clean-up | ||
| 1207 | $(window) | ||
| 1208 | .bind('unload', function() { | ||
| 1209 | var els = $.event._dpCache || []; | ||
| 1210 | for (var i in els) { | ||
| 1211 | $(els[i].ele)._dpDestroy(); | ||
| 1212 | } | ||
| 1213 | }); | ||
| 1214 | |||
| 1215 | |||
| 1216 | })(jQuery); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/UserManager.js
0 → 100644
| 1 | jQuery(function() { | ||
| 2 | |||
| 3 | Date.firstDayOfWeek = 0; | ||
| 4 | Date.format = 'yyyy-mm-dd'; | ||
| 5 | |||
| 6 | if (jQuery('.datepicker').length > 0) { | ||
| 7 | jQuery('.datepicker').datePicker( | ||
| 8 | { | ||
| 9 | startDate: '1920-01-01', | ||
| 10 | endDate: (new Date()).asString() | ||
| 11 | } | ||
| 12 | ); | ||
| 13 | } | ||
| 14 | |||
| 15 | jQuery('#admin-edit-user-profile').ajaxForm({ | ||
| 16 | url: '/wp-admin/admin-ajax.php' | ||
| 17 | , data: ({ajax:"yes", action: 'update_edit_profile'}) | ||
| 18 | , dataType: 'json' | ||
| 19 | , type: 'post' | ||
| 20 | , beforeSubmit: function(formData, jqForm, options) { | ||
| 21 | var $error_container = jQuery('.validation-errors'); | ||
| 22 | $error_container.hide(); | ||
| 23 | } | ||
| 24 | , success: function(data) { | ||
| 25 | if (data.success == "true") { | ||
| 26 | jQuery('.update-placeholder').html('Update Successful.'); | ||
| 27 | } else { | ||
| 28 | //$('.register-form :input').removeAttr('disabled'); | ||
| 29 | var $error_container = jQuery('.validation-errors'); | ||
| 30 | jQuery('h6',$error_container).html("OOPS..."); | ||
| 31 | jQuery('ul',$error_container).html(data.msg); | ||
| 32 | $error_container.show(); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | , error: function(XMLHttpRequest, textStatus, errorThrown) { | ||
| 36 | var $error_container = jQuery('.validation-errors'); | ||
| 37 | jQuery('h6',$error_container).html("A server error has occurred."); | ||
| 38 | jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>"); | ||
| 39 | $error_container.show(); | ||
| 40 | } | ||
| 41 | }); | ||
| 42 | |||
| 43 | // overview ajaxForm... | ||
| 44 | jQuery('#overview_form').ajaxForm({ | ||
| 45 | url: '/wp-admin/admin-ajax.php' | ||
| 46 | , data: ({ajax:"yes", action: 'update_account'}) | ||
| 47 | , dataType: 'json' | ||
| 48 | , type: 'post' | ||
| 49 | , beforeSubmit: function(formData, jqForm, options) { | ||
| 50 | var $error_container = jQuery('.validation-errors'); | ||
| 51 | $error_container.hide(); | ||
| 52 | } | ||
| 53 | , success: function(data) { | ||
| 54 | |||
| 55 | if (data.success == "true") { | ||
| 56 | jQuery('.update-placeholder').html('Update Successful.'); | ||
| 57 | } else { | ||
| 58 | //$('.register-form :input').removeAttr('disabled'); | ||
| 59 | var $error_container = jQuery('.validation-errors'); | ||
| 60 | jQuery('h6',$error_container).html("OOPS..."); | ||
| 61 | jQuery('ul',$error_container).html(data.msg); | ||
| 62 | $error_container.show(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | , error: function(XMLHttpRequest, textStatus, errorThrown) { | ||
| 66 | var $error_container = jQuery('.validation-errors'); | ||
| 67 | jQuery('h6',$error_container).html("A server error has occurred."); | ||
| 68 | jQuery('ul',$error_container).html("<li>"+errorThrown+"</li>"); | ||
| 69 | $error_container.show(); | ||
| 70 | } | ||
| 71 | }); | ||
| 72 | |||
| 73 | jQuery('.event-edit').colorbox({onComplete: function() { | ||
| 74 | var cb = this; | ||
| 75 | var options = { | ||
| 76 | beforeSubmit: function() {} | ||
| 77 | , success: function(data) { | ||
| 78 | |||
| 79 | if (data.refresh == "true") { | ||
| 80 | document.location.href = document.location.href; | ||
| 81 | } else { | ||
| 82 | jQuery.colorbox.close(); | ||
| 83 | } | ||
| 84 | |||
| 85 | } | ||
| 86 | , data: ({ajax:"yes", action: 'update_registration'}) | ||
| 87 | , dataType: 'json' | ||
| 88 | , url: '/wp-admin/admin-ajax.php' | ||
| 89 | }; | ||
| 90 | jQuery('#edit-event-form').ajaxForm(options); | ||
| 91 | }}); | ||
| 92 | |||
| 93 | jQuery('#admin_add_new_cehours').colorbox({onComplete: function() { | ||
| 94 | jQuery('.datepicker').datePicker( | ||
| 95 | { | ||
| 96 | startDate: '1920-01-01', | ||
| 97 | endDate: (new Date()).asString() | ||
| 98 | } | ||
| 99 | ); | ||
| 100 | |||
| 101 | var options = { | ||
| 102 | success: function(data) { | ||
| 103 | document.location.href = document.location.href; | ||
| 104 | } | ||
| 105 | , data: ({ajax:"yes", action: 'admin_update_cehours'}) | ||
| 106 | , dataType: 'json' | ||
| 107 | , url: '/wp-admin/admin-ajax.php' | ||
| 108 | }; | ||
| 109 | jQuery('#edit-cehours-form').ajaxForm(options); | ||
| 110 | |||
| 111 | }}); | ||
| 112 | |||
| 113 | |||
| 114 | jQuery('.cehours-edit').colorbox({onComplete: function() { | ||
| 115 | jQuery('.datepicker').datePicker( | ||
| 116 | { | ||
| 117 | startDate: '1920-01-01', | ||
| 118 | endDate: (new Date()).asString() | ||
| 119 | } | ||
| 120 | ); | ||
| 121 | |||
| 122 | var options = { | ||
| 123 | success: function(data) { | ||
| 124 | document.location.href = document.location.href; | ||
| 125 | } | ||
| 126 | , data: ({ajax:"yes", action: 'admin_update_cehours'}) | ||
| 127 | , dataType: 'json' | ||
| 128 | , url: '/wp-admin/admin-ajax.php' | ||
| 129 | }; | ||
| 130 | jQuery('#edit-cehours-form').ajaxForm(options); | ||
| 131 | |||
| 132 | }}); | ||
| 133 | |||
| 134 | |||
| 135 | jQuery('.cehours-remove').click(function(e) { | ||
| 136 | |||
| 137 | var ds = jQuery(this).attr('rel'); | ||
| 138 | |||
| 139 | jConfirm('Are you sure?', 'Remove CE Hours?', function(c) { | ||
| 140 | if (c) { | ||
| 141 | jQuery.ajax({ | ||
| 142 | url: '/wp-admin/admin-ajax.php' | ||
| 143 | , data: ({ajax:"yes", action: 'admin_remove_cehours', uid:user_id, indexed: ds}) | ||
| 144 | , type: 'post' | ||
| 145 | , dataType: 'json' | ||
| 146 | , success: function(data) { | ||
| 147 | document.location.href = document.location.href; | ||
| 148 | } | ||
| 149 | }); | ||
| 150 | } | ||
| 151 | }); | ||
| 152 | |||
| 153 | e.preventDefault(); | ||
| 154 | return false; | ||
| 155 | |||
| 156 | }); | ||
| 157 | |||
| 158 | jQuery('.event-cancel').click(function(e) { | ||
| 159 | var eventcontainer = jQuery(this).parent(); | ||
| 160 | var link = jQuery(this); | ||
| 161 | |||
| 162 | jConfirm('Are you sure?', 'Cancel Registration', function(c) { | ||
| 163 | |||
| 164 | if (c) { | ||
| 165 | eventcontainer.empty().addClass('spinner'); | ||
| 166 | |||
| 167 | jQuery.ajax({ | ||
| 168 | url: '/wp-admin/admin-ajax.php' | ||
| 169 | , data: ({ajax:"yes", action: 'cancel_registration', uid: user_id, eid: link.attr('rel')}) | ||
| 170 | , type: 'post' | ||
| 171 | , success: function(data) { | ||
| 172 | |||
| 173 | if (data.ask_credit=="true") { | ||
| 174 | // ask if they want to credit.... | ||
| 175 | jPrompt('How much (if any) would you like to credit their account?', '0.00', 'Registration has been cancelled', function(r) { | ||
| 176 | if( r ) { | ||
| 177 | jQuery.ajax({ | ||
| 178 | url: '/wp-admin/admin-ajax.php' | ||
| 179 | , data: ({ajax:"yes", action: 'post_credit', uid:user_id, post_id: link.attr('rel'), amount:r}) | ||
| 180 | , type: 'POST' | ||
| 181 | , dataType: 'json' | ||
| 182 | }); | ||
| 183 | } | ||
| 184 | document.location.href = document.location.href; | ||
| 185 | }); | ||
| 186 | } else { | ||
| 187 | document.location.href = document.location.href; | ||
| 188 | } | ||
| 189 | |||
| 190 | } | ||
| 191 | , dataType: 'json' | ||
| 192 | }); | ||
| 193 | |||
| 194 | } | ||
| 195 | |||
| 196 | }); | ||
| 197 | |||
| 198 | e.preventDefault(); | ||
| 199 | return false; | ||
| 200 | }); | ||
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | }); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/UserManager.php
0 → 100644
| 1 | <?php | ||
| 2 | /* | ||
| 3 | Plugin Name: CBV User Manager | ||
| 4 | Description: All-In-One User Management for CBV | ||
| 5 | Version: 1.0 | ||
| 6 | Author: Tenzing Communications Inc. | ||
| 7 | Author URI: http://www.gotenzing.com | ||
| 8 | */ | ||
| 9 | namespace Tz\WordPress\Tools\UserManager; | ||
| 10 | |||
| 11 | use Tz\Common; | ||
| 12 | use Tz\WordPress\Tools; | ||
| 13 | use Tz\WordPress\Tools\Auth; | ||
| 14 | use Tz\WordPress\UAM; | ||
| 15 | use Tz\WordPress\CBV; | ||
| 16 | use Tz\WordPress\CBV\User; | ||
| 17 | use Tz\WordPress\CBV\Events; | ||
| 18 | use Tz\WordPress\CBV\CEHours; | ||
| 19 | use Exception, StdClass; | ||
| 20 | use WP_User; | ||
| 21 | |||
| 22 | const OPTION_NAME = "user_options"; | ||
| 23 | const CAPABILITY = "manage_cbv_users"; | ||
| 24 | |||
| 25 | CBV\load('User'); | ||
| 26 | |||
| 27 | |||
| 28 | call_user_func(function() { | ||
| 29 | $role = get_role('administrator'); | ||
| 30 | $role->add_cap(CAPABILITY); | ||
| 31 | Tools\add_actions(__NAMESPACE__ . '\Actions'); | ||
| 32 | |||
| 33 | Vars::$validation = new StdClass; | ||
| 34 | Vars::$validation->errors = Array(); | ||
| 35 | }); | ||
| 36 | |||
| 37 | function display_users() { | ||
| 38 | |||
| 39 | if ( isset($_GET['action']) && ($_GET['action']=="edit") && isset($_GET['uid']) && ($_GET['uid'] > 0) ) { | ||
| 40 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'edit_user.php'); | ||
| 41 | } elseif (isset($_GET['action']) && $_GET['action']=="edit-partial") { | ||
| 42 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_'.$_GET['section'].'.php'); | ||
| 43 | } else { | ||
| 44 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'display_users.php'); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | function search_special_status($key) { | ||
| 49 | $special_statuses = get_user_meta($_GET['uid'], 'special_statuses',true); | ||
| 50 | if (!empty($special_statuses)) { | ||
| 51 | foreach($special_statuses as $stat) { | ||
| 52 | if ($stat == $key) { | ||
| 53 | echo 'checked'; | ||
| 54 | break; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | function get_users() { | ||
| 61 | global $wpdb; | ||
| 62 | |||
| 63 | $users = array(); | ||
| 64 | |||
| 65 | $wp_user_search = $wpdb->get_results("SELECT ID, display_name,user_login,user_email FROM $wpdb->users ORDER BY ID"); | ||
| 66 | foreach ( $wp_user_search as $user ) { | ||
| 67 | $uid = (int) $user->ID; | ||
| 68 | |||
| 69 | $user = new WP_User($uid); | ||
| 70 | |||
| 71 | $user_login = $user->user_login; | ||
| 72 | $name = get_user_meta($uid,'first_name',true) . " " . get_user_meta($uid, 'last_name',true); | ||
| 73 | |||
| 74 | reset($user->roles); | ||
| 75 | $role = ucwords(current($user->roles)); | ||
| 76 | |||
| 77 | $users[] = array('uid'=>$uid,'name'=>$name,'role'=>$role, 'user_login'=>$user_login, 'email'=>$user->user_email); | ||
| 78 | } | ||
| 79 | return $users; | ||
| 80 | } | ||
| 81 | |||
| 82 | function create_user() { | ||
| 83 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create_user.php'); | ||
| 84 | } | ||
| 85 | |||
| 86 | class ProfileValidation extends Common\Validation { | ||
| 87 | |||
| 88 | public function prefix($val) { | ||
| 89 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 90 | } | ||
| 91 | |||
| 92 | public function first_name($val) { | ||
| 93 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 94 | } | ||
| 95 | |||
| 96 | public function initial($val) { | ||
| 97 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 98 | } | ||
| 99 | |||
| 100 | public function last_name($val) { | ||
| 101 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 102 | } | ||
| 103 | |||
| 104 | public function degrees($val) { | ||
| 105 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 106 | } | ||
| 107 | |||
| 108 | public function description($val) { | ||
| 109 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 110 | } | ||
| 111 | |||
| 112 | public function date_of_birth($val) { | ||
| 113 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 114 | } | ||
| 115 | |||
| 116 | public function address($val) { | ||
| 117 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 118 | } | ||
| 119 | |||
| 120 | public function address2($val) { | ||
| 121 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 122 | } | ||
| 123 | |||
| 124 | public function city($val) { | ||
| 125 | update_user_meta($_POST['uid'], __FUNCTION__, User\clean_string($val)); | ||
| 126 | } | ||
| 127 | |||
| 128 | public function province($val) { | ||
| 129 | if (empty($val)) { | ||
| 130 | throw new Exception('Province field can not be empty'); | ||
| 131 | } | ||
| 132 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 133 | } | ||
| 134 | |||
| 135 | public function postal($val) { | ||
| 136 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 137 | } | ||
| 138 | |||
| 139 | public function country($val) { | ||
| 140 | if (empty($val)) { | ||
| 141 | throw new Exception('Country field can not be empty'); | ||
| 142 | } | ||
| 143 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 144 | } | ||
| 145 | |||
| 146 | public function phone($val) { | ||
| 147 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 148 | } | ||
| 149 | |||
| 150 | public function fax($val) { | ||
| 151 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 152 | } | ||
| 153 | |||
| 154 | public function mobile($val) { | ||
| 155 | update_user_meta($_POST['uid'], __FUNCTION__, $val); | ||
| 156 | } | ||
| 157 | |||
| 158 | public function email($val) { | ||
| 159 | if (!empty($val)) { | ||
| 160 | if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) { | ||
| 161 | throw new Exception('An invalid email address was entered in Email'); | ||
| 162 | } | ||
| 163 | } else { | ||
| 164 | throw new Exception('Email field can not be empty'); | ||
| 165 | } | ||
| 166 | update_user_meta($_POST['uid'], 'email', $val); | ||
| 167 | } | ||
| 168 | |||
| 169 | public function company($val) { | ||
| 170 | update_user_meta($_POST['uid'],'company', User\clean_string($val)); | ||
| 171 | } | ||
| 172 | |||
| 173 | public function title($val) { | ||
| 174 | update_user_meta($_POST['uid'], 'title', User\clean_string($val)); | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 178 | public function website($val) { | ||
| 179 | |||
| 180 | if (!empty($val)) { | ||
| 181 | |||
| 182 | if (substr($val, 0, 7) != 'http://' && substr($val, 0, 8) != 'https://') { | ||
| 183 | $val = 'http://' . $val; | ||
| 184 | } | ||
| 185 | |||
| 186 | if (!(boolean)filter_var($val, FILTER_VALIDATE_URL)) { | ||
| 187 | throw new Exception('An invalid url was entered in website'); | ||
| 188 | } | ||
| 189 | } | ||
| 190 | update_user_meta($_POST['uid'], 'website', User\clean_string($val)); | ||
| 191 | } | ||
| 192 | |||
| 193 | public function profile_preference($val) { | ||
| 194 | update_user_meta($_POST['uid'], 'profile_preference', $val); | ||
| 195 | } | ||
| 196 | |||
| 197 | public function email_address_preference($val) { | ||
| 198 | update_user_meta($_POST['uid'], 'email_address_preference', $val); | ||
| 199 | } | ||
| 200 | |||
| 201 | |||
| 202 | } | ||
| 203 | |||
| 204 | class AccountValidation extends Common\Validation { | ||
| 205 | |||
| 206 | public function status($val) { | ||
| 207 | update_user_meta($_POST['uid'], 'status',$val); | ||
| 208 | } | ||
| 209 | |||
| 210 | public function special_status_active($vals) { | ||
| 211 | delete_usermeta($_POST['uid'], 'special_statuses'); | ||
| 212 | if (isset($_POST['special_status'])) { | ||
| 213 | $s = $_POST['special_status']; | ||
| 214 | if (count($s) > 0) { | ||
| 215 | update_user_meta($_POST['uid'], 'special_statuses', $s); | ||
| 216 | } | ||
| 217 | |||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | public function user_role($val) { | ||
| 222 | $user = new WP_User($_POST['uid']); | ||
| 223 | try { | ||
| 224 | $user->set_role($val); | ||
| 225 | } catch (Exception $e) { | ||
| 226 | throw new Exception($e->getMessage()); | ||
| 227 | } | ||
| 228 | } | ||
| 229 | |||
| 230 | public function password1($val) { | ||
| 231 | if (!empty($_POST['password1']) || !empty($_POST['password2'])) { | ||
| 232 | if ($_POST['password1']==$_POST['password2']) { | ||
| 233 | // update the user's password... | ||
| 234 | _update_user(Array('ID' => $_POST['uid'], 'user_pass' => $_POST['password1'])); | ||
| 235 | } else { | ||
| 236 | throw new Exception('Passwords must match.'); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | } | ||
| 242 | |||
| 243 | class CreateValidation extends Common\Validation { | ||
| 244 | |||
| 245 | |||
| 246 | public function first_name($val) { | ||
| 247 | if(empty($val)) { | ||
| 248 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 252 | public function last_name($val) { | ||
| 253 | if(empty($val)) { | ||
| 254 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | public function username($val) { | ||
| 259 | if(empty($val)) { | ||
| 260 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 261 | } | ||
| 262 | } | ||
| 263 | |||
| 264 | public function email($val) { | ||
| 265 | if (!empty($val)) { | ||
| 266 | if (!(boolean)preg_match(CBV\VALID_EMAIL, (string)$val)) { | ||
| 267 | throw new Exception('An invalid email address was entered in ' . User\Vars::$field_lookup[__FUNCTION__]); | ||
| 268 | } | ||
| 269 | } else { | ||
| 270 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' field can not be empty'); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | |||
| 274 | public function country($val) { | ||
| 275 | if(empty($val)) { | ||
| 276 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 277 | } | ||
| 278 | } | ||
| 279 | |||
| 280 | public function province($val) { | ||
| 281 | if(empty($val)) { | ||
| 282 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | |||
| 286 | public function user_role($val) { | ||
| 287 | if(empty($val)) { | ||
| 288 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | public function password($val) { | ||
| 293 | if(!empty($val)) { | ||
| 294 | if ($_POST['password'] != $_POST['password2']) { | ||
| 295 | throw new Exception('Passwords do not match'); | ||
| 296 | } | ||
| 297 | } else { | ||
| 298 | throw new Exception(User\Vars::$field_lookup[__FUNCTION__] . ' cannot be blank'); | ||
| 299 | } | ||
| 300 | } | ||
| 301 | |||
| 302 | } | ||
| 303 | |||
| 304 | function run_validation() { | ||
| 305 | $section = $_POST['section']; | ||
| 306 | $class = __NAMESPACE__ . '\\' . ucwords(array_shift(explode('-', $section))) . 'Validation'; | ||
| 307 | |||
| 308 | Vars::$validation = new $class($_POST); | ||
| 309 | return (count(Vars::$validation->errors) > 0 ? false : true); | ||
| 310 | } | ||
| 311 | |||
| 312 | class Actions { | ||
| 313 | |||
| 314 | |||
| 315 | public static function wp_ajax_admin_create_user() { | ||
| 316 | run_validation(); | ||
| 317 | |||
| 318 | Tools\import('Auth'); | ||
| 319 | |||
| 320 | $valid = (count(Vars::$validation->errors) > 0) ? false : true; | ||
| 321 | if ($valid) { | ||
| 322 | |||
| 323 | $user_role = $_POST['user_role']; unset($_POST['user_role']); | ||
| 324 | $username = $_POST['username']; unset($_POST['username']); | ||
| 325 | $email = $_POST['email']; unset($_POST['email']); | ||
| 326 | if ($user_role != "member") { unset($_POST['member_id']); } | ||
| 327 | $password = $_POST['password']; unset($_POST['password']); unset($_POST['password2']); | ||
| 328 | |||
| 329 | // register the user. | ||
| 330 | $user_details = Array( | ||
| 331 | 'first_name' => User\clean_string($_POST['first_name']) | ||
| 332 | , 'last_name' => User\clean_string($_POST['last_name']) | ||
| 333 | , 'province' => $_POST['province'] | ||
| 334 | , 'country' => $_POST['country'] | ||
| 335 | , 'email' => $email | ||
| 336 | ); | ||
| 337 | |||
| 338 | if (isset($_POST['member_id'])) { $user_details['member_id'] = $_POST['member_id']; } | ||
| 339 | $user_details = array_merge(User\Vars::$meta_defaults, $user_details); | ||
| 340 | |||
| 341 | try { | ||
| 342 | $user_key = Auth\register($username, $email, $password, $user_details); | ||
| 343 | $uid = Auth\activate($user_key, $password); | ||
| 344 | $u = new WP_User($uid); | ||
| 345 | $u->set_role($user_role); | ||
| 346 | update_user_meta($uid, 'validated', time()); | ||
| 347 | } catch (Exception $e) { | ||
| 348 | $return = array( | ||
| 349 | 'success' => false | ||
| 350 | , 'msg' => $e->getMessage() | ||
| 351 | ); | ||
| 352 | die(json_encode($return)); | ||
| 353 | } | ||
| 354 | |||
| 355 | $return = array( | ||
| 356 | 'success' => 'true' | ||
| 357 | , 'edit_profile' => '/wp-admin/admin.php?page=cbv_users&action=edit&uid='.$uid.'§ion=profile' | ||
| 358 | , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>' | ||
| 359 | ); | ||
| 360 | |||
| 361 | } else { | ||
| 362 | $return = array( | ||
| 363 | 'success' => 'false' | ||
| 364 | , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>' | ||
| 365 | ); | ||
| 366 | } | ||
| 367 | |||
| 368 | die(json_encode($return)); | ||
| 369 | } | ||
| 370 | |||
| 371 | public static function wp_ajax_admin_create_member_id() { | ||
| 372 | |||
| 373 | // do logic here to create the user's member id. | ||
| 374 | $member_id = $_POST['last_name'] . time(); | ||
| 375 | |||
| 376 | $return = array( | ||
| 377 | 'member_id' => $member_id | ||
| 378 | ); | ||
| 379 | die(json_encode($return)); | ||
| 380 | } | ||
| 381 | |||
| 382 | public static function wp_ajax_admin_remove_cehours() { | ||
| 383 | CBV\load('CEHours'); | ||
| 384 | $cehours = CEHours\get_user_cehours($_POST['uid']); | ||
| 385 | $compare = $_POST['indexed']; | ||
| 386 | |||
| 387 | if (isset($cehours[$compare])) { | ||
| 388 | unset($cehours[$compare]); | ||
| 389 | } | ||
| 390 | |||
| 391 | update_user_meta($_POST['uid'], 'cehours',$cehours); | ||
| 392 | |||
| 393 | $return = array( | ||
| 394 | 'success' => 'true' | ||
| 395 | ); | ||
| 396 | die(json_encode($return)); | ||
| 397 | } | ||
| 398 | |||
| 399 | public static function wp_ajax_update_edit_profile() { | ||
| 400 | |||
| 401 | run_validation(); | ||
| 402 | |||
| 403 | $return = array( | ||
| 404 | 'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true') | ||
| 405 | , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>' | ||
| 406 | ); | ||
| 407 | |||
| 408 | die(json_encode($return)); | ||
| 409 | } | ||
| 410 | |||
| 411 | public static function wp_ajax_cancel_registration() { | ||
| 412 | |||
| 413 | CBV\load('Events'); | ||
| 414 | Events\cancel_registration($_POST['uid'], $_POST['eid']); | ||
| 415 | |||
| 416 | $event = get_post($_POST['eid']); | ||
| 417 | $cost = get_post_meta($_POST['eid'], 'cost', true); | ||
| 418 | if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { | ||
| 419 | $cost = 0; | ||
| 420 | } | ||
| 421 | |||
| 422 | $return = array( | ||
| 423 | 'success' => 'true', | ||
| 424 | 'ask_credit' => (($cost > 0) ? 'true' : 'false') | ||
| 425 | ); | ||
| 426 | die(json_encode($return)); | ||
| 427 | } | ||
| 428 | |||
| 429 | public static function wp_ajax_update_account() { | ||
| 430 | run_validation(); | ||
| 431 | |||
| 432 | $return = array( | ||
| 433 | 'success' => (count(Vars::$validation->errors) > 0 ? 'false' : 'true') | ||
| 434 | , 'msg' => '<li>' . implode('</li><li>', Vars::$validation->errors) . '</li>' | ||
| 435 | ); | ||
| 436 | |||
| 437 | die(json_encode($return)); | ||
| 438 | } | ||
| 439 | |||
| 440 | public static function wp_ajax_post_credit() { | ||
| 441 | |||
| 442 | $uid = $_POST['uid']; | ||
| 443 | $post_id = $_POST['event_id']; // could be an event, or a course. | ||
| 444 | $amount = $_POST['amount']; | ||
| 445 | |||
| 446 | |||
| 447 | // post credit to their account. | ||
| 448 | |||
| 449 | |||
| 450 | // return json object | ||
| 451 | $return = array( | ||
| 452 | 'success' => 'true' | ||
| 453 | ); | ||
| 454 | die(json_encode($return)); | ||
| 455 | |||
| 456 | } | ||
| 457 | |||
| 458 | |||
| 459 | |||
| 460 | public static function wp_ajax_update_registration() { | ||
| 461 | |||
| 462 | CBV\load('Events'); | ||
| 463 | |||
| 464 | if (!isset($_POST['type'])) { die('Invalid Form Post'); } | ||
| 465 | |||
| 466 | $uid = $_POST['uid']; | ||
| 467 | $event_id = $_POST['event_id']; | ||
| 468 | $type = $_POST['type']; | ||
| 469 | $status = $_POST['status']; | ||
| 470 | |||
| 471 | unset($_POST['action']); | ||
| 472 | unset($_POST['ajax']); | ||
| 473 | unset($_POST['event_id']); | ||
| 474 | unset($_POST['uid']); | ||
| 475 | unset($_POST['type']); | ||
| 476 | unset($_POST['status']); | ||
| 477 | |||
| 478 | $events = get_user_meta($uid, 'events',true); | ||
| 479 | |||
| 480 | // if $type = "edit" | ||
| 481 | if ($type=="edit") { | ||
| 482 | |||
| 483 | foreach($events as $index=>$event) { | ||
| 484 | if ($event['event_id']==$event_id) { | ||
| 485 | $events[$index]['status'] = $status; | ||
| 486 | unset($events[$index]['extras']); | ||
| 487 | $events[$index]['extras'] = $_POST; | ||
| 488 | break; | ||
| 489 | } | ||
| 490 | } | ||
| 491 | update_user_meta($uid, 'events', $events); | ||
| 492 | $return = array('success' => 'true', 'refresh' => 'false'); | ||
| 493 | |||
| 494 | } else { | ||
| 495 | Events\set_attending($uid,$event_id,$status,'',$_POST); | ||
| 496 | $return = array('success' => 'true', 'refresh' => 'true'); | ||
| 497 | } | ||
| 498 | |||
| 499 | die(json_encode($return)); | ||
| 500 | |||
| 501 | } | ||
| 502 | |||
| 503 | public static function wp_ajax_admin_update_cehours() { | ||
| 504 | CBV\load('CEHours'); | ||
| 505 | $cehours = CEHours\get_user_cehours($_POST['uid']); | ||
| 506 | if ($_POST['action']=="edit") { | ||
| 507 | unset($cehours[$_POST['indexed']]); | ||
| 508 | } | ||
| 509 | |||
| 510 | $timestamp = CEHours\mysqldatetime_to_timestamp($_POST['date']); | ||
| 511 | |||
| 512 | |||
| 513 | $cehours[$timestamp] = Array( | ||
| 514 | 'type' => $_POST['type'] | ||
| 515 | , 'date' => $timestamp | ||
| 516 | , 'activity' => $_POST['activity'] | ||
| 517 | , 'hours' => $_POST['hours'] | ||
| 518 | ); | ||
| 519 | |||
| 520 | update_user_meta($_POST['uid'], 'cehours', $cehours); | ||
| 521 | // return json object | ||
| 522 | $return = array( | ||
| 523 | 'success' => 'true' | ||
| 524 | ); | ||
| 525 | die(json_encode($return)); | ||
| 526 | |||
| 527 | } | ||
| 528 | |||
| 529 | public static function wp_ajax_build_cehour_form() { | ||
| 530 | $user = new WP_User($_GET['uid']); | ||
| 531 | $uid = $user->ID; | ||
| 532 | |||
| 533 | $fname = get_user_meta($user->ID, 'first_name', true); | ||
| 534 | $lname = get_user_meta($user->ID, 'last_name', true); | ||
| 535 | |||
| 536 | if (empty($fname) || empty($lname)) { | ||
| 537 | $name = $user->user_login; | ||
| 538 | } else { | ||
| 539 | $name = $fname . " " . $lname; | ||
| 540 | } | ||
| 541 | |||
| 542 | CBV\load('CEHours'); | ||
| 543 | ob_start(); | ||
| 544 | $action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit"; | ||
| 545 | $cehours = CEHours\get_user_cehours($uid); | ||
| 546 | |||
| 547 | if ($action=="edit") { | ||
| 548 | $record = $cehours[$_GET['indexed']]; | ||
| 549 | $indexed = $_GET['indexed']; | ||
| 550 | $type = $record['type']; | ||
| 551 | $date = date('Y-m-d',$record['date']); | ||
| 552 | $activity = $record['activity']; | ||
| 553 | $hours = $record['hours']; | ||
| 554 | } else { | ||
| 555 | $indexed = ""; | ||
| 556 | $type = "unstructured"; | ||
| 557 | $date = date('Y-m-d',time()); | ||
| 558 | $activity = ""; | ||
| 559 | $hours = "0"; | ||
| 560 | } | ||
| 561 | |||
| 562 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_cehour.php'); | ||
| 563 | |||
| 564 | $content = ob_get_contents(); | ||
| 565 | ob_end_clean(); | ||
| 566 | die($content); | ||
| 567 | |||
| 568 | } | ||
| 569 | |||
| 570 | public static function wp_ajax_build_event_form() { | ||
| 571 | |||
| 572 | $user = new WP_User($_GET['uid']); | ||
| 573 | $uid = $user->ID; | ||
| 574 | reset($user->roles); | ||
| 575 | $role = current($user->roles); | ||
| 576 | |||
| 577 | $fname = get_user_meta($user->ID, 'first_name', true); | ||
| 578 | $lname = get_user_meta($user->ID, 'last_name', true); | ||
| 579 | |||
| 580 | if (empty($fname) || empty($lname)) { | ||
| 581 | $name = $user->user_login; | ||
| 582 | } else { | ||
| 583 | $name = $fname . " " . $lname; | ||
| 584 | } | ||
| 585 | |||
| 586 | |||
| 587 | CBV\load('Events'); | ||
| 588 | ob_start(); | ||
| 589 | |||
| 590 | $action = isset($_GET['post_action']) ? $_GET['post_action'] : "edit"; | ||
| 591 | |||
| 592 | if ($action=="edit") { | ||
| 593 | $user_event_meta = Events\get_event_registration($_GET['event_id'], $_GET['uid']); | ||
| 594 | } else { | ||
| 595 | $user_event_meta = Array(); | ||
| 596 | } | ||
| 597 | |||
| 598 | $post = Events\get_event($_GET['event_id']); | ||
| 599 | |||
| 600 | $show_dietary = get_post_meta($post->ID, 'show_dietary', true); | ||
| 601 | |||
| 602 | $session_description = get_post_meta($post->ID, 'session_description', true); | ||
| 603 | $session_one = get_post_meta($post->ID, 'session_one', true); | ||
| 604 | $session_two = get_post_meta($post->ID, 'session_two', true); | ||
| 605 | $session_three = get_post_meta($post->ID, 'session_three', true); | ||
| 606 | $session_four = get_post_meta($post->ID, 'session_four', true); | ||
| 607 | $session_five = get_post_meta($post->ID, 'session_five', true); | ||
| 608 | $session_six = get_post_meta($post->ID, 'session_six', true); | ||
| 609 | $session_seven = get_post_meta($post->ID, 'session_seven', true); | ||
| 610 | $session_eight = get_post_meta($post->ID, 'session_eight', true); | ||
| 611 | $session_nine = get_post_meta($post->ID, 'session_nine', true); | ||
| 612 | $session_ten = get_post_meta($post->ID, 'session_ten', true); | ||
| 613 | |||
| 614 | $mealopt_description = get_post_meta($post->ID, 'mealopt_description', true); | ||
| 615 | $mealopt_one = get_post_meta($post->ID, 'mealopt_one', true); | ||
| 616 | $mealopt_two = get_post_meta($post->ID, 'mealopt_two', true); | ||
| 617 | $mealopt_three = get_post_meta($post->ID, 'mealopt_three', true); | ||
| 618 | $mealopt_four = get_post_meta($post->ID, 'mealopt_four', true); | ||
| 619 | |||
| 620 | $mealopt_five = get_post_meta($post->ID, 'mealopt_five', true); | ||
| 621 | $mealopt_six = get_post_meta($post->ID, 'mealopt_six', true); | ||
| 622 | $mealopt_seven = get_post_meta($post->ID, 'mealopt_seven', true); | ||
| 623 | $mealopt_eight = get_post_meta($post->ID, 'mealopt_eight', true); | ||
| 624 | $mealopt_nine = get_post_meta($post->ID, 'mealopt_nine', true); | ||
| 625 | $mealopt_ten = get_post_meta($post->ID, 'mealopt_ten', true); | ||
| 626 | |||
| 627 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'partials' . DIRECTORY_SEPARATOR . 'edit_event.php'); | ||
| 628 | |||
| 629 | $content = ob_get_contents(); | ||
| 630 | ob_end_clean(); | ||
| 631 | die($content); | ||
| 632 | |||
| 633 | |||
| 634 | } | ||
| 635 | |||
| 636 | public static function admin_menu() { | ||
| 637 | add_menu_page('CBV Users','CBV Users',CAPABILITY,'cbv_users',__NAMESPACE__ . '\display_users' ); | ||
| 638 | add_submenu_page('cbv_users','New User', 'New User',CAPABILITY,'cbv_users_create',__NAMESPACE__ . '\create_user'); | ||
| 639 | } | ||
| 640 | |||
| 641 | public static function admin_init() { | ||
| 642 | register_setting(OPTION_NAME, OPTION_NAME); | ||
| 643 | } | ||
| 644 | |||
| 645 | |||
| 646 | } | ||
| 647 | |||
| 648 | class Vars { | ||
| 649 | public static $validation; | ||
| 650 | } | ||
| 651 | |||
| 652 | ?> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/create_user.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\UAM; | ||
| 7 | use Tz\WordPress\Tools; | ||
| 8 | use Tz\WordPress\Tools\HTML; | ||
| 9 | use Exception, StdClass; | ||
| 10 | use WP_User, WP_Roles; | ||
| 11 | |||
| 12 | Tools\import('HTML'); | ||
| 13 | |||
| 14 | $rc = new WP_Roles(); | ||
| 15 | $roles = $rc->role_names; | ||
| 16 | ksort($roles); | ||
| 17 | unset($rc, $roles['administrator']); | ||
| 18 | |||
| 19 | ?> | ||
| 20 | |||
| 21 | <style> | ||
| 22 | |||
| 23 | #post-body { | ||
| 24 | -moz-border-radius-bottomleft:6px; | ||
| 25 | -moz-border-radius-bottomright:6px; | ||
| 26 | -moz-border-radius-topright:6px; | ||
| 27 | -moz-border-radius-topleft:6px; | ||
| 28 | background:none repeat scroll 0 0 #FFFFFF; | ||
| 29 | border-width:1px 1px 1px 1px; | ||
| 30 | padding:10px; | ||
| 31 | margin-top:20px; | ||
| 32 | } | ||
| 33 | #nav-menu-header, #post-body,#post-header { | ||
| 34 | border-color:#CCCCCC; | ||
| 35 | border-style:solid; | ||
| 36 | } | ||
| 37 | |||
| 38 | #menu-management .nav-tab { | ||
| 39 | background:none repeat scroll 0 0 #F4F4F4; | ||
| 40 | } | ||
| 41 | |||
| 42 | #menu-management .nav-tab-active { | ||
| 43 | background:none repeat scroll 0 0 #fff; | ||
| 44 | border-bottom-color:#fff; | ||
| 45 | } | ||
| 46 | |||
| 47 | </style> | ||
| 48 | <div id="" class="wrap"> | ||
| 49 | <div id="icon-users" class="icon32"><br /></div> | ||
| 50 | <h2>Creating a new CBV User...</h2> | ||
| 51 | |||
| 52 | <div id="post-body"> | ||
| 53 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 54 | <form method="post" id="admin-new-user-form"> | ||
| 55 | |||
| 56 | <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;"> | ||
| 57 | <tbody> | ||
| 58 | <tr> | ||
| 59 | <th width="120px;">Username:</th> | ||
| 60 | <td><input type="text" name="username" required /></td> | ||
| 61 | </tr> | ||
| 62 | <tr> | ||
| 63 | <th>Email:</th> | ||
| 64 | <td><input type="text" name="email" required /></td> | ||
| 65 | </tr> | ||
| 66 | <tr> | ||
| 67 | <th>First Name:</th> | ||
| 68 | <td><input type="text" name="first_name" required /></td> | ||
| 69 | </tr> | ||
| 70 | <tr> | ||
| 71 | <th>Last Name:</th> | ||
| 72 | <td><input type="text" name="last_name" id="create_last_name" required /></td> | ||
| 73 | </tr> | ||
| 74 | <tr> | ||
| 75 | <th>Country:</th> | ||
| 76 | <td> | ||
| 77 | <select name="country"> | ||
| 78 | <?php HTML\select_opts_countries(); ?> | ||
| 79 | </select> | ||
| 80 | </td> | ||
| 81 | </tr> | ||
| 82 | <tr> | ||
| 83 | <th>Province:</th> | ||
| 84 | <td> | ||
| 85 | <select name="province"> | ||
| 86 | <option disabled value="">Select a State/Province</option> | ||
| 87 | <optgroup label="Canada"> | ||
| 88 | <?php HTML\select_opts_provinces(); ?> | ||
| 89 | </optgroup> | ||
| 90 | |||
| 91 | <optgroup label="United States"> | ||
| 92 | <?php HTML\select_opts_states(); ?> | ||
| 93 | </optgroup> | ||
| 94 | </select> | ||
| 95 | </td> | ||
| 96 | </tr> | ||
| 97 | </tbody> | ||
| 98 | </table> | ||
| 99 | |||
| 100 | <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table" style="float:left; width:350px;"> | ||
| 101 | <tbody> | ||
| 102 | <tr> | ||
| 103 | <th>User Type:</th> | ||
| 104 | <td> | ||
| 105 | <select name="user_role" id="create_user_role"> | ||
| 106 | <?php foreach($roles as $roled=>$name):?> | ||
| 107 | <option value="<?php echo $roled;?>"><?php echo $name;?></option> | ||
| 108 | <?php endforeach;?> | ||
| 109 | </select> | ||
| 110 | </td> | ||
| 111 | </tr> | ||
| 112 | <tr id="create_member_id"> | ||
| 113 | <th>Member ID:</th> | ||
| 114 | <td><input type="text" name="member_id" id="member_id" readonly="readonly" /></td> | ||
| 115 | </tr> | ||
| 116 | <tr><td colspan="2"> </td></tr> | ||
| 117 | <tr> | ||
| 118 | <th>Password (twice):</th> | ||
| 119 | <td><input type="password" name="password" required /></td> | ||
| 120 | </tr> | ||
| 121 | <tr> | ||
| 122 | <th> </th> | ||
| 123 | <td><input type="password" name="password2" required /></td> | ||
| 124 | </tr> | ||
| 125 | </tbody> | ||
| 126 | </table> | ||
| 127 | |||
| 128 | <div style="clear:both;"></div> | ||
| 129 | |||
| 130 | <div class="validation-errors" style="display:none;margin-top:10px;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div> | ||
| 131 | |||
| 132 | <div style="margin-top:10px;padding-top:5px; border-top:1px solid #e8e8e8;"> | ||
| 133 | <input type="submit" value="Create User" /> | ||
| 134 | </div> | ||
| 135 | |||
| 136 | </form> | ||
| 137 | </div> | ||
| 138 | |||
| 139 | </div> | ||
| 140 | |||
| 141 | </div> | ||
| 142 | |||
| 143 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| 144 | <script type="text/javascript"> | ||
| 145 | var $ = jQuery; | ||
| 146 | |||
| 147 | var $role_selector = $('#create_user_role'); | ||
| 148 | var $member_id_container = $('#create_member_id'); | ||
| 149 | var $member_id_field = $('#member_id'); | ||
| 150 | var $form = $('#admin-new-user-form'); | ||
| 151 | var $last_name_field = $('#create_last_name'); | ||
| 152 | |||
| 153 | function changedUserRole() { | ||
| 154 | if ($role_selector.val() == "member") { | ||
| 155 | updateMemberID(); | ||
| 156 | $member_id_container.show(); | ||
| 157 | } else { | ||
| 158 | $member_id_container.hide(); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | function updateMemberID() { | ||
| 163 | var lname = $last_name_field.val(); | ||
| 164 | if ($role_selector.val() == "member") { | ||
| 165 | $.ajax({ | ||
| 166 | url: '/wp-admin/admin-ajax.php' | ||
| 167 | , data: ({ajax:"yes", action: 'admin_create_member_id', last_name: lname}) | ||
| 168 | , dataType: 'json' | ||
| 169 | , type: 'post' | ||
| 170 | , success: function(data) { | ||
| 171 | $member_id_field.val(data.member_id); | ||
| 172 | } | ||
| 173 | }); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | $(function() { | ||
| 178 | changedUserRole(); | ||
| 179 | |||
| 180 | $('#create_last_name').blur(function() { | ||
| 181 | updateMemberID(); | ||
| 182 | }); | ||
| 183 | |||
| 184 | $role_selector.change(function() { | ||
| 185 | changedUserRole(); | ||
| 186 | }); | ||
| 187 | |||
| 188 | var options = { | ||
| 189 | url: '/wp-admin/admin-ajax.php' | ||
| 190 | , dataType: 'json' | ||
| 191 | , type: 'post' | ||
| 192 | , data: ({ajax:"yes", action: 'admin_create_user', section: 'create'}) | ||
| 193 | , beforeSubmit: function(formData, jqForm, options) { | ||
| 194 | var $error_container = jQuery('.validation-errors'); | ||
| 195 | $error_container.hide(); | ||
| 196 | } | ||
| 197 | , success: function(data) { | ||
| 198 | if (data.success == "true") { | ||
| 199 | document.location.href=data.edit_profile | ||
| 200 | } else { | ||
| 201 | var $error_container = jQuery('.validation-errors'); | ||
| 202 | jQuery('h6',$error_container).html("OOPS..."); | ||
| 203 | jQuery('ul',$error_container).html(data.msg); | ||
| 204 | $error_container.show(); | ||
| 205 | } | ||
| 206 | |||
| 207 | } | ||
| 208 | }; | ||
| 209 | $form.ajaxForm(options); | ||
| 210 | |||
| 211 | }); | ||
| 212 | |||
| 213 | |||
| 214 | </script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/display_users.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | use Tz\WordPress\UAM; | ||
| 9 | |||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 11 | use Tz\WordPress\Tools\Notifications; | ||
| 12 | |||
| 13 | use Exception, StdClass; | ||
| 14 | use WP_User; | ||
| 15 | ?> | ||
| 16 | <div id="" class="wrap"> | ||
| 17 | <div id="icon-users" class="icon32"><br /></div> | ||
| 18 | <h2>CBV User Manager <a href="/wp-admin/admin.php?page=cbv_users_create" class="button add-new-h2">Add New</a></h2> | ||
| 19 | <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p> | ||
| 20 | |||
| 21 | |||
| 22 | <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;"> | ||
| 23 | <thead> | ||
| 24 | <tr> | ||
| 25 | <th scope="col" width="180" class="manage-column">Username</th> | ||
| 26 | <th scope="col" class="manage-column">Name</th> | ||
| 27 | <th scope="col" width="250" class="manage-column">Email</th> | ||
| 28 | <th scope="col" width="200" class="manage-column">Role</th> | ||
| 29 | </tr> | ||
| 30 | </thead> | ||
| 31 | <tbody> | ||
| 32 | <?php $users = get_users(); | ||
| 33 | |||
| 34 | foreach($users as $user): | ||
| 35 | |||
| 36 | reset($user->roles); | ||
| 37 | $role = current($user->roles); | ||
| 38 | |||
| 39 | |||
| 40 | ?> | ||
| 41 | <tr> | ||
| 42 | <td><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $user['uid']?>"><?php echo $user['user_login']?></a></td> | ||
| 43 | <td><a href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $user['uid']?>"><?php echo $user['name']?></a></td> | ||
| 44 | <td><?php echo $user['email']?></td> | ||
| 45 | <td><?php echo $user['role']?></td> | ||
| 46 | </tr> | ||
| 47 | <?php endforeach; ?> | ||
| 48 | </body> | ||
| 49 | </table> | ||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | </div> | ||
| 55 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | |||
| 9 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 10 | use Tz\WordPress\Tools\Notifications; | ||
| 11 | |||
| 12 | use Exception, StdClass; | ||
| 13 | use WP_User; | ||
| 14 | |||
| 15 | $user = new WP_User($_GET['uid']); | ||
| 16 | reset($user->roles); | ||
| 17 | $role = current($user->roles); | ||
| 18 | |||
| 19 | $fname = get_user_meta($user->ID, 'first_name', true); | ||
| 20 | $lname = get_user_meta($user->ID, 'last_name', true); | ||
| 21 | |||
| 22 | if (empty($fname) || empty($lname)) { | ||
| 23 | $name = $user->user_login; | ||
| 24 | } else { | ||
| 25 | $name = $fname . " " . $lname; | ||
| 26 | } | ||
| 27 | |||
| 28 | $section = isset($_GET['section']) ? $_GET['section'] : "overview"; | ||
| 29 | |||
| 30 | |||
| 31 | call_user_func(function() { | ||
| 32 | CBV\load('Events'); | ||
| 33 | }); | ||
| 34 | |||
| 35 | $member_id = get_user_meta($user->ID, 'member_id', true); | ||
| 36 | ?> | ||
| 37 | <style> | ||
| 38 | |||
| 39 | #post-body { | ||
| 40 | -moz-border-radius-bottomleft:6px; | ||
| 41 | -moz-border-radius-bottomright:6px; | ||
| 42 | -moz-border-radius-topright:6px; | ||
| 43 | background:none repeat scroll 0 0 #FFFFFF; | ||
| 44 | border-width:1px 1px 1px; | ||
| 45 | padding:10px; | ||
| 46 | } | ||
| 47 | #nav-menu-header, #post-body,#post-header { | ||
| 48 | border-color:#CCCCCC; | ||
| 49 | border-style:solid; | ||
| 50 | } | ||
| 51 | |||
| 52 | #menu-management .nav-tab { | ||
| 53 | background:none repeat scroll 0 0 #F4F4F4; | ||
| 54 | } | ||
| 55 | |||
| 56 | #menu-management .nav-tab-active { | ||
| 57 | background:none repeat scroll 0 0 #fff; | ||
| 58 | border-bottom-color:#fff; | ||
| 59 | } | ||
| 60 | |||
| 61 | </style> | ||
| 62 | |||
| 63 | <script type="text/javascript">var user_id = <?php echo $_GET['uid'];?>;</script> | ||
| 64 | |||
| 65 | <div id="" class="wrap"> | ||
| 66 | <div id="icon-users" class="icon32"><br /></div> | ||
| 67 | <h2>Editing: <?php echo $name; ?> | ||
| 68 | <?php if ($role=="member" && !empty($member_id)) { echo '<span class="admin-member-id"> ('.$member_id.')</span>'; }?> | ||
| 69 | </h2> | ||
| 70 | <p style="display:none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis convallis nisi eu dignissim. Quisque malesuada augue in mi blandit at blandit tortor sollicitudin. Cras at justo mi, vel mollis est. Donec orci erat, blandit varius vehicula vitae, volutpat at lorem. Etiam tincidunt bibendum ante, non tincidunt purus faucibus sed. Suspendisse eget facilisis tellus. Nulla imperdiet leo placerat diam sollicitudin nec mattis neque mattis. Cras id lacus tellus. Phasellus volutpat vehicula porttitor. Praesent erat felis, pharetra mollis egestas sit amet, rhoncus eget nisl. Morbi interdum sapien vitae nibh pharetra scelerisque. Mauris porta accumsan velit ac aliquam. Sed sit amet dictum felis. Fusce tempus vulputate nulla, quis tincidunt velit mattis eu.</p> | ||
| 71 | |||
| 72 | <div id="menu-management" style="margin-top:25px;"> | ||
| 73 | <div class="nav-tabs-nav"> | ||
| 74 | <div class="nav-tabs-wrapper" class="section-<?php echo $_GET['section'];?>"> | ||
| 75 | <div class="nav-tabs" style="padding: 0px; margin-left: 0px;"> | ||
| 76 | <a id="overview" class="nav-tab hide-if-no-js <?php echo ($section=="overview") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=overview">Overview</a> | ||
| 77 | <a id="profile" class="nav-tab hide-if-no-js <?php echo ($section=="profile") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=profile">Profile</a> | ||
| 78 | <a id="events" class="nav-tab hide-if-no-js <?php echo ($section=="events") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=events">Events</a> | ||
| 79 | <a id="courses" class="nav-tab hide-if-no-js <?php echo ($section=="courses") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=courses">Courses</a> | ||
| 80 | <?php if ($role=="member"): ?> | ||
| 81 | <a id="cehours" class="nav-tab hide-if-no-js <?php echo ($section=="cehours") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=cehours">Continuing Ed.</a> | ||
| 82 | <?php endif; ?> | ||
| 83 | <a id="payhistory" class="nav-tab hide-if-no-js <?php echo ($section=="payhistory") ? "nav-tab-active" : ""; ?>" href="/wp-admin/admin.php?page=cbv_users&action=edit&uid=<?php echo $_GET['uid']; ?>§ion=payhistory">Payment History</a> | ||
| 84 | </div> | ||
| 85 | </div> | ||
| 86 | </div> | ||
| 87 | |||
| 88 | <div id="post-body" style="padding:0px 10px 15px 10px;"> | ||
| 89 | <?php require_once('edit_user_' . $section . '.php'); ?> | ||
| 90 | </div> | ||
| 91 | |||
| 92 | </div> | ||
| 93 | |||
| 94 | </div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user_cehours.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\UAM; | ||
| 8 | |||
| 9 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 10 | use Tz\WordPress\Tools\Notifications; | ||
| 11 | |||
| 12 | use Exception, StdClass; | ||
| 13 | use WP_User; | ||
| 14 | |||
| 15 | $uid = $_GET['uid']; | ||
| 16 | |||
| 17 | CBV\load('CEHours'); | ||
| 18 | $cehours = CEHours\get_user_cehours($uid); | ||
| 19 | |||
| 20 | |||
| 21 | ?> | ||
| 22 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 23 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Continuing Education Hours... <a href="/wp-admin/admin-ajax.php?ajax=yes&post_action=create&action=build_cehour_form&uid=<?php echo $uid?>&indexed=0" id="admin_add_new_cehours" class="button add-new-h2">Add New</a></h2> | ||
| 24 | |||
| 25 | <?php | ||
| 26 | if (empty($cehours)) : | ||
| 27 | print "<p>No CE Hours recorded.</p>"; | ||
| 28 | else: | ||
| 29 | |||
| 30 | ?> | ||
| 31 | |||
| 32 | <table cellspacing="0" class="widefat post fixed" style="margin-top:0px;"> | ||
| 33 | <thead> | ||
| 34 | <tr> | ||
| 35 | <th scope="col" width="150">Date Recorded</th> | ||
| 36 | <th scope="col">Activity</th> | ||
| 37 | <th scope="col" width="150">Structured</th> | ||
| 38 | <th scope="col" width="100">Unstructured</th> | ||
| 39 | <th scope="col" width="100"> </th> | ||
| 40 | </tr> | ||
| 41 | </thead> | ||
| 42 | <tbody> | ||
| 43 | <?php foreach($cehours as $ce): | ||
| 44 | $ce_date = date('F j, Y',$ce['date']); | ||
| 45 | ?> | ||
| 46 | <tr> | ||
| 47 | <td><?php echo $ce_date; ?></td> | ||
| 48 | <td><?php echo $ce['activity']; ?></td> | ||
| 49 | <td><?php echo ($ce['type']=="structured") ? $ce['hours'] : 0;?></td> | ||
| 50 | <td><?php echo ($ce['type']=="unstructured") ? $ce['hours'] : 0;?></td> | ||
| 51 | <td class="cehours-remove-td"><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_cehour_form&uid=<?php echo $uid?>&indexed=<?php echo $ce['date'];?>" class="cehours-edit" rel="<?php echo $ce['date'];?>">edit</a> | <a href="#" class="cehours-remove" rel="<?php echo $ce['date'];?>">remove</a></td> | ||
| 52 | </tr> | ||
| 53 | <?php endforeach; ?> | ||
| 54 | </tbody> | ||
| 55 | </table> | ||
| 56 | <?php | ||
| 57 | endif; | ||
| 58 | |||
| 59 | ?> | ||
| 60 | </div> | ||
| 61 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user_courses.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | use Tz\WordPress\UAM; | ||
| 9 | |||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 11 | use Tz\WordPress\Tools\Notifications; | ||
| 12 | |||
| 13 | use Exception, StdClass; | ||
| 14 | use WP_User; | ||
| 15 | ?> | ||
| 16 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 17 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Courses...</h2> | ||
| 18 | <em>Will be implemented when Courses is complete.</em> | ||
| 19 | </div> | ||
| 20 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user_events.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | use Tz\WordPress\UAM; | ||
| 9 | |||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 11 | use Tz\WordPress\Tools\Notifications; | ||
| 12 | |||
| 13 | use Exception, StdClass; | ||
| 14 | use WP_User; | ||
| 15 | |||
| 16 | $uid = $_GET['uid']; | ||
| 17 | |||
| 18 | CBV\load('Events'); | ||
| 19 | $events = get_user_meta($user->ID, 'events', true); | ||
| 20 | ?> | ||
| 21 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 22 | <?php | ||
| 23 | if (empty($events) || count($events) < 1): | ||
| 24 | echo '<h2 style="margin-bottom:10px;padding-bottom:0px;">'.$name.' is not registered for any events...</h2>'; | ||
| 25 | else: ?> | ||
| 26 | |||
| 27 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Registered for Events...</h2> | ||
| 28 | |||
| 29 | <table cellspacing="0" class="widefat post fixed"> | ||
| 30 | <thead> | ||
| 31 | <tr> | ||
| 32 | <th scope="col">Event Name</th> | ||
| 33 | <th scope="col" width="150">Event Date</th> | ||
| 34 | <th scope="col" width="150">Registered</th> | ||
| 35 | <th scope="col" width="100"> </th> | ||
| 36 | </tr> | ||
| 37 | </thead> | ||
| 38 | <tbody> | ||
| 39 | <?php foreach($user->events as $event): | ||
| 40 | $e = Events\get_event($event['event_id']); | ||
| 41 | $event_date = get_post_meta($e->ID, 'event_date', true); | ||
| 42 | ?> | ||
| 43 | <tr> | ||
| 44 | <td><?php echo $e->post_title;?></td> | ||
| 45 | <td><?php echo date('F j, Y',$event_date);?></td> | ||
| 46 | <td><?php echo date('F j, Y',$event['register_date']);?></td> | ||
| 47 | <td class="event-cancel-td"><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_event_form&uid=<?php echo $uid?>&event_id=<?php echo $e->ID;?>" class="event-edit" rel="<?php echo $e->ID;?>">edit</a> | <a href="#" class="event-cancel" rel="<?php echo $e->ID;?>">cancel</a></td> | ||
| 48 | </tr> | ||
| 49 | <?php endforeach; ?> | ||
| 50 | </tbody> | ||
| 51 | </table> | ||
| 52 | |||
| 53 | <h4 style="margin-bottom:5px;padding-bottom:0px; padding-left:10px;"><em>Not registered for...</em></h4> | ||
| 54 | <?php endif; ?> | ||
| 55 | <?php | ||
| 56 | $posts = query_posts(Array( | ||
| 57 | 'post_type' => 'events' | ||
| 58 | , 'posts_per_page' => get_option('posts_per_page') | ||
| 59 | , 'paged' => (get_query_var('paged') ? get_query_var('paged') : 1) | ||
| 60 | , 'meta_key' => 'event_date' | ||
| 61 | , 'meta_compare' => '>' | ||
| 62 | , 'meta_value' => (time() + (60*60*24)) // event date + 1 day, so that they can register the day of... | ||
| 63 | , 'order' => 'DESC' | ||
| 64 | )); | ||
| 65 | ?> | ||
| 66 | |||
| 67 | <table cellspacing="0" class="widefat post fixed"> | ||
| 68 | <thead> | ||
| 69 | <tr> | ||
| 70 | <th scope="col">Event Name</th> | ||
| 71 | <th scope="col" width="150">Event Date</th> | ||
| 72 | <th scope="col" width="150">Register By</th> | ||
| 73 | <th scope="col" width="100">Cost</th> | ||
| 74 | <th scope="col" width="100"> </th> | ||
| 75 | </tr> | ||
| 76 | </thead> | ||
| 77 | <tbody> | ||
| 78 | <?php foreach($posts as $post): | ||
| 79 | if (!Events\is_attending($post->ID, $uid) && UAM\can_user_access($post->ID, $uid)): | ||
| 80 | $event_date = get_post_meta($post->ID, 'event_date', true); | ||
| 81 | $register_date = get_post_meta($post->ID, 'reg_deadline', true); | ||
| 82 | $cost = get_post_meta($post->ID,'cost',true); | ||
| 83 | if (empty($cost) || $cost < 1 || strtolower($cost)=="free") { $cost = 0; } | ||
| 84 | ?> | ||
| 85 | <tr> | ||
| 86 | <td><?php echo $post->post_title;?></td> | ||
| 87 | <td><?php echo date('F j, Y',$event_date);?></td> | ||
| 88 | <td><?php echo date('F j, Y',$register_date);?></td> | ||
| 89 | <td>$<?php echo number_format($cost,2);?></td> | ||
| 90 | <td><a href="/wp-admin/admin-ajax.php?ajax=yes&action=build_event_form&post_action=create&uid=<?php echo $uid?>&event_id=<?php echo $post->ID;?>" class="event-edit" rel="<?php echo $post->ID;?>">Register</a></td> | ||
| 91 | </tr> | ||
| 92 | <?php endif; endforeach; ?> | ||
| 93 | </tbody> | ||
| 94 | </table> | ||
| 95 | |||
| 96 | </div> | ||
| 97 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user_overview.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | use Tz\WordPress\UAM; | ||
| 9 | |||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 11 | use Tz\WordPress\Tools\Notifications; | ||
| 12 | |||
| 13 | use Exception, StdClass; | ||
| 14 | use WP_User, WP_Roles; | ||
| 15 | |||
| 16 | $uid = $user->ID; | ||
| 17 | |||
| 18 | $first_name = get_user_meta($uid, 'first_name', true); | ||
| 19 | $last_name = get_user_meta($uid, 'last_name', true); | ||
| 20 | $description = get_user_meta($uid, 'description', true); | ||
| 21 | |||
| 22 | // contact info. | ||
| 23 | $address = get_user_meta($uid, 'address', true); | ||
| 24 | $address2 = get_user_meta($uid, 'address2', true); | ||
| 25 | $city = get_user_meta($uid, 'city', true); | ||
| 26 | $province = get_user_meta($uid, 'province', true); | ||
| 27 | $postal = get_user_meta($uid, 'postal', true); | ||
| 28 | $country = get_user_meta($uid, 'country', true); | ||
| 29 | $phone = get_user_meta($uid, 'phone', true); | ||
| 30 | $fax = get_user_meta($uid, 'fax', true); | ||
| 31 | $mobile = get_user_meta($uid, 'mobile', true); | ||
| 32 | $email = get_user_meta($uid, 'email', true); | ||
| 33 | |||
| 34 | // professional stuff | ||
| 35 | $title = get_user_meta($uid, 'title', true); | ||
| 36 | $company = get_user_meta($uid, 'company', true); | ||
| 37 | $website = get_user_meta($uid, 'website', true); | ||
| 38 | |||
| 39 | // status | ||
| 40 | $status = get_user_meta($uid, 'status', true); | ||
| 41 | |||
| 42 | // membership | ||
| 43 | $member_id = get_user_meta($uid, 'member_id', true); | ||
| 44 | |||
| 45 | $notify_me = get_user_meta($uid, 'notify_me', true); | ||
| 46 | |||
| 47 | |||
| 48 | $rc = new WP_Roles(); | ||
| 49 | $roles = $rc->role_names; | ||
| 50 | ksort($roles); | ||
| 51 | unset($rc, $roles['administrator']); | ||
| 52 | |||
| 53 | |||
| 54 | ?> | ||
| 55 | |||
| 56 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 57 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Overview of Users' Account...</h2> | ||
| 58 | <div style="float:left; width:300px;margin-right:50px;"> | ||
| 59 | |||
| 60 | <table cellspacing="0" class="widefat post fixed" style="border:none;"> | ||
| 61 | <tbody> | ||
| 62 | <?php if (!empty($first_name)): ?> | ||
| 63 | <tr> | ||
| 64 | <th>First Name:</th> | ||
| 65 | <td><?php echo $first_name; ?></td> | ||
| 66 | </tr> | ||
| 67 | <?php endif; ?> | ||
| 68 | |||
| 69 | <?php if (!empty($last_name)): ?> | ||
| 70 | <tr> | ||
| 71 | <th>Last Name:</th> | ||
| 72 | <td><?php echo $last_name; ?></td> | ||
| 73 | </tr> | ||
| 74 | <?php endif; ?> | ||
| 75 | |||
| 76 | <?php if (!empty($company)): ?> | ||
| 77 | <tr> | ||
| 78 | <th>Company:</th> | ||
| 79 | <td><?php echo $company; ?></td> | ||
| 80 | </tr> | ||
| 81 | <?php endif; ?> | ||
| 82 | |||
| 83 | <?php if (!empty($title)): ?> | ||
| 84 | <tr> | ||
| 85 | <th>Title:</th> | ||
| 86 | <td><?php echo $title; ?></td> | ||
| 87 | </tr> | ||
| 88 | <?php endif; ?> | ||
| 89 | |||
| 90 | <?php if (!empty($address)): ?> | ||
| 91 | <tr> | ||
| 92 | <th>Address:</th> | ||
| 93 | <td><?php echo $address; if (!empty($address2)) { echo "<br />".$address2; }?></td> | ||
| 94 | </tr> | ||
| 95 | <?php endif; ?> | ||
| 96 | |||
| 97 | <?php if (!empty($city)): ?> | ||
| 98 | <tr> | ||
| 99 | <th>City:</th> | ||
| 100 | <td><?php echo $city; ?></td> | ||
| 101 | </tr> | ||
| 102 | <?php endif; ?> | ||
| 103 | |||
| 104 | <?php if (!empty($province)): ?> | ||
| 105 | <tr> | ||
| 106 | <th>Province:</th> | ||
| 107 | <td><?php echo $province; ?></td> | ||
| 108 | </tr> | ||
| 109 | <?php endif; ?> | ||
| 110 | |||
| 111 | <?php if (!empty($country)): ?> | ||
| 112 | <tr> | ||
| 113 | <th>Country:</th> | ||
| 114 | <td><?php echo $country; ?></td> | ||
| 115 | </tr> | ||
| 116 | <?php endif; ?> | ||
| 117 | |||
| 118 | <?php if (!empty($phone)): ?> | ||
| 119 | <tr> | ||
| 120 | <th>Phone:</th> | ||
| 121 | <td><?php echo $phone; ?></td> | ||
| 122 | </tr> | ||
| 123 | <?php endif; ?> | ||
| 124 | |||
| 125 | <?php if (!empty($fax)): ?> | ||
| 126 | <tr> | ||
| 127 | <th>Fax:</th> | ||
| 128 | <td><?php echo $fax; ?></td> | ||
| 129 | </tr> | ||
| 130 | <?php endif; ?> | ||
| 131 | |||
| 132 | <?php if (!empty($mobile)): ?> | ||
| 133 | <tr> | ||
| 134 | <th>Mobile:</th> | ||
| 135 | <td><?php echo $mobile; ?></td> | ||
| 136 | </tr> | ||
| 137 | <?php endif; ?> | ||
| 138 | |||
| 139 | <?php if (!empty($email)): ?> | ||
| 140 | <tr> | ||
| 141 | <th>Email:</th> | ||
| 142 | <td><?php echo $email; ?></td> | ||
| 143 | </tr> | ||
| 144 | <?php endif; ?> | ||
| 145 | |||
| 146 | <?php if (!empty($website)): ?> | ||
| 147 | <tr> | ||
| 148 | <th>Website:</th> | ||
| 149 | <td><?php echo $website; ?></td> | ||
| 150 | </tr> | ||
| 151 | <?php endif; ?> | ||
| 152 | |||
| 153 | </tbody> | ||
| 154 | </table> | ||
| 155 | </div> | ||
| 156 | <div style="float:left; width:360px; border-left: 1px solid #ccc;"> | ||
| 157 | <div style="margin-left:20px; margin-bottom:20px;"> | ||
| 158 | |||
| 159 | <!-- coming soon... | ||
| 160 | <h3 style="margin-bottom:5px; padding-bottom:0px;">Account Balance:</h3> | ||
| 161 | <div style="color:red; font-size:18px;">-$130.00</div> | ||
| 162 | --> | ||
| 163 | |||
| 164 | <form method="post" id="overview_form"> | ||
| 165 | <input type="hidden" name="uid" value="<?php echo $uid; ?>" /> | ||
| 166 | <input type="hidden" name="section" value="account" /> | ||
| 167 | |||
| 168 | <h3 style="margin-bottom:5px; padding-bottom:0px;">Account Status:</h3> | ||
| 169 | <select name="status"> | ||
| 170 | <option value="active" <?php echo ($status=="active") ? "selected" : ""; ?>>Active</option> | ||
| 171 | <option value="suspeneded" <?php echo ($status=="suspended") ? "selected" : ""; ?>>Suspended</option> | ||
| 172 | <option value="terminated" <?php echo ($status=="terminated") ? "selected" : ""; ?>>Terminated</option> | ||
| 173 | </select> | ||
| 174 | |||
| 175 | <div style="clear:both;"></div> | ||
| 176 | |||
| 177 | <?php if($role!="administrator"):?> | ||
| 178 | <h3 style="margin-bottom:5px; padding-bottom:0px;">Account Type:</h3> | ||
| 179 | <select name="user_role"> | ||
| 180 | <?php foreach($roles as $roled=>$name):?> | ||
| 181 | <option value="<?php echo $roled;?>" <?php echo ($roled==$role) ? "selected" : "";?>><?php echo $name;?></option> | ||
| 182 | <?php endforeach;?> | ||
| 183 | </select> | ||
| 184 | <div style="clear:both;"></div> | ||
| 185 | <?php endif; ?> | ||
| 186 | |||
| 187 | <h3 style="margin-bottom:5px; padding-bottom:0px;">Change User Password:</h3> | ||
| 188 | <table cellpadding="0" cellspacing="0" border="0"> | ||
| 189 | <tbody> | ||
| 190 | <tr> | ||
| 191 | <td width="150">New Password (twice)</td> | ||
| 192 | <td><input type="password" name="password1" value="" /></td> | ||
| 193 | </tr> | ||
| 194 | <tr> | ||
| 195 | <td> </td> | ||
| 196 | <td><input type="password" name="password2" value="" /></td> | ||
| 197 | </tr> | ||
| 198 | <tr><td colspan="2" style="font-size:11px;"><em>(leave them blank to not change their password)</em></td></tr> | ||
| 199 | </tbody> | ||
| 200 | </table> | ||
| 201 | |||
| 202 | <div style="clear:both;"></div> | ||
| 203 | |||
| 204 | <?php if ($role=="member"): ?> | ||
| 205 | <h3 style="margin-bottom:5px; padding-bottom:0px;">Special Status:</h3> | ||
| 206 | <input type="hidden" name="special_status_active" value="true" /> | ||
| 207 | <table cellpadding="0" cellspacing="0" border="0"> | ||
| 208 | <tbody> | ||
| 209 | <tr> | ||
| 210 | <td width="20"><input type="checkbox" id="status_retired" name="special_status[]" value="status_retired" <?php search_special_status('status_retired');?> /></td> | ||
| 211 | <td><label for="status_retired">Retired status</label></td> | ||
| 212 | </tr> | ||
| 213 | <tr> | ||
| 214 | <td width="20"><input type="checkbox" id="status_disability" name="special_status[]" value="status_disability" <?php search_special_status('status_disability');?> /></td> | ||
| 215 | <td><label for="status_disability">Disability status</label></td> | ||
| 216 | </tr> | ||
| 217 | <tr> | ||
| 218 | <td width="20"><input type="checkbox" id="status_parental" name="special_status[]" value="status_parental" <?php search_special_status('status_parental');?> /></td> | ||
| 219 | <td><label for="status_parental">Parental status</label></td> | ||
| 220 | </tr> | ||
| 221 | <tr> | ||
| 222 | <td width="20"><input type="checkbox" id="status_educational" name="special_status[]" value="status_educational" <?php search_special_status('status_educational');?> /></td> | ||
| 223 | <td><label for="status_educational">Educational status</label></td> | ||
| 224 | </tr> | ||
| 225 | </tbody> | ||
| 226 | </table> | ||
| 227 | <div style="clear:both;"></div> | ||
| 228 | <?php endif; ?> | ||
| 229 | |||
| 230 | |||
| 231 | |||
| 232 | <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div> | ||
| 233 | <br /> | ||
| 234 | <input type="submit" value="Update Account" /><span class="update-placeholder"></span> | ||
| 235 | |||
| 236 | </form> | ||
| 237 | |||
| 238 | |||
| 239 | </div> | ||
| 240 | </div> | ||
| 241 | <div style="clear:both;"></div> | ||
| 242 | </div> | ||
| 243 | |||
| 244 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| 245 | |||
| 246 |
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\CEHours; | ||
| 7 | use Tz\WordPress\CBV\Events; | ||
| 8 | use Tz\WordPress\UAM; | ||
| 9 | |||
| 10 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 11 | use Tz\WordPress\Tools\Notifications; | ||
| 12 | |||
| 13 | use Exception, StdClass; | ||
| 14 | use WP_User; | ||
| 15 | ?> | ||
| 16 | <div style="padding:10px 10px 0px 10px; min-width:760px;"> | ||
| 17 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Invoices and Receipts...</h2> | ||
| 18 | <em>Will be implemented when Beanstream Integration is complete.</em> | ||
| 19 | </div> | ||
| 20 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
com/UserManager/views/edit_user_profile.php
0 → 100644
| 1 | <?php | ||
| 2 | namespace Tz\WordPress\Tools\UserManager; | ||
| 3 | |||
| 4 | use Tz, Tz\Common; | ||
| 5 | use Tz\WordPress\CBV; | ||
| 6 | use Tz\WordPress\CBV\User; | ||
| 7 | use Tz\WordPress\CBV\CEHours; | ||
| 8 | use Tz\WordPress\CBV\Events; | ||
| 9 | use Tz\WordPress\UAM; | ||
| 10 | use Tz\WordPress\Tools\HTML; | ||
| 11 | |||
| 12 | use Tz\WordPress\Tools, Tz\WordPress\Tools\UserDetails as UD; | ||
| 13 | use Tz\WordPress\Tools\Notifications; | ||
| 14 | |||
| 15 | use Exception, StdClass; | ||
| 16 | use WP_User; | ||
| 17 | |||
| 18 | $user = new WP_User($_GET['uid']); | ||
| 19 | |||
| 20 | Tools\import('HTML'); | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | $profile_preference = get_user_meta($user->ID, 'profile_preference', true); | ||
| 25 | $preference = get_user_meta($user->ID, 'email_address_preference', true); | ||
| 26 | |||
| 27 | ?> | ||
| 28 | <div style="padding:10px 10px 0px 10px; min-width:800px;" class="my-profile-edit"> | ||
| 29 | <h2 style="margin-bottom:10px;padding-bottom:0px;">Users' Profile...</h2> | ||
| 30 | <form name="admin-edit-user-profile" id="admin-edit-user-profile" style="margin-top:0;padding-top:0;"> | ||
| 31 | <input type="hidden" name="section" value="profile" /> | ||
| 32 | <input type="hidden" name="uid" value="<?php echo $user->ID;?>" /> | ||
| 33 | <div style="float:left; width:400px;margin-right:20px;"> | ||
| 34 | |||
| 35 | <h4>Personal Information</h4> | ||
| 36 | <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> | ||
| 37 | <tbody> | ||
| 38 | <tr> | ||
| 39 | <th width="150">Prefix:</th> | ||
| 40 | <td> | ||
| 41 | <select name="prefix"> | ||
| 42 | <?php HTML\select_opts_prefixes(get_user_meta($_GET['uid'], 'prefix', true)); ?> | ||
| 43 | </select> | ||
| 44 | </td> | ||
| 45 | </tr> | ||
| 46 | <tr> | ||
| 47 | <th width="150">First Name:</th> | ||
| 48 | <td><input type="text" name="first_name" value="<?php echo get_user_meta($_GET['uid'], 'first_name', true);?>" /></td> | ||
| 49 | </tr> | ||
| 50 | <tr> | ||
| 51 | <th>Last Name:</th> | ||
| 52 | <td><input type="text" name="last_name" value="<?php echo get_user_meta($_GET['uid'], 'last_name', true);?>" /></td> | ||
| 53 | </tr> | ||
| 54 | <tr> | ||
| 55 | <th>Degrees:</th> | ||
| 56 | <td><input type="text" name="degrees" value="<?php echo get_user_meta($_GET['uid'], 'degrees', true);?>" /></td> | ||
| 57 | </tr> | ||
| 58 | <tr> | ||
| 59 | <th>Biography:</th> | ||
| 60 | <td><textarea name="description"><?php echo get_user_meta($_GET['uid'], 'description', true);?></textarea></td> | ||
| 61 | </tr> | ||
| 62 | <tr> | ||
| 63 | <th>Date of Birth:</th> | ||
| 64 | <td><input type="text" name="date_of_birth" class="datepicker" value="<?php echo get_user_meta($_GET['uid'], 'date_of_birth', true);?>" /></td> | ||
| 65 | </tr> | ||
| 66 | </tbody> | ||
| 67 | </table> | ||
| 68 | |||
| 69 | <h4>Contact Information</h4> | ||
| 70 | <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> | ||
| 71 | <tbody> | ||
| 72 | <tr> | ||
| 73 | <th width="150"> </th> | ||
| 74 | <td><select name="profile_preference"><option value="Home" <?php echo ($profile_preference=="Home") ? "selected" : ""; ?>>Home </option><option value="Work" <?php echo ($profile_preference=="Work") ? "selected" : ""; ?>>Work </option></select></td> | ||
| 75 | </tr> | ||
| 76 | <tr> | ||
| 77 | <th>Address:</th> | ||
| 78 | <td><input type="text" name="address" value="<?php echo get_user_meta($_GET['uid'], 'address', true);?>" /></td> | ||
| 79 | </tr> | ||
| 80 | <tr> | ||
| 81 | <th>Suite:</th> | ||
| 82 | <td><input type="text" name="address2" value="<?php echo get_user_meta($_GET['uid'], 'address2', true);?>" /></td> | ||
| 83 | </tr> | ||
| 84 | <tr> | ||
| 85 | <th>City:</th> | ||
| 86 | <td><input type="text" name="city" value="<?php echo get_user_meta($_GET['uid'], 'city', true);?>" /></td> | ||
| 87 | </tr> | ||
| 88 | <tr> | ||
| 89 | <th>State/Province:</th> | ||
| 90 | <td> | ||
| 91 | <select name="province"> | ||
| 92 | <option disabled value="">Select a State/Province</option> | ||
| 93 | <optgroup label="Canada"> | ||
| 94 | <?php HTML\select_opts_provinces(get_user_meta($_GET['uid'], 'province', true)); ?> | ||
| 95 | </optgroup> | ||
| 96 | |||
| 97 | <optgroup label="United States"> | ||
| 98 | <?php HTML\select_opts_states(get_user_meta($_GET['uid'], 'province', true)); ?> | ||
| 99 | </optgroup> | ||
| 100 | </select> | ||
| 101 | </td> | ||
| 102 | </tr> | ||
| 103 | <tr> | ||
| 104 | <th>Postal:</th> | ||
| 105 | <td><input type="text" name="postal" value="<?php echo get_user_meta($_GET['uid'], 'postal', true); ?>" /></td> | ||
| 106 | </tr> | ||
| 107 | <tr> | ||
| 108 | <th>Country:</th> | ||
| 109 | <td> | ||
| 110 | <select name="country"> | ||
| 111 | <?php HTML\select_opts_countries(get_user_meta($_GET['uid'], 'country', true)); ?> | ||
| 112 | </select> | ||
| 113 | </td> | ||
| 114 | </tr> | ||
| 115 | <tr> | ||
| 116 | <th>Phone:</th> | ||
| 117 | <td><input type="text" name="phone" value="<?php echo get_user_meta($_GET['uid'], 'phone', true);?>" /></td> | ||
| 118 | </tr> | ||
| 119 | <tr> | ||
| 120 | <th>Fax:</th> | ||
| 121 | <td><input type="text" name="fax" value="<?php echo get_user_meta($_GET['uid'], 'fax', true);?>" /></td> | ||
| 122 | </tr> | ||
| 123 | <tr> | ||
| 124 | <th>Email:</th> | ||
| 125 | <td><input type="text" name="email" value="<?php echo get_user_meta($_GET['uid'], 'email', true);?>" /></td> | ||
| 126 | </tr> | ||
| 127 | <tr> | ||
| 128 | <th>Mobile:</th> | ||
| 129 | <td><input type="text" name="mobile" value="<?php echo get_user_meta($_GET['uid'], 'mobile', true);?>" /></td> | ||
| 130 | </tr> | ||
| 131 | </tbody> | ||
| 132 | </table> | ||
| 133 | |||
| 134 | </div> | ||
| 135 | <div style="float:left; width:350px;"> | ||
| 136 | <h4>Notification Settings</h4> | ||
| 137 | <table cellpadding="0" cellspacing="0" border="0" class="my-profile-table"> | ||
| 138 | <tbody> | ||
| 139 | <tr> | ||
| 140 | <th width="150">Email for Notifications:</th> | ||
| 141 | <td> | ||
| 142 | <select name="email_address_preference"> | ||
| 143 | <?php | ||
| 144 | $email = get_user_meta($_GET['uid'],'email',true); | ||
| 145 | ?> | ||
| 146 | <option value="none" <?php echo ($preference=="none") ? "selected" : "";?>>None</option> | ||
| 147 | <?php if(!empty($email)): ?><option value="email" <?php echo ($preference=="email") ? "selected" : "";?>><?php echo $email;?></option><?php endif;?> | ||
| 148 | </select> | ||
| 149 | </td> | ||
| 150 | </tr> | ||
| 151 | </tbody> | ||
| 152 | </table> | ||
| 153 | </div> | ||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | <div style="clear:both;"></div> | ||
| 158 | <div class="validation-errors" style="display:none;"><div class="error-wrap"><h6>OOPS...</h6><ul></ul></div></div> | ||
| 159 | <br /> | ||
| 160 | <input type="submit" value="Update Profile" /><span class="update-placeholder"></span> | ||
| 161 | |||
| 162 | |||
| 163 | </form> | ||
| 164 | </div> | ||
| 165 | <script src="<?php echo Tools\url('../UserManager.js', __FILE__);?>" type="text/javascript"></script> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
| 3 | |||
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
| 5 | <head> | ||
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
| 7 | |||
| 8 | <title>Edit CE Hours</title> | ||
| 9 | <style type="text/css"> | ||
| 10 | |||
| 11 | html, body { margin:0px; padding:0;} | ||
| 12 | h3 { | ||
| 13 | color:#f7bd55; | ||
| 14 | font-size: 12px; | ||
| 15 | font-weight: bold; | ||
| 16 | text-align: left; | ||
| 17 | line-height: 1.75em; | ||
| 18 | background: #3b0d32; | ||
| 19 | border: solid 1px #FFF; | ||
| 20 | border-bottom: solid 1px #999; | ||
| 21 | cursor: default; | ||
| 22 | padding: 0em; padding:3px 5px 3px 10px; | ||
| 23 | margin: 0em; | ||
| 24 | } | ||
| 25 | |||
| 26 | form { | ||
| 27 | display: block; | ||
| 28 | margin-right:20px; | ||
| 29 | } | ||
| 30 | |||
| 31 | .dashboard-section-title { font-weight:bold; color:#3b0d32; } | ||
| 32 | </style> | ||
| 33 | </head> | ||
| 34 | |||
| 35 | <body> | ||
| 36 | |||
| 37 | <h3>Edit <?php echo $name; ?>'s CE Hours:</h3> | ||
| 38 | |||
| 39 | <form method="post" action="" id="edit-cehours-form"> | ||
| 40 | <input type="hidden" name="uid" value="<?php echo $uid; ?>" /> | ||
| 41 | <input type="hidden" name="indexed" value="<?php echo $indexed; ?>" /> | ||
| 42 | <input type="hidden" name="action" value="<?php echo $action; ?>" /> | ||
| 43 | |||
| 44 | |||
| 45 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 46 | <div class="dashboard-section-links"></div> | ||
| 47 | <div class="dashboard-section-content small"> | ||
| 48 | <table class="clean no-left-padding"> | ||
| 49 | <tbody> | ||
| 50 | <tr> | ||
| 51 | <th width="100">Type:</th> | ||
| 52 | <td> | ||
| 53 | <select name="type"> | ||
| 54 | <option value="structured" <?php echo ($type=="structured") ? "selected" : ""; ?>>Structured</option> | ||
| 55 | <option value="unstructured" <?php echo ($type=="unstructured") ? "selected" : ""; ?>>Unstructured</option> | ||
| 56 | </select> | ||
| 57 | </td> | ||
| 58 | </tr> | ||
| 59 | <tr> | ||
| 60 | <th>Date:</th> | ||
| 61 | <td><input type="text" class="datepicker" name="date" value="<?php echo $date;?>" /></td> | ||
| 62 | </tr> | ||
| 63 | <tr> | ||
| 64 | <th>Activity</th> | ||
| 65 | <td><input type="text" name="activity" value="<?php echo $activity;?>" /></td> | ||
| 66 | </tr> | ||
| 67 | |||
| 68 | <tr> | ||
| 69 | <th>Hours:</th> | ||
| 70 | <td><input type="text" name="hours" value="<?php echo $hours;?>" /></td> | ||
| 71 | </tr> | ||
| 72 | </tbody> | ||
| 73 | </table> | ||
| 74 | |||
| 75 | </div> | ||
| 76 | </div> | ||
| 77 | |||
| 78 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 79 | <div class="dashboard-section-title"></div> | ||
| 80 | <div class="dashboard-section-links"></div> | ||
| 81 | <div class="dashboard-section-content small"> | ||
| 82 | <div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Apply"; ?>" /></div> | ||
| 83 | </div> | ||
| 84 | </div> | ||
| 85 | |||
| 86 | </form> | ||
| 87 | |||
| 88 | </body> | ||
| 89 | </html> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
| 3 | |||
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
| 5 | <head> | ||
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
| 7 | |||
| 8 | <title>Edit Event</title> | ||
| 9 | <style type="text/css"> | ||
| 10 | |||
| 11 | html, body { margin:0px; padding:0;} | ||
| 12 | h3 { | ||
| 13 | color:#f7bd55; | ||
| 14 | font-size: 12px; | ||
| 15 | font-weight: bold; | ||
| 16 | text-align: left; | ||
| 17 | line-height: 1.75em; | ||
| 18 | background: #3b0d32; | ||
| 19 | border: solid 1px #FFF; | ||
| 20 | border-bottom: solid 1px #999; | ||
| 21 | cursor: default; | ||
| 22 | padding: 0em; padding:3px 5px 3px 10px; | ||
| 23 | margin: 0em; | ||
| 24 | } | ||
| 25 | |||
| 26 | form { | ||
| 27 | display: block; | ||
| 28 | margin-right:20px; | ||
| 29 | } | ||
| 30 | |||
| 31 | .dashboard-section-title { font-weight:bold; color:#3b0d32; } | ||
| 32 | </style> | ||
| 33 | </head> | ||
| 34 | |||
| 35 | <body> | ||
| 36 | |||
| 37 | <h3><?php echo $post->post_title;?></h3> | ||
| 38 | |||
| 39 | <?php | ||
| 40 | $extras = $user_event_meta['extras']; | ||
| 41 | ?> | ||
| 42 | |||
| 43 | <form method="post" action="" id="edit-event-form"> | ||
| 44 | |||
| 45 | <input type="hidden" name="uid" value="<?php echo $uid; ?>" /> | ||
| 46 | <input type="hidden" name="event_id" value="<?php echo $post->ID; ?>" /> | ||
| 47 | <input type="hidden" name="type" value="<?php echo $action; ?>" /> | ||
| 48 | |||
| 49 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 50 | <div class="dashboard-section-title">REGISTRATION STATUS</div> | ||
| 51 | <div class="dashboard-section-links"></div> | ||
| 52 | <div class="dashboard-section-content small"> | ||
| 53 | <select name="status"> | ||
| 54 | <option value="paid" <?php echo ($user_event_meta['status']=="paid") ? "selected" : ""; ?>>Paid</option> | ||
| 55 | <option value="invoice" <?php echo ($user_event_meta['status']=="invoice") ? "selected" : ""; ?>>Invoice</option> | ||
| 56 | <option value="free" <?php echo ($user_event_meta['status']=="free") ? "selected" : ""; ?>>Free</option> | ||
| 57 | </select> | ||
| 58 | </div> | ||
| 59 | </div> | ||
| 60 | |||
| 61 | <?php | ||
| 62 | if (!empty($show_dietary)): ?> | ||
| 63 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 64 | <div class="dashboard-section-title">SPECIAL DIETARY REQUIREMENTS</div> | ||
| 65 | <div class="dashboard-section-links"></div> | ||
| 66 | <div class="dashboard-section-content small"> | ||
| 67 | <textarea name="dietary" class="input-field-css input-large" rows="5" style="width:350px;"><?php echo isset($extras['dietary']) ? $extras['dietary'] : ""; ?></textarea> | ||
| 68 | </div> | ||
| 69 | </div> | ||
| 70 | <?php endif; ?> | ||
| 71 | |||
| 72 | <?php if (!empty($mealopt_description) || !empty($mealopt_one) || !empty($mealopt_two) || !empty($mealopt_three) || !empty($mealopt_four)):?> | ||
| 73 | |||
| 74 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 75 | <div class="dashboard-section-title">MEAL OPTIONS</div> | ||
| 76 | <div class="dashboard-section-links"></div> | ||
| 77 | <div class="dashboard-section-content small"> | ||
| 78 | <?php if (!empty($mealopt_description)) { echo "<div><strong>".$mealopt_description."</strong></div>"; } ?> | ||
| 79 | <table class="clean no-left-padding"> | ||
| 80 | <tbody> | ||
| 81 | <?php if (!empty($mealopt_one) && $mealopt_one != ""):?> | ||
| 82 | <tr> | ||
| 83 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_one" value="on" <?php echo (isset($extras['mealopt_one'])) ? "checked" : ""; ?> /></th> | ||
| 84 | <td><?php echo $mealopt_one; ?></td> | ||
| 85 | </tr> | ||
| 86 | <?php endif; ?> | ||
| 87 | |||
| 88 | <?php if (!empty($mealopt_two) && $mealopt_two != ""):?> | ||
| 89 | <tr> | ||
| 90 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_two" value="on" <?php echo (isset($extras['mealopt_two'])) ? "checked" : ""; ?> /></th> | ||
| 91 | <td><?php echo $mealopt_two; ?></td> | ||
| 92 | </tr> | ||
| 93 | <?php endif; ?> | ||
| 94 | |||
| 95 | <?php if (!empty($mealopt_three) && $mealopt_three != ""):?> | ||
| 96 | <tr> | ||
| 97 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_three" value="on" <?php echo (isset($extras['mealopt_three'])) ? "checked" : ""; ?> /></th> | ||
| 98 | <td><?php echo $mealopt_three; ?></td> | ||
| 99 | </tr> | ||
| 100 | <?php endif; ?> | ||
| 101 | |||
| 102 | <?php if (!empty($mealopt_four) && $mealopt_four != ""):?> | ||
| 103 | <tr> | ||
| 104 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_four" value="on" <?php echo (isset($extras['mealopt_four'])) ? "checked" : ""; ?> /></th> | ||
| 105 | <td><?php echo $mealopt_four; ?></td> | ||
| 106 | </tr> | ||
| 107 | <?php endif; ?> | ||
| 108 | |||
| 109 | <?php if (!empty($mealopt_five) && $mealopt_five != ""):?> | ||
| 110 | <tr> | ||
| 111 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_five" value="on" <?php echo (isset($extras['mealopt_five'])) ? "checked" : ""; ?> /></th> | ||
| 112 | <td><?php echo $mealopt_five; ?></td> | ||
| 113 | </tr> | ||
| 114 | <?php endif; ?> | ||
| 115 | |||
| 116 | <?php if (!empty($mealopt_six) && $mealopt_six != ""):?> | ||
| 117 | <tr> | ||
| 118 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_six" value="on" <?php echo (isset($extras['mealopt_six'])) ? "checked" : ""; ?> /></th> | ||
| 119 | <td><?php echo $mealopt_six; ?></td> | ||
| 120 | </tr> | ||
| 121 | <?php endif; ?> | ||
| 122 | |||
| 123 | <?php if (!empty($mealopt_seven) && $mealopt_seven != ""):?> | ||
| 124 | <tr> | ||
| 125 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_seven" value="on" <?php echo (isset($extras['mealopt_seven'])) ? "checked" : ""; ?> /></th> | ||
| 126 | <td><?php echo $mealopt_seven; ?></td> | ||
| 127 | </tr> | ||
| 128 | <?php endif; ?> | ||
| 129 | |||
| 130 | <?php if (!empty($mealopt_eight) && $mealopt_eight != ""):?> | ||
| 131 | <tr> | ||
| 132 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_eight" value="on" <?php echo (isset($extras['mealopt_eight'])) ? "checked" : ""; ?> /></th> | ||
| 133 | <td><?php echo $mealopt_eight; ?></td> | ||
| 134 | </tr> | ||
| 135 | <?php endif; ?> | ||
| 136 | |||
| 137 | <?php if (!empty($mealopt_nine) && $mealopt_nine != ""):?> | ||
| 138 | <tr> | ||
| 139 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_nine" value="on" <?php echo (isset($extras['mealopt_nine'])) ? "checked" : ""; ?> /></th> | ||
| 140 | <td><?php echo $mealopt_nine; ?></td> | ||
| 141 | </tr> | ||
| 142 | <?php endif; ?> | ||
| 143 | |||
| 144 | <?php if (!empty($mealopt_ten) && $mealopt_ten != ""):?> | ||
| 145 | <tr> | ||
| 146 | <th width="40" style="text-align:right;"><input type="checkbox" name="mealopt_ten" value="on" <?php echo (isset($extras['mealopt_ten'])) ? "checked" : ""; ?> /></th> | ||
| 147 | <td><?php echo $mealopt_ten; ?></td> | ||
| 148 | </tr> | ||
| 149 | <?php endif; ?> | ||
| 150 | |||
| 151 | |||
| 152 | </tbody> | ||
| 153 | </table> | ||
| 154 | </div> | ||
| 155 | </div> | ||
| 156 | <?php endif; ?> | ||
| 157 | |||
| 158 | <?php if (!empty($session_description) || !empty($session_one) || !empty($session_two) || !empty($session_three) || !empty($session_four) || !empty($session_five) || !empty($session_six)):?> | ||
| 159 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 160 | <div class="dashboard-section-title">SESSION OPTIONS</div> | ||
| 161 | <div class="dashboard-section-links"></div> | ||
| 162 | <div class="dashboard-section-content small"> | ||
| 163 | <?php if (!empty($session_description)) { echo "<div><strong>".$session_description."</strong></div>"; } ?> | ||
| 164 | <table class="clean no-left-padding"> | ||
| 165 | <tbody> | ||
| 166 | |||
| 167 | <?php if (!empty($session_one)):?> | ||
| 168 | <tr> | ||
| 169 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_one" value="on" <?php echo (isset($extras['session_one'])) ? "checked" : ""; ?> /></th> | ||
| 170 | <td><?php echo $session_one; ?></td> | ||
| 171 | </tr> | ||
| 172 | <?php endif; ?> | ||
| 173 | |||
| 174 | <?php if (!empty($session_two)):?> | ||
| 175 | <tr> | ||
| 176 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_two" value="on" <?php echo (isset($extras['session_two'])) ? "checked" : ""; ?> /></th> | ||
| 177 | <td><?php echo $session_two; ?></td> | ||
| 178 | </tr> | ||
| 179 | <?php endif; ?> | ||
| 180 | |||
| 181 | <?php if (!empty($session_three)):?> | ||
| 182 | <tr> | ||
| 183 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_three" value="on" <?php echo (isset($extras['session_three'])) ? "checked" : ""; ?> /></th> | ||
| 184 | <td><?php echo $session_three; ?></td> | ||
| 185 | </tr> | ||
| 186 | <?php endif; ?> | ||
| 187 | |||
| 188 | <?php if (!empty($session_four)):?> | ||
| 189 | <tr> | ||
| 190 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_four" value="on" <?php echo (isset($extras['session_four'])) ? "checked" : ""; ?> /></th> | ||
| 191 | <td><?php echo $session_four; ?></td> | ||
| 192 | </tr> | ||
| 193 | <?php endif; ?> | ||
| 194 | |||
| 195 | <?php if (!empty($session_five)):?> | ||
| 196 | <tr> | ||
| 197 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_five" value="on" <?php echo (isset($extras['session_five'])) ? "checked" : ""; ?> /></th> | ||
| 198 | <td><?php echo $session_five; ?></td> | ||
| 199 | </tr> | ||
| 200 | <?php endif; ?> | ||
| 201 | |||
| 202 | <?php if (!empty($session_six)):?> | ||
| 203 | <tr> | ||
| 204 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_six" value="on" <?php echo (isset($extras['session_six'])) ? "checked" : ""; ?> /></th> | ||
| 205 | <td><?php echo $session_six; ?></td> | ||
| 206 | </tr> | ||
| 207 | <?php endif; ?> | ||
| 208 | |||
| 209 | <?php if (!empty($session_seven)):?> | ||
| 210 | <tr> | ||
| 211 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_seven" value="on" <?php echo (isset($extras['session_seven'])) ? "checked" : ""; ?> /></th> | ||
| 212 | <td><?php echo $session_seven; ?></td> | ||
| 213 | </tr> | ||
| 214 | <?php endif; ?> | ||
| 215 | |||
| 216 | <?php if (!empty($session_eight)):?> | ||
| 217 | <tr> | ||
| 218 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_eight" value="on" <?php echo (isset($extras['session_eight'])) ? "checked" : ""; ?> /></th> | ||
| 219 | <td><?php echo $session_eight; ?></td> | ||
| 220 | </tr> | ||
| 221 | <?php endif; ?> | ||
| 222 | |||
| 223 | <?php if (!empty($session_nine)):?> | ||
| 224 | <tr> | ||
| 225 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_nine" value="on" <?php echo (isset($extras['session_nine'])) ? "checked" : ""; ?> /></th> | ||
| 226 | <td><?php echo $session_nine; ?></td> | ||
| 227 | </tr> | ||
| 228 | <?php endif; ?> | ||
| 229 | |||
| 230 | <?php if (!empty($session_ten)):?> | ||
| 231 | <tr> | ||
| 232 | <th width="40" style="text-align:right;"><input type="checkbox" name="session_ten" value="on" <?php echo (isset($extras['session_ten'])) ? "checked" : ""; ?> /></th> | ||
| 233 | <td><?php echo $session_ten; ?></td> | ||
| 234 | </tr> | ||
| 235 | <?php endif; ?> | ||
| 236 | |||
| 237 | </tbody> | ||
| 238 | </table> | ||
| 239 | </div> | ||
| 240 | </div> | ||
| 241 | <?php endif; ?> | ||
| 242 | |||
| 243 | |||
| 244 | <div class="dashboard-section" style="margin-left:20px;margin-top:10px;"> | ||
| 245 | <div class="dashboard-section-title"></div> | ||
| 246 | <div class="dashboard-section-links"></div> | ||
| 247 | <div class="dashboard-section-content small"> | ||
| 248 | <div><input type="submit" value="<?php echo ($action=="edit") ? "Update" : "Register"; ?>" /></div> | ||
| 249 | </div> | ||
| 250 | </div> | ||
| 251 | |||
| 252 | </form> | ||
| 253 | |||
| 254 | </body> | ||
| 255 | </html> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment