PageRenderTime 34ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/media/com_easyblog/scripts_/eblog.js

https://bitbucket.org/pastor399/newcastleunifc
JavaScript | 1756 lines | 1320 code | 264 blank | 172 comment | 182 complexity | 420ded0a56040bca96aad530d4b8ef0f MD5 | raw file
  1. /**
  2. * @package EasyBlog
  3. * @copyright Copyright (C) 2010 Stack Ideas Private Limited. All rights reserved.
  4. * @license GNU/GPL, see LICENSE.php
  5. *
  6. * EasyBlog is free software. This version may have been modified pursuant
  7. * to the GNU General Public License, and as distributed it includes or
  8. * is derivative of works licensed under the GNU General Public License or
  9. * other free or open source software licenses.
  10. * See COPYRIGHT.php for copyright notices and details.
  11. */
  12. EasyBlog.module('eblog', function($){
  13. var module = this;
  14. window.isSave = false;
  15. var eblog = window.eblog = {
  16. stream: {
  17. load: function( startlimit ){
  18. ejax.load( 'dashboard' , 'loadStream' , startlimit );
  19. }
  20. },
  21. login:{
  22. toggle: function(){
  23. $( '#easyblog-search-form' ).hide().siblings().removeClass('active');
  24. $( '.user-options' ).hide().siblings().removeClass('active');
  25. $( '#easyblog-login-form' ).toggle();
  26. $( '#easyblog-login-form' ).siblings().toggleClass('active')
  27. }
  28. },
  29. report:{
  30. show: function( objId , objType ){
  31. EasyBlog.ajax( 'site.views.reports.show' , {
  32. id: objId,
  33. type: objType
  34. }, function( title , html ){
  35. ejax.dialog( { 'title' : title , 'content' : html } );
  36. });
  37. }
  38. },
  39. search:{
  40. toggle: function(){
  41. $( '.user-options' ).hide().siblings().removeClass('active');
  42. $( '#easyblog-login-form' ).hide().siblings().removeClass('active');
  43. $( '#easyblog-search-form' ).toggle();
  44. $( '#easyblog-search-form' ).siblings().toggleClass( 'active' );
  45. }
  46. },
  47. toolbar:{
  48. dashboard: function(){
  49. $( '#easyblog-search-form' ).hide();
  50. $( '#easyblog-login-form' ).hide();
  51. $( '.user-options' ).toggle();
  52. $( '.user-options' ).siblings().toggleClass( 'active' );
  53. }
  54. },
  55. images: {
  56. initFancybox: function(element, options) {
  57. if (window.eblog_lightbox_strip_extension && window.eblog_lightbox_title) {
  58. $(element).each(function(){
  59. var el = $(this),
  60. title = el.attr("title"),
  61. parts = title.split(".").reverse();
  62. if (/jpg|png|gif|xcf|odg|bmp|jpeg/.test(parts[0].toLowerCase())) {
  63. parts.splice(0, 1);
  64. }
  65. title = parts.reverse().join('.');
  66. el.fancybox($.extend(true, {}, options, {title: title}));
  67. });
  68. } else {
  69. $(element).fancybox(options);
  70. }
  71. },
  72. initCaption: function(images) {
  73. $(images).each(function(i, image){
  74. var image = $(image).removeClass("easyblog-image-caption");
  75. if (image.parents(".easyblog-image-caption-container").length > 0) {
  76. return;
  77. }
  78. var imageUrl = $(image).attr("src"),
  79. hasFancybox = image.parent().hasClass("easyblog-thumb-preview");
  80. var hasSiblings = function(image) {
  81. var image = image[0],
  82. value = false;
  83. $.each(image.parentNode.childNodes, function(i, node){
  84. if (node!=image && !$(node).hasClass("easyblog-image-caption") && !$(node).hasClass("easyblog-thumb-preview")) {
  85. value = true;
  86. }
  87. });
  88. return value;
  89. }
  90. // Reinject src so we can trigger the load function
  91. image
  92. .one("load", function() {
  93. var target = (hasFancybox) ? image.parent() : image;
  94. // Decide where to float
  95. var orientation = target.css("float");
  96. if (orientation=="none") {
  97. orientation = image.css("float");
  98. }
  99. if (orientation=="none") {
  100. var props = (image.attr("style") || "").split(";"),
  101. css = {};
  102. $.each(props, function(i, prop){
  103. var _prop = prop.split(":");
  104. css[$.trim(_prop[0])] = $.trim(_prop[1]);
  105. });
  106. if (css["margin-left"]=="auto" && css["margin-right"]=="auto") {
  107. orientation = "center";
  108. }
  109. }
  110. // Use alignment
  111. if (orientation=="none") {
  112. var alignment = image.parent().attr("align");
  113. if (alignment===undefined || alignment=="none") {
  114. alignment = image.attr("align");
  115. }
  116. switch (alignment) {
  117. case "left":
  118. orientation = "left";
  119. break;
  120. case "right":
  121. orientation = "right";
  122. break;
  123. case "center":
  124. case "middle":
  125. orientation = "center";
  126. break;
  127. }
  128. }
  129. if (!/none|center/.test(orientation)) {
  130. orientation = ((hasSiblings(target)) ? "float" : "align") + orientation;
  131. }
  132. // Prepare container
  133. var container =
  134. $("<span>")
  135. .addClass("easyblog-image-caption-container orientation-" + orientation);
  136. if (orientation=="center" || orientation=="alignright" || orientation=="alignleft") {
  137. var additionalWrapper = $("<span>");
  138. target.wrap(additionalWrapper);
  139. target.parent().wrap(container);
  140. } else {
  141. // Insert container
  142. target.wrap(container);
  143. }
  144. // Prepare caption
  145. var caption = $("<span>").addClass("easyblog-image-caption");
  146. caption
  147. .width(target.outerWidth())
  148. .html(image.attr("title"));
  149. // Insert caption
  150. target.after(caption);
  151. })
  152. .removeAttr("src")
  153. .attr("src", imageUrl);
  154. });
  155. }
  156. },
  157. captcha: {
  158. reload: function(){
  159. var previousId = $( '#captcha-id' ).val();
  160. ejax.load( 'entry' , 'reloadCaptcha' , previousId );
  161. },
  162. reloadImage: function( id , source ){
  163. $( '#captcha-image' ).attr( 'src' , source );
  164. $( '#captcha-id' ).val( id );
  165. $( '#captcha-response' ).val( '' );
  166. }
  167. },
  168. comments:{
  169. edit: function( id ){
  170. ejax.load( 'entry' , 'editComment' , id );
  171. },
  172. remove: function( id ){
  173. ejax.load( 'entry' , 'deleteComment' , id );
  174. }
  175. },
  176. checkbox: {
  177. render: function(){
  178. // Transform all checkboxes into nicer switches
  179. $( '.option-enable' ).click( function(){
  180. var parent = $(this).parent();
  181. $( '.option-disable' , parent ).removeClass( 'selected' );
  182. $( this ).addClass( 'selected' );
  183. $( '.radiobox' , parent ).attr( 'value' , 1 );
  184. });
  185. $( '.option-disable' ).click( function(){
  186. var parent = $(this).parent();
  187. $( '.option-enable' , parent ).removeClass( 'selected' );
  188. $( this ).addClass( 'selected' );
  189. $( '.radiobox' , parent ).attr( 'value' , 0 );
  190. });
  191. }
  192. },
  193. drafts: {
  194. getContent: null,
  195. // Frequency of draft checks by default to 5 seconds
  196. frequency: 15000,
  197. chars: 0,
  198. check: function(){
  199. // Returns the content
  200. var content = eblog.drafts.getContent();
  201. if( typeof content == 'undefined' )
  202. {
  203. return;
  204. }
  205. var title = $("#title").val();
  206. if( content.length > 0 || ( title.length > 0 && title != emptyText ))
  207. {
  208. // Only run this when there's more contents
  209. ejax.load( 'dashboard' , 'saveDraft' , ejax.getFormVal( '#blogForm' ) , content , '' );
  210. }
  211. setTimeout( 'eblog.drafts.check()', eblog.drafts.frequency );
  212. },
  213. save: function() {
  214. //do submitting
  215. eblog.editor.toggleSave();
  216. $(window).unbind('beforeunload');
  217. $('#form-task').val('savedraft');
  218. var data = eblog.editor.getContent(),
  219. content = $( '<div>' ).html( data ).html();
  220. $('#write_content_hidden' ).val( content );
  221. $('#blogForm').submit();
  222. }
  223. },
  224. subscription: {
  225. // show subscription
  226. show: function( type , id ) {
  227. ejax.load( 'subscription', 'showForm' , type , id );
  228. },
  229. submit: function( type ) {
  230. eblog.loader.loading( 'eblog_loader' );
  231. ejax.load( 'subscription', 'submitForm', type , ejax.getFormVal('#frmSubscribe') );
  232. }
  233. },
  234. /**
  235. * Dashboard
  236. */
  237. dashboard: {
  238. logout: function(){
  239. $( '#eblog-logout' ).submit();
  240. },
  241. changeCollab: function( type ){
  242. $( '#blog_contribute_source' ).val( type );
  243. },
  244. changeAuthor: function( title , url ){
  245. ejax.dialog({
  246. width: 700,
  247. height: 500,
  248. title: title ,
  249. content: '',
  250. beforeDisplay: function(){
  251. var dialog = $(this);
  252. // Remove padding from dialog
  253. dialog.find('.dialog-middle').css('padding', 0);
  254. },
  255. afterDisplay: function(){
  256. var dialog = $(this);
  257. // Add iframe
  258. $('<iframe>')
  259. .attr('src', url )
  260. .css({
  261. width: dialog.find('.dialog-middle').width(),
  262. height: dialog.find('.dialog-middle').height(),
  263. border: 'none'
  264. })
  265. .appendTo(dialog.find('.dialog-middle-content'));
  266. }
  267. });
  268. },
  269. changeCategory: function( title, url ){
  270. ejax.dialog({
  271. width: 700,
  272. height: 500,
  273. title: title ,
  274. content: '',
  275. beforeDisplay: function(){
  276. var dialog = $(this);
  277. // Remove padding from dialog
  278. dialog.find('.dialog-middle').css('padding', 0);
  279. },
  280. afterDisplay: function(){
  281. var dialog = $(this);
  282. // Add iframe
  283. $('<iframe>')
  284. .attr('src', url )
  285. .css({
  286. width: dialog.find('.dialog-middle').width(),
  287. height: dialog.find('.dialog-middle').height(),
  288. border: 'none'
  289. })
  290. .appendTo(dialog.find('.dialog-middle-content'));
  291. }
  292. });
  293. },
  294. socialshare: {
  295. setActive: function( element ){
  296. $( element ).parent().toggleClass( 'active' );
  297. }
  298. },
  299. drafts: {
  300. discard: function( cids ){
  301. ejax.load( 'dashboard' , 'confirmDeleteDraft' , cids );
  302. },
  303. discardAll: function(){
  304. ejax.load( 'dashboard' , 'confirmDeleteAllDraft' );
  305. }
  306. },
  307. lists: {
  308. init: function( element ){
  309. $( '#dashboard-'+ element ).checkList({
  310. checkbox: ".stackSelect",
  311. masterCheckbox: ".stackSelectAll",
  312. check: function(){
  313. this.parent('.ui-list-select').addClass('active');
  314. $('#select-actions').show();
  315. },
  316. uncheck: function(){
  317. this.parent('.ui-list-select').removeClass('active');
  318. $('#select-actions').hide();
  319. },
  320. change: function(selected, deselected){
  321. }
  322. });
  323. }
  324. },
  325. toggle: function( element ){
  326. if( $( element ).parent().next().css( 'display' ) == 'block' )
  327. {
  328. $( element ).parent().addClass( 'ui-togbox' );
  329. $( element ).parent().next().hide();
  330. }
  331. else
  332. {
  333. $( element ).parent().removeClass( 'ui-togbox' );
  334. $( element ).parent().next().show();
  335. }
  336. },
  337. quickpost: {
  338. notify: function( type , message ){
  339. $( '#eblog-message' ).removeClass( 'error info success' ).addClass( type );
  340. $( '#eblog-message div' ).html( message );
  341. $( '#eblog-message').show();
  342. },
  343. save: function(){
  344. eblog.loader.loading( 'quickpost-loading' );
  345. var values = ejax.getFormVal( '#quick-post' );
  346. ejax.load( 'dashboard' , 'save' , values );
  347. },
  348. draft: function(){
  349. eblog.loader.loading( 'quickdraft-loading' );
  350. var content = $( '#eblog-post-content' ).val();
  351. // Only run this when there's more contents
  352. ejax.load( 'dashboard' , 'quickSaveDraft' , ejax.getFormVal( '#quick-post' ) , content , '' );
  353. }
  354. },
  355. settings: {
  356. submit: function(){
  357. // Validate password
  358. if( $( '#password' ).val() != '' || $( '#password2' ).val() != '' )
  359. {
  360. if( $( '#password' ).val() != $( '#password2' ).val() )
  361. {
  362. $( '.password-notice' ).show();
  363. return false;
  364. }
  365. }
  366. $( '#dashboard' ).submit();
  367. }
  368. },
  369. categories:{
  370. create: function(){
  371. if( $( '#widget-create-category' ).css( 'display' ) == 'block' )
  372. {
  373. $( '#widget-create-category' ).slideUp();
  374. }
  375. else
  376. {
  377. $( '#widget-create-category' ).slideDown();
  378. }
  379. return false;
  380. },
  381. edit: function( id ) {
  382. ejax.load( 'dashboard', 'editCategory' , id );
  383. },
  384. remove: function( url , id ){
  385. ejax.load( 'dashboard' , 'confirmDeleteCategory' , id , url );
  386. },
  387. quicksave: function( name ){
  388. ejax.load( 'dashboard' , 'quickSaveCategory' , name);
  389. }
  390. },
  391. comments: {
  392. publish: function( id , status ){
  393. ejax.load( 'dashboard' , 'publishComment' , id , status );
  394. },
  395. publishModerated: function( id , status ){
  396. ejax.load( 'dashboard' , 'publishModerateComment' , id , status );
  397. },
  398. edit: function( id ){
  399. ejax.load( 'dashboard' , 'editComment' , id );
  400. },
  401. remove: function( url , id ){
  402. ejax.load( 'dashboard' , 'confirmDeleteComment' , id , url );
  403. }
  404. },
  405. action: function( element , redirect ){
  406. var action = $( '#' + element + '-action' ).val();
  407. var form = '#' + element + '-form';
  408. var cids = '';
  409. $( form + ' INPUT[name="cid[]"]').each( function() {
  410. if ( $(this).attr('checked') ) {
  411. if(cids.length == 0)
  412. {
  413. cids = $(this).val();
  414. }
  415. else
  416. {
  417. cids = cids + ',' + $(this).val();
  418. }
  419. }
  420. });
  421. if( cids == '' )
  422. {
  423. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ONE_ITEM_TO_CONTINUE', 'COM_EASYBLOG_WARNING');
  424. return;
  425. }
  426. switch( action )
  427. {
  428. case 'copy':
  429. // Copy blog posts
  430. ejax.load( 'dashboard' , 'copyForm' , cids );
  431. break;
  432. case 'discardDraft':
  433. eblog.dashboard.drafts.discard( cids );
  434. break;
  435. case 'publishBlog':
  436. eblog.blog.togglePublish( cids , 'publish' );
  437. break;
  438. case 'unpublishBlog':
  439. eblog.blog.togglePublish( cids , 'unpublish' );
  440. break;
  441. case 'deleteBlog':
  442. eblog.blog.confirmDelete( cids , redirect );
  443. break;
  444. case 'rejectBlog':
  445. eblog.editor.reject( cids );
  446. break;
  447. case 'unpublishComment':
  448. eblog.dashboard.comments.publish( cids , 'unpublish' );
  449. break;
  450. case 'publishComment':
  451. eblog.dashboard.comments.publish( cids , 'publish' );
  452. break;
  453. case 'removeComment':
  454. eblog.dashboard.comments.remove( redirect , cids, '' );
  455. break;
  456. default :
  457. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ACTION_TO_PERFORM', 'COM_EASYBLOG_WARNING');
  458. break;
  459. }
  460. },
  461. videos:{
  462. insert: function( editor ){
  463. var url = $( '#video-source' ).val();
  464. var width = $( '#video-width' ).val();
  465. var height = $( '#video-height' ).val();
  466. var data = '[embed=videolink]'
  467. + '{"video":"' + url + '","width":"' + width + '","height":"' + height + '"}'
  468. + '[/embed]';
  469. jInsertEditorText( data , editor )
  470. ejax.closedlg();
  471. },
  472. showForm: function( editor ){
  473. try { IeCursorFix(); } catch(e) {};
  474. ejax.load( 'dashboard' , 'showVideoForm' , editor );
  475. }
  476. },
  477. preview: function( itemId ) {
  478. var content = eblog.drafts.getContent();
  479. if( typeof content == 'undefined' )
  480. {
  481. return;
  482. }
  483. var title = $("#title").val();
  484. if( content.length > 0 && ( title.length > 0 && title != emptyText ))
  485. {
  486. ejax.call('dashboard','saveDraft', [ejax.getFormVal( '#blogForm' ), content, ''], {
  487. success: function(){
  488. //second step
  489. var draftId = $('#draft_id').val();
  490. if( draftId != '')
  491. { var url = $.rootPath + 'index.php?option=com_easyblog&view=entry&layout=preview&draftid=' + draftId + '&Itemid=' + itemId,
  492. width = screen.width,
  493. height = screen.height,
  494. left = (screen.width/2)-( width /2),
  495. top = (screen.height/2)-(height/2);
  496. window.open( url , '' , 'toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, width='+width+', height='+height+', top='+top+', left='+left );
  497. }
  498. }
  499. });
  500. }
  501. else
  502. {
  503. if( content.length > 0 )
  504. {
  505. eblog.system.alert('COM_EASYBLOG_PLEASE_SET_TITLE_BEFORE_PREVIEW', 'COM_EASYBLOG_ENTRY_PREVIEW_MODE');
  506. }
  507. else
  508. {
  509. eblog.system.alert('COM_EASYBLOG_ENTRY_PREVIEW_MODE_NO_CONTENT', 'COM_EASYBLOG_ENTRY_PREVIEW_MODE');
  510. }
  511. }
  512. }
  513. },
  514. /**
  515. * Ratings
  516. **/
  517. ratings:{
  518. setup: function( elementId , disabled , ratingType ){
  519. $("#" + elementId ).stars({
  520. split: 2,
  521. disabled: disabled,
  522. oneVoteOnly: true,
  523. cancelShow: false,
  524. callback: function( element ){
  525. eblog.loader.loading( elementId + '-command .rating-text' );
  526. ejax.load( 'ratings' , 'vote' , element.value() , $( '#' + elementId ).children( 'input:hidden' ).val() , ratingType , elementId );
  527. }
  528. });
  529. },
  530. showVoters: function( elementId , elementType ){
  531. ejax.load( 'ratings' , 'showvoters' , elementId , elementType );
  532. },
  533. update: function( elementId , ratingType , value , resultCommand ){
  534. $( '#' + elementId ).children( '.ui-stars-star' ).removeClass( 'ui-stars-star-on' );
  535. value = parseInt( value );
  536. // Hide command
  537. $( '#' + elementId + '-command' ).hide();
  538. $( '#' + elementId ).addClass( 'voted' );
  539. $( '#' + elementId ).children( '.ui-stars-star' ).each( function( index ){
  540. if( index < value )
  541. {
  542. $( this ).addClass( 'ui-stars-star-on' );
  543. }
  544. else
  545. {
  546. $( this ).removeClass( 'ui-stars-star-on' );
  547. }
  548. });
  549. }
  550. },
  551. /**
  552. * Editor
  553. */
  554. editor: {
  555. checkPublishStatus: function() {
  556. var status = $('#published').val();
  557. var unpublishdate = $('#publish_down').val();
  558. if(unpublishdate == '' || unpublishdate == '0000-00-00 00:00:00')
  559. {
  560. eblog.editor.postSubmit();
  561. return true;
  562. }
  563. ejax.load( 'dashboard' , 'checkPublishStatus' , status, unpublishdate);
  564. return true;
  565. },
  566. cancelSubmit: function() {
  567. isSave = false;
  568. $("#save_post").attr('disabled', '');
  569. return false;
  570. },
  571. postSubmit: function () {
  572. //do submitting
  573. $(window).unbind('beforeunload');
  574. $('#blogForm').submit();
  575. },
  576. // save the post
  577. save: function() {
  578. eblog.editor.toggleSave();
  579. // Retrieve the main content.
  580. var editorContents = eblog.editor.getContent();
  581. // Try to break the parts with the read more.
  582. var val = editorContents.split( '<hr id="system-readmore" />' );
  583. if( val.length > 1 )
  584. {
  585. // It has a read more tag
  586. var intro = $.sanitizeHTML( val[0] );
  587. var fulltext = $.sanitizeHTML( val[1] );
  588. var content = intro + '<hr id="system-readmore" />' + fulltext;
  589. }
  590. else
  591. {
  592. // Since there is no read more tag here, the first index is always the full content.
  593. var content = $.sanitizeHTML( editorContents );;
  594. }
  595. $( '#write_content_hidden' ).val( content );
  596. $('#save_post_button' ).addClass( 'ui-disabled' );
  597. $( '#save_post_button' ).attr( 'disabled' , 'disabled' );
  598. eblog.editor.checkPublishStatus();
  599. },
  600. apply: function(){
  601. $( 'input[name=apply]' ).val( 1 );
  602. eblog.editor.save();
  603. },
  604. reject: function( blogId ) {
  605. ejax.load( 'Dashboard' , 'confirmRejectBlog' , blogId );
  606. },
  607. search: {
  608. load: function(){
  609. try { IeCursorFix(); } catch(e) {};
  610. ejax.load( 'search' , 'search' , $( '#search-content' ).val() );
  611. },
  612. insert: function( value , title , editor ){
  613. var link = '<a href="'+value+'">'+title+'</a>';
  614. switch(editor)
  615. {
  616. case 'intro':
  617. if($( '#widget-write-introtext .ui-modhead' ).hasClass('ui-togbox'))
  618. {
  619. eblog.editor.setIntro(link);
  620. }
  621. else
  622. {
  623. jInsertEditorText( link, editor );
  624. }
  625. break;
  626. case 'write_content':
  627. if($( '#widget-writepost .ui-modhead' ).hasClass('ui-togbox'))
  628. {
  629. eblog.editor.setContent(link);
  630. }
  631. else
  632. {
  633. jInsertEditorText( link, editor );
  634. }
  635. break;
  636. default:
  637. //do nothing
  638. }
  639. }
  640. },
  641. setIntro: null,
  642. setContent: null,
  643. getContent: null,
  644. /**
  645. * Generate date time picker like Wordpress
  646. */
  647. datetimepicker: {
  648. element: function( id, reset ) {
  649. // Referenced from http://www.quackit.com/javascript/javascript_date_and_time_functions.cfm
  650. // Adds active class on the element.
  651. $( '#datetime_' + id ).addClass( 'toggle-active' );
  652. // Hide edit button
  653. $( '#datetime_edit_' + id ).hide();
  654. var day, month, year, hour, minute, ampm;
  655. eblog.editor.datetimepicker.hideEditLink(id);
  656. var day, month, year, hour, minute, ampm;
  657. eblog.editor.datetimepicker.hideEditLink(id);
  658. if( id == 'publish_down' && $('#' + id).val() == '')
  659. {
  660. var tmpStr = $('#publish_down_reset').val();
  661. $('#' + id).val(tmpStr);
  662. }
  663. if ( $('#' + id).val() != '' ) {
  664. var strValue = $('#' + id).val();
  665. var strTemp = strValue.split(' ');
  666. var strTime = strTemp[1].split(':');
  667. var strDate = strTemp[0].split('-');
  668. day = strDate[2];
  669. month = strDate[1];
  670. year = strDate[0];
  671. hour = strTime[0];
  672. minute = strTime[1];
  673. }
  674. else {
  675. today = new Date();
  676. day = today.getDate();
  677. month = today.getMonth() + 1; //in js, month start from 0, not 1
  678. year = today.getFullYear();
  679. hour = today.getHours();
  680. minute = today.getMinutes();
  681. }
  682. //minute = parseInt(minute);
  683. hour = parseInt(hour, 10);
  684. if (minute.length <= 1) {
  685. minute = '0' + minute;
  686. }
  687. if ( hour >= 12 ) {
  688. ampm = 'pm';
  689. }
  690. else {
  691. ampm = 'am';
  692. }
  693. if ( hour > 12 ) {
  694. hour -= 12;
  695. }
  696. if( ampm == 'am' && hour == 0)
  697. {
  698. hour = 12;
  699. }
  700. if( hour < 10 )
  701. {
  702. hour = '0' + hour;
  703. }
  704. var html = '';
  705. html += '<div class="dtpicker-wrap" id="dtpicker_'+id+'" style="display: none;">';
  706. html += ' <select tabindex="4" name="dt_month" id="dt_month_'+id+'">';
  707. html += ' <option value="01" '+ (month == '01' ? 'selected="selected"' : "" ) +'>'+ sJan +'</option>';
  708. html += ' <option value="02" '+ (month == '02' ? 'selected="selected"' : "" ) +'>'+ sFeb +'</option>';
  709. html += ' <option value="03" '+ (month == '03' ? 'selected="selected"' : "" ) +'>'+ sMar +'</option>';
  710. html += ' <option value="04" '+ (month == '04' ? 'selected="selected"' : "" ) +'>'+ sApr +'</option>';
  711. html += ' <option value="05" '+ (month == '05' ? 'selected="selected"' : "" ) +'>'+ sMay +'</option>';
  712. html += ' <option value="06" '+ (month == '06' ? 'selected="selected"' : "" ) +'>'+ sJun +'</option>';
  713. html += ' <option value="07" '+ (month == '07' ? 'selected="selected"' : "" ) +'>'+ sJul +'</option>';
  714. html += ' <option value="08" '+ (month == '08' ? 'selected="selected"' : "" ) +'>'+ sAug +'</option>';
  715. html += ' <option value="09" '+ (month == '09' ? 'selected="selected"' : "" ) +'>'+ sSep +'</option>';
  716. html += ' <option value="10" '+ (month == '10' ? 'selected="selected"' : "" ) +'>'+ sOct +'</option>';
  717. html += ' <option value="11" '+ (month == '11' ? 'selected="selected"' : "" ) +'>'+ sNov +'</option>';
  718. html += ' <option value="12" '+ (month == '12' ? 'selected="selected"' : "" ) +'>'+ sDec +'</option>';
  719. html += ' </select>';
  720. html += ' <input type="text" autocomplete="off" tabindex="4" maxlength="2" size="2" value="' + day + '" name="dt_day" id="dt_day_'+id+'">, ';
  721. html += ' <input type="text" autocomplete="off" tabindex="4" maxlength="4" size="4" value="' + year + '" name="dt_year" id="dt_year_'+id+'"> @ ';
  722. html += ' <input type="text" autocomplete="off" tabindex="4" maxlength="2" size="2" value="' + hour + '" name="dt_hour" id="dt_hour_'+id+'"> : ';
  723. html += ' <input type="text" autocomplete="off" tabindex="4" maxlength="2" size="2" value="' + minute + '" name="dt_min" id="dt_min_'+id+'">';
  724. html += ' <select tabindex="4" name="dt_ampm" id="dt_ampm_'+id+'">';
  725. html += ' <option value="am" ' + (ampm == "am" ? 'selected="selected"' : '') + '>'+ sAm +'</option>';
  726. html += ' <option value="pm" ' + (ampm == "pm" ? 'selected="selected"' : '') + '>'+ sPm +'</option>';
  727. html += ' </select>';
  728. html += ' <div class="dtpicker-action" id="dtpicker_action_'+id+'">';
  729. html += ' <a class="dtpicker-save ui-button" href="javascript:void(0);" onclick="eblog.editor.datetimepicker.save(\''+id+'\')">'+btnOK+'</a>';
  730. if ( reset )
  731. {
  732. html += ' <a class="dtpicker-reset" href="javascript:void(0);" onclick="eblog.editor.datetimepicker.reset(\''+id+'\')">'+btnReset+'</a>';
  733. }
  734. html += ' <a class="dtpicker-cancel" href="javascript:void(0);" onclick="eblog.editor.datetimepicker.cancel(\''+id+'\')">'+btnCancel+'</a>';
  735. html += ' </div>';
  736. html += '</div>';
  737. $(html).insertAfter('#datetime_' + id);
  738. $('#dtpicker_' + id).slideDown('fast');
  739. },
  740. reset: function(id) {
  741. $('#dtpicker_' + id).slideUp('fast');
  742. $('#' + id).val('');
  743. $('#datetime_' + id + ' .datetime_caption').html(sNever);
  744. eblog.editor.datetimepicker.showEditLink(id);
  745. },
  746. cancel: function(id) {
  747. $('#dtpicker_' + id).slideUp('fast');
  748. if( id == 'publish_down' && ($('#publish_down_ori').val() == '' || $('#publish_down_ori').val() == '0000-00-00 00:00:00'))
  749. {
  750. // make sure the value get remove.
  751. $('#' + id).val('');
  752. }
  753. // Remove toggle-active class once the cancel is clicked
  754. $( '#datetime_' + id ).removeClass( 'toggle-active' );
  755. eblog.editor.datetimepicker.showEditLink(id);
  756. },
  757. save: function(id) {
  758. $('#dtpicker_' + id).slideUp('fast');
  759. // Remove toggle-active class once the cancel is clicked
  760. $( '#datetime_' + id ).removeClass( 'toggle-active' );
  761. // construct date time
  762. var day, month, year, hour, minute, ampm;
  763. //today = new Date();
  764. day = $('#dtpicker_' + id + ' #dt_day_' + id).val();
  765. month = $('#dtpicker_' + id + ' #dt_month_' + id).val();
  766. month = parseInt(month, 10);
  767. if ( month < 10 ) {
  768. month = '0' + month;
  769. }
  770. year = $('#dtpicker_' + id + ' #dt_year_' + id).val();
  771. hour = $('#dtpicker_' + id + ' #dt_hour_' + id).val();
  772. ampm = $('#dtpicker_' + id + ' #dt_ampm_' + id).val();
  773. if ( ampm == 'pm' ) {
  774. switch ( parseInt(hour, 10) ) {
  775. case 12:
  776. //hour = parseInt(hour);
  777. break;
  778. default:
  779. hour = parseInt(hour, 10) + 12;
  780. break;
  781. }
  782. }
  783. else {
  784. switch ( parseInt(hour) ) {
  785. case 12:
  786. hour = '00';
  787. break;
  788. default:
  789. if ( hour.length <= 1) {
  790. hour = '0' + hour;
  791. }
  792. break;
  793. }
  794. }
  795. minute = $('#dtpicker_' + id + ' #dt_min_' + id).val();
  796. //minute = parseInt(minute);
  797. if ( minute.length <= 1) {
  798. minute = '0' + minute;
  799. }
  800. var setTime = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':00';
  801. $('#' + id).val(setTime);
  802. // $('#datetime_' + id + ' .datetime_caption').html(setTime);
  803. ejax.load( 'dashboard' , 'updateDisplayDate' , id, setTime);
  804. eblog.editor.datetimepicker.showEditLink(id);
  805. $('.dtpicker-wrap').remove();
  806. },
  807. showEditLink: function(id) {
  808. $('#datetime_edit_' + id ).show();
  809. },
  810. hideEditLink: function(id) {
  811. $('#datetime_edit_' + id ).hide();
  812. }
  813. },
  814. permalink: {
  815. edited: false,
  816. // get permalink from controller
  817. generate: function() {
  818. // We don't want to generate empty permalinks and
  819. // if the permalink is edited, we don't want to change the user's value.
  820. if( $('#title').val() != '' && !eblog.editor.permalink.edited )
  821. {
  822. ejax.load( 'dashboard' , 'getPermalink' , $('#title').val() );
  823. }
  824. },
  825. edit: function(){
  826. if( $( '#permalink-edit' ).css( 'display' ) == 'none' )
  827. {
  828. // We try to remember the state here so that permalink don't get
  829. // generated everytime we try to change the title.
  830. eblog.editor.permalink.edited = true;
  831. $( '#permalink-edit' ).show();
  832. $( '#permalink-value' ).hide();
  833. }
  834. else
  835. {
  836. $( '#permalink-edit' ).hide();
  837. $( '#permalink-value' ).show();
  838. }
  839. },
  840. save: function(){
  841. // Change the value of the display
  842. $( '#permalink-url' ).html( $( '#permalink-data').val() );
  843. // Hide the edit form first.
  844. eblog.editor.permalink.edit();
  845. }
  846. }
  847. },
  848. tags: {
  849. search: {
  850. init: function(){
  851. $('#filter-tags').keyup(function()
  852. {
  853. var text = $.trim($(this).val());
  854. $('.post-tags li')
  855. .hide()
  856. .filter(function()
  857. {
  858. return (this.textContent || this.innerText || '').toUpperCase().indexOf(text.toUpperCase()) >= 0
  859. })
  860. .show();
  861. });
  862. }
  863. }
  864. },
  865. loader:{
  866. item: null,
  867. loading: function( elementId ) {
  868. eblog.loader.item = elementId;
  869. $( '#' + elementId ).addClass( 'eblog_loader' );
  870. $( '#' + elementId ).show();
  871. },
  872. doneLoading: function(){
  873. if( eblog.loader.item != null )
  874. {
  875. $( '#' + eblog.loader.item ).removeClass( 'eblog_loader');
  876. }
  877. }
  878. },
  879. /**
  880. * All comment operations
  881. */
  882. comment: {
  883. /**
  884. * Comment like or dislike
  885. */
  886. likes: function(contentId, status, likeId) {
  887. eblog.loader.loading( 'likes-' + contentId );
  888. ejax.load('Entry', 'likesComment', contentId, status, likeId);
  889. },
  890. /**
  891. * Save comment
  892. */
  893. save: function() {
  894. //clear err-msg
  895. $('#eblog-message').removeClass('info error');
  896. $('#eblog-message').html('');
  897. eblog.loader.loading( 'comment-form-title' );
  898. finalData = ejax.getFormVal('#frmComment');
  899. ejax.load('Entry', 'commentSave', finalData);
  900. if ( $('#empty-comment-notice').length > 0 ) {
  901. $('#empty-comment-notice').fadeOut('100');
  902. }
  903. },
  904. /**
  905. * Reply to comment
  906. */
  907. reply: function( id , commentDepth , autoTitle ) {
  908. // hide all reply container
  909. $('.cancel_container').hide();
  910. // show all reply container
  911. $('.reply_container').show();
  912. //prepare the comment input form
  913. $('#comment-reply-form-' + id).show();
  914. var commentForm = $('#eblog-wrapper #frmComment').clone();
  915. $('#eblog-wrapper #frmComment').remove();
  916. $('#comment-reply-form-' + id).addClass('comment-form-inline').append(commentForm);
  917. $('#parent_id').val(id);
  918. $('#comment_depth').val(commentDepth);
  919. if(autoTitle)
  920. {
  921. //auto insert title
  922. var title = $('#comment-title-' + id).text();
  923. var reTitle = (title != '') ? 'RE:' + title : '';
  924. $('#title.inputbox').val(reTitle);
  925. }
  926. //toggle toolbar button
  927. //$('#toolbar-reply-' + id).hide();
  928. //$('#toolbar-cancel-' + id).show();
  929. // reset all reply/cancel to reply
  930. $('.comment-reply-no').removeClass('show-this');
  931. $('.comment-reply-yes').addClass('show-this');
  932. // set reply to cancel
  933. $('#toolbar-reply-' + id).removeClass('show-this');
  934. $('#toolbar-cancel-' + id).addClass('show-this');
  935. $('#toolbar-cancel-' + id).parent('.comment-reply').toggleClass('in-action');
  936. //need to check if bbcode enabled
  937. if($('.markItUpContainer').length > 0)
  938. {
  939. $("#comment").markItUpRemove();
  940. $("#comment").markItUp(EasyBlogBBCodeSettings);
  941. }
  942. },
  943. /**
  944. * Cancel comment reply
  945. */
  946. cancel: function(id) {
  947. //revert the comment input form
  948. var commentForm = $('#eblog-wrapper #comment-reply-form-' + id + ' #frmComment').clone();
  949. $('#eblog-wrapper #comment-reply-form-' + id + ' #frmComment').remove();
  950. $('#eblog-wrapper #comment-separator').after(commentForm);
  951. $('#parent_id').val('0');
  952. $('#comment_depth').val('0');
  953. $('#comment-reply-form-' + id).hide();
  954. $('#title.inputbox').val('');
  955. //toggle toolbar button
  956. //$('#toolbar-cancel-' + id).hide();
  957. //$('#toolbar-reply-' + id).toggleClass('hide-this');
  958. //$('#toolbar-reply-' + id).removeAttr('style');
  959. $('#toolbar-reply-' + id).toggleClass('show-this');
  960. $('#toolbar-cancel-' + id).toggleClass('show-this');
  961. $('#toolbar-cancel-' + id).parent('.comment-reply').toggleClass('in-action');
  962. //need to check if bbcode enabled
  963. if($('.markItUpContainer').length > 0)
  964. {
  965. $("#comment").markItUpRemove();
  966. $("#comment").markItUp(EasyBlogBBCodeSettings);
  967. }
  968. },
  969. /**
  970. * Save edit comment
  971. */
  972. edit: function() {
  973. //clear err-msg
  974. $('#eblog-message').removeClass('info error');
  975. $('#eblog-message').html('');
  976. //toggleSpinner(true);
  977. finalData = ejax.getFormVal('#frmComment');
  978. ejax.load('dashboard', 'updateComment', finalData);
  979. },
  980. /**
  981. * Actions
  982. */
  983. action: function(param, url) {
  984. var count = 0;
  985. var cids = "";
  986. var actionStr = $("#"+param).val();
  987. if(actionStr == '')
  988. {
  989. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ACTION_TO_PERFORM', 'COM_EASYBLOG_WARNING');
  990. return;
  991. }
  992. $("#adminForm INPUT[name='cid[]']").each( function() {
  993. if ( $(this).attr('checked') ) {
  994. if(cids.length == 0)
  995. {
  996. cids = $(this).val();
  997. }
  998. else
  999. {
  1000. cids = cids + ',' + $(this).val();
  1001. }
  1002. count++;
  1003. }
  1004. });
  1005. if(count <= 0)
  1006. {
  1007. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ONE_ITEM_TO_CONTINUE', 'COM_EASYBLOG_WARNING');
  1008. return;
  1009. }
  1010. if(actionStr == 'unpublishComment')
  1011. {
  1012. ejax.load('dashboard', 'publishComment', cids, '0', 'comment');
  1013. }
  1014. else if(actionStr == 'publishComment')
  1015. {
  1016. ejax.load('dashboard', 'publishComment', cids, '1', 'comment');
  1017. }
  1018. else if(actionStr == 'removeComment')
  1019. {
  1020. eblog.comment.confirm( url , cids, '');
  1021. }
  1022. },
  1023. confirm: function(url, commentId, lbl)
  1024. {
  1025. var targetUrl = url + '&task=removeComment&commentId=' + commentId;
  1026. var callback = 'window.location = "' + targetUrl + '";';
  1027. eblog.system.dialog('COM_EASYBLOG_ARE_YOU_SURE_YOU_WANT_TO_REMOVE_COMMENT', callback, 'CONFIRMATION');
  1028. return;
  1029. },
  1030. displayInlineMsg: function (msgType, msg)
  1031. {
  1032. //$('#err-msg').show();
  1033. $('#eblog-message').removeClass('info error');
  1034. $('#eblog-message').html(msg);
  1035. $('#eblog-message').addClass(msgType);
  1036. if(msgType == 'info')
  1037. {
  1038. setTimeout( function() {
  1039. $('#eblog-message').removeClass('info error');
  1040. $('#eblog-message').html('');
  1041. }, 6000);
  1042. }
  1043. }
  1044. },
  1045. /**
  1046. * Featured
  1047. */
  1048. featured: {
  1049. add: function(type, cid){
  1050. ejax.load('Latest', 'makeFeatured', type, cid);
  1051. },
  1052. remove: function(type, cid){
  1053. ejax.load('Latest', 'removeFeatured', type, cid);
  1054. },
  1055. slider: {
  1056. holderWidth: 0,
  1057. element: Array(),
  1058. autorotate: function( interval ){
  1059. var items = $( '#ezblog-featured .featured-a' ).children();
  1060. var set = false;
  1061. $( items ).each( function(){
  1062. if( $( this ).hasClass( 'active' ) && set != true )
  1063. {
  1064. if( $( this ).next().length == 0 )
  1065. {
  1066. // return to the parent
  1067. $( '#ezblog-featured .featured-a :first' ).click();
  1068. }
  1069. else
  1070. {
  1071. $( this ).next().click();
  1072. }
  1073. set = true;
  1074. }
  1075. });
  1076. setTimeout( 'eblog.featured.slider.autorotate(' + interval + ');' , interval );
  1077. },
  1078. init: function( sliderElement , autorotate , interval ){
  1079. eblog.featured.slider.element[ sliderElement ] = { 'width' : parseInt( $( '.' + sliderElement ).parent().width() ) , 'element' : '.' + sliderElement };
  1080. var total = 0;
  1081. $( eblog.featured.slider.element[ sliderElement ].element ).children().each( function(){
  1082. total += eblog.featured.slider.element[ sliderElement ].width;
  1083. });
  1084. $( eblog.featured.slider.element[ sliderElement ].element ).css( 'width' , total );
  1085. $( eblog.featured.slider.element[ sliderElement ].element ).children().css( 'width' , eblog.featured.slider.element[ sliderElement ].width );
  1086. if( autorotate )
  1087. {
  1088. interval = parseInt( interval ) * 1000;
  1089. setTimeout( 'eblog.featured.slider.autorotate(' + interval + ');' , interval );
  1090. }
  1091. },
  1092. slide: function( index , sliderElement ){
  1093. var left = 0;
  1094. var elementId = index;
  1095. if( index != 1 )
  1096. {
  1097. index -= 1;
  1098. left = eblog.featured.slider.element[ sliderElement ].width * parseInt( index );
  1099. }
  1100. $( eblog.featured.slider.element[ sliderElement ].element ).animate( { 'left' : '-' + left + 'px' } , 'slow' );
  1101. $( eblog.featured.slider.element[ sliderElement ].element ).parent().parent().children( 'div.featured-navi' ).children().children().removeClass( 'active' );
  1102. // Set active element for the slider buttons.
  1103. $( eblog.featured.slider.element[ sliderElement ].element ).parent().parent().children( 'div.featured-navi' ).children().children( '.slider-navi-' + elementId ).addClass( 'active' );
  1104. }
  1105. }
  1106. },
  1107. /**
  1108. * Spinner
  1109. */
  1110. spinner: {
  1111. // toggle btw the spinner and save button
  1112. show: function() {
  1113. $('#blogSubmitBtn').hide();
  1114. $('#blogSubmitWait').show();
  1115. },
  1116. // toggle btw the spinner and save button
  1117. hide: function() {
  1118. $('#blogSubmitWait').hide();
  1119. $('#blogSubmitBtn').show();
  1120. },
  1121. // for publish operation
  1122. publish: function(id, show) {
  1123. if(show == 1)
  1124. {
  1125. $("#"+id+"Spinner").html("<img src=\""+spinnerPath+"\" alt=\"Loading\">");
  1126. }
  1127. else
  1128. {
  1129. $("#"+id+"Spinner").html("");
  1130. }
  1131. }
  1132. },
  1133. /**
  1134. * Elements
  1135. */
  1136. element: {
  1137. focus: function(element) {
  1138. ele = '#' + element;
  1139. $(ele).focus();
  1140. ejax.closedlg();
  1141. }
  1142. },
  1143. /**
  1144. * Blog
  1145. */
  1146. blog: {
  1147. /**
  1148. * HTTP POST
  1149. */
  1150. publish: function(url, id, status) {
  1151. var targetUrl = url + '&task=toggleBlogStatus&status=' + status + '&blogId=' + id;
  1152. window.location = targetUrl;
  1153. },
  1154. remove: function(id, actionSrc) {
  1155. var id_str = "";
  1156. var src = (actionSrc) ? actionSrc : 'Dashboard';
  1157. $.each(id, function() {
  1158. eblog.spinner.publish(id, 1);
  1159. if(id_str!="")
  1160. {
  1161. id_str += ",";
  1162. }
  1163. id_str += this;
  1164. });
  1165. ejax.load('Dashboard', 'deleteBlog', id_str, src);
  1166. },
  1167. confirmDelete: function( ids , url ){
  1168. ejax.load( 'dashboard' , 'confirmDelete' , ids , url );
  1169. },
  1170. confirm: function(url, blogId, lbl) {
  1171. var targetUrl = url + '&task=deleteBlog&blogId=' + blogId;
  1172. var callback = 'window.location = "' + targetUrl + '";';
  1173. //console.log(callback);
  1174. //eblog.system.dialog( 'COM_EASYBLOG_ARE_YOU_SURE_YOU_WANT_TO_REMOVE_BLOG' , callback, 'CONFIRMATION');
  1175. return;
  1176. },
  1177. approve: function( url , blogId ) {
  1178. ejax.load( 'dashboard' , 'confirmApproveBlog' , blogId , url );
  1179. },
  1180. ajaxpublish: function(id, status, actionSrc) {
  1181. var id_str = "";
  1182. var src = (actionSrc) ? actionSrc : 'Dashboard';
  1183. $.each(id, function() {
  1184. eblog.spinner.publish( id , 1 );
  1185. if( id_str!="" )
  1186. {
  1187. id_str += ",";
  1188. }
  1189. id_str += this;
  1190. });
  1191. ejax.load( 'Dashboard', 'togglePublishStatus', id_str , status , src);
  1192. },
  1193. togglePublish: function( id , action ){
  1194. ejax.load( 'dashboard' , 'togglePublish' , id , action );
  1195. },
  1196. action: function( param , url ) {
  1197. var count = 0;
  1198. var cids = "";
  1199. var actionStr = $("#"+param).val();
  1200. if(actionStr == 'default')
  1201. {
  1202. return;
  1203. }
  1204. $("#adminForm INPUT[name='cid[]']").each( function() {
  1205. if ( $(this).attr('checked') ) {
  1206. if(cids.length == 0)
  1207. {
  1208. cids = $(this).val();
  1209. }
  1210. else
  1211. {
  1212. cids = cids + ',' + $(this).val();
  1213. }
  1214. count++;
  1215. }
  1216. });
  1217. if(count <= 0)
  1218. {
  1219. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ONE_ITEM_TO_CONTINUE', 'COM_EASYBLOG_WARNING');
  1220. return;
  1221. }
  1222. if(actionStr == 'unpublishBlog')
  1223. {
  1224. eblog.blog.togglePublish( cids , 'unpublish' );
  1225. }
  1226. else if(actionStr == 'publishBlog')
  1227. {
  1228. eblog.blog.togglePublish( cids , 'publish' );
  1229. }
  1230. else if(actionStr == 'deleteBlog')
  1231. {
  1232. eblog.blog.confirmDelete( cids , url );
  1233. }
  1234. },
  1235. /**
  1236. * Tab section in blog.read.php
  1237. */
  1238. tab: {
  1239. init: function() {
  1240. // hide all containers
  1241. $('.tab_container').hide();
  1242. // Show the first container
  1243. $( 'div.tab-wrapper .tab_container:first' ).show();
  1244. // Make the first tab active all the time.
  1245. $('.tab_item:first').addClass('item-active');
  1246. // Bind the click function on the tabs.
  1247. $('ul.tab_button li.tab_item a').click( function() {
  1248. var element = $(this).parent();
  1249. if ( element.hasClass( 'item-active' ) )
  1250. {
  1251. return false;
  1252. }
  1253. element.siblings().each( function(){
  1254. if( $(this).hasClass( 'item-active' ) )
  1255. {
  1256. $(this).removeClass( 'item-active' );
  1257. }
  1258. });
  1259. element.addClass( 'item-active' );
  1260. // hide all other container
  1261. $( '.tab_container' ).hide();
  1262. // get id from element
  1263. var _id = element.attr('id');
  1264. var _x = _id.split('-');
  1265. var id = _x[1];
  1266. $( '#section-' + id ).show();
  1267. return false;
  1268. });
  1269. }
  1270. },
  1271. /**
  1272. * ajax unsubscribe blog
  1273. */
  1274. unsubscribe: function( sid, bid )
  1275. {
  1276. ejax.load( 'entry' , 'confirmUnsubscribeBlog' , sid , bid );
  1277. }
  1278. },
  1279. /**
  1280. * Tags
  1281. */
  1282. tag: {
  1283. remove: function( redirect , tagId ) {
  1284. ejax.load( 'Dashboard' , 'confirmDeleteTag' , tagId , redirect );
  1285. },
  1286. edit: function(id) {
  1287. ejax.load('Dashboard', 'editTagDialog', id);
  1288. },
  1289. /**
  1290. * Actions
  1291. */
  1292. action: function(param, url) {
  1293. var count = 0;
  1294. var cids = "";
  1295. var actionStr = $("#"+param).val();
  1296. if(actionStr == '')
  1297. {
  1298. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ACTION_TO_PERFORM', 'COM_EASYBLOG_WARNING');
  1299. return;
  1300. }
  1301. $("#adminForm INPUT[name='cid[]']").each( function() {
  1302. if ( $(this).attr('checked') ) {
  1303. if(cids.length == 0)
  1304. {
  1305. cids = $(this).val();
  1306. }
  1307. else
  1308. {
  1309. cids = cids + ',' + $(this).val();
  1310. }
  1311. count++;
  1312. }
  1313. });
  1314. if(count <= 0)
  1315. {
  1316. eblog.system.alert('COM_EASYBLOG_PLEASE_SELECT_ONE_ITEM_TO_CONTINUE', 'COM_EASYBLOG_WARNING');
  1317. return;
  1318. }
  1319. if(actionStr == 'deleteTag')
  1320. {
  1321. eblog.tag.confirm(url, cids, '');
  1322. }
  1323. },
  1324. confirm: function(url, tagId, lbl)
  1325. {
  1326. var targetUrl = url + '&task=deleteTag&tagId=' + tagId;
  1327. var callback = 'window.location = "' + targetUrl + '";';
  1328. eblog.system.dialog('COM_EASYBLOG_ARE_YOU_SURE_YOU_WANT_TO_REMOVE_TAGS', callback, 'CONFIRMATION');
  1329. return;
  1330. },
  1331. save: function() {
  1332. finalData = ejax.getFormVal('#frmEditTag');
  1333. ejax.load('Dashboard', 'saveTag', finalData);
  1334. }
  1335. },
  1336. socialshare:{
  1337. share: function( id , type ){
  1338. eblog.spinner.publish( id , 1 );
  1339. ejax.load( 'dashboard' , 'ajaxSocialShare' , id , type );
  1340. }
  1341. },
  1342. /**
  1343. * Twitter
  1344. */
  1345. twitter: {
  1346. update: function(id) {
  1347. if ( id != "" )
  1348. {
  1349. eblog.spinner.publish(id, 1);
  1350. ejax.load('Dashboard', 'ajaxUpdateTwitter', id);
  1351. }
  1352. }
  1353. },
  1354. /**
  1355. * Forms
  1356. */
  1357. form: {
  1358. checkbox: {
  1359. checkall: function() {
  1360. $("#adminForm INPUT[type='checkbox']").each( function() {
  1361. if ( $('#toggle').attr('checked') )
  1362. $(this).attr('checked', true);
  1363. else
  1364. $(this).attr('checked', false);
  1365. });
  1366. return false;
  1367. }
  1368. }
  1369. },
  1370. /**
  1371. * Trackbacks
  1372. */
  1373. trackback: {
  1374. url: {
  1375. copy: function() {
  1376. $( '#trackback-url' ).focus().select();
  1377. }
  1378. }
  1379. },
  1380. /**
  1381. * Common method for EasyBlog
  1382. */
  1383. system: {
  1384. alert: function ( text, title ) {
  1385. ejax.alert(ejax.string(text), ejax.string(title), '450', 'auto');
  1386. //ejax.load('Latest', 'ajaxShowAlertDialog', _text, _title);
  1387. },
  1388. dialog: function ( text, callback, title ) {
  1389. var dialogActions = '<div class="dialog-actions"><input type="button" value="' + ejax.string('No') + '" class="button" id="edialog-cancel" name="edialog-cancel" onclick="ejax.closedlg();" /><input type="button" value="' + ejax.string('Yes') + '" class="button" id="edialog-submit" name="edialog-submit" onclick="' + callback + '" /></div>';
  1390. var options = {
  1391. title: ejax.string(title),
  1392. content: ejax.string(text) + dialogActions
  1393. }
  1394. ejax.dialog(options);
  1395. //ejax.load('Latest', 'ajaxShowDialog', text, callback, title);
  1396. },
  1397. loader: function (show) {
  1398. if(show)
  1399. {
  1400. if($('img#easyblog-loader').length > 0)
  1401. {
  1402. $('img#easyblog-loader').remove();
  1403. }
  1404. var img = new Image;
  1405. img.src = '/components/com_easyblog/assets/images/loader.gif';
  1406. img.name = 'easyblog-loader';
  1407. img.id = 'easyblog-loader';
  1408. var divBody = $('div#eblog-wrapper');
  1409. var divWidth = divBody.width();
  1410. //divHeight = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || window.parent.document.body.clientHeight;
  1411. divHeight = window.innerHeight || self.innerHeight || window.parent.document.body.clientHeight;
  1412. divBody.prepend(img);
  1413. $('img#easyblog-loader').css('marginTop', (divHeight / 2));
  1414. $('img#easyblog-loader').css('marginLeft', (divWidth / 2));
  1415. $('img#easyblog-loader').css('position', 'absolute');
  1416. $('img#easyblog-loader').css('z-index', 10);
  1417. }
  1418. else
  1419. {
  1420. if($('img#easyblog-loader').length > 0)
  1421. {
  1422. $('img#easyblog-loader').remove();
  1423. }
  1424. }
  1425. }
  1426. },
  1427. teamblog: {
  1428. join: function(teamId) {
  1429. var id = String(teamId);
  1430. ejax.load('TeamBlog', 'showDialog', id, 'join');
  1431. },
  1432. leave: function(teamId) {
  1433. var id = String(teamId);
  1434. ejax.load('TeamBlog', 'showDialog', id, 'leave');
  1435. },
  1436. leaveteam: function() {
  1437. eblog.loader.loading( 'eblog_loader' );
  1438. ejax.load( 'teamblog' , 'leaveTeam' , ejax.getFormVal( '#frmLeave' ) );
  1439. },
  1440. send: function() {
  1441. eblog.loader.loading( 'eblog_loader' );
  1442. ejax.load( 'teamblog' , 'addJoinRequest' , ejax.getFormVal( '#frmJoin' ) );
  1443. },
  1444. approve: function() {
  1445. },
  1446. reject: function() {
  1447. }
  1448. },
  1449. calendar: {
  1450. reload: function(view, func, position, itemid, size, type, timestamp) {
  1451. ejax.load( view , func, position, itemid, size, type, timestamp);
  1452. },
  1453. showtooltips : function(id)
  1454. {
  1455. $('.easyblog_calendar_tooltips').hide();
  1456. $('#com_easyblog_calendar_day_'+id).show();
  1457. }
  1458. }
  1459. }
  1460. $(document).ready(function(){
  1461. $.sanitizeHTML = function(html)
  1462. {
  1463. var fragmentContainer = document.createElement('div'),
  1464. fragment = document.createDocumentFragment();
  1465. $.clean([html], document, fragment);
  1466. fragmentContainer.appendChild(fragment);
  1467. return fragmentContainer.innerHTML;
  1468. }
  1469. /**
  1470. * Initializes all the gallery stuffs here
  1471. **/
  1472. // Init fancy box images.
  1473. if (window.eblog_enable_lightbox) {
  1474. var options = {
  1475. showOverlay: true,
  1476. centerOnScroll: true,
  1477. overlayOpacity: 0.7
  1478. }
  1479. if (!window.eblog_lightbox_title) {
  1480. options.helpers = { title: false };
  1481. }
  1482. if (window.eblog_lightbox_enforce_size) {
  1483. options.maxWidth = window.eblog_lightbox_width;
  1484. options.maxHeight = window.eblog_lightbox_height;
  1485. }
  1486. eblog.images.initFancybox('a.easyblog-thumb-preview', options);
  1487. }
  1488. eblog.images.initCaption('img.easyblog-image-caption');
  1489. });
  1490. // module: end
  1491. module.resolve();
  1492. });