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

/wp-content/plugins/suppamenu/core/js/core.dev.js

https://gitlab.com/thisishayat/itv-2016
JavaScript | 351 lines | 244 code | 64 blank | 43 comment | 15 complexity | d03d29882b27d2ff7e8366a2295b1b9c MD5 | raw file
  1. /*********************************************************************************************************
  2. *
  3. * Codetemp Framework ( CTFramework )
  4. *
  5. * @author Taieb Sabri (codetemp), http://vamospace.com
  6. * @version 1.2.5
  7. *
  8. * Start 2013-6-2
  9. * Last Update 2013-10-07
  10. *
  11. * Required WP 3.5+ (*)
  12. *
  13. * --- You Are Not Allowed To Use This Framework , To Build WordPress Plugins or Themes !!!
  14. * --- You Have To Purchase A Licence From codezag@gmail.com
  15. *
  16. /*********************************************************************************************************/
  17. jQuery(document).ready(function(){
  18. /** Import Message **/
  19. if( jQuery( document ).find('.suppa_fileuploaded').length > 0 )
  20. {
  21. jQuery(".codetemp_ajax_response_backup").fadeIn(200);
  22. setTimeout( function(){
  23. jQuery(".codetemp_ajax_response_backup").fadeOut(200);
  24. }, 4000 );
  25. }
  26. /** Main Nav : Show/Hide pages **/
  27. jQuery('.codetemp_main_nav').on({
  28. click : function(){
  29. var $this = jQuery(this);
  30. var $target = $this.attr('href').replace( '#' , '' );
  31. jQuery('.codetemp_main_nav > li').removeClass('selected');
  32. $this.parent().addClass('selected');
  33. $this.parents('.codetemp_nav_pages_container').find('.codetemp_page').slideUp(200);
  34. if( $this.parents('.codetemp_nav_pages_container').find('#'+$target).length > 0 )
  35. $this.parents('.codetemp_nav_pages_container').find('#'+$target).slideDown(200);
  36. else
  37. $this.parents('.codetemp_nav_pages_container').find('#'+$target+'_1').slideDown(200);
  38. return false;
  39. }
  40. }, '> li > a' );
  41. /* second nav */
  42. jQuery('.codetemp_main_nav ul').on({
  43. click : function(){
  44. var $this = jQuery(this);
  45. var $target = $this.attr('href').replace( '#' , '' );
  46. jQuery('.codetemp_main_nav ul a').removeClass('selected');
  47. $this.addClass('selected');
  48. $this.parents('.codetemp_nav_pages_container').find('.codetemp_page').slideUp(200);
  49. $this.parents('.codetemp_nav_pages_container').find('#'+$target).slideDown(200);
  50. return false;
  51. }
  52. }, 'a' );
  53. /** Tab : Show / Hide **/
  54. jQuery('.codetemp_pages_container').on({
  55. click : function(){
  56. jQuery(this).parent().parent().parent().children('.codetemp_tab_inside').slideToggle(200);
  57. }
  58. }, '.codetemp_tab_display_icon' );
  59. /** Ace Editor **/
  60. var ace_editors = [];
  61. jQuery('.codetemp_pages_container').find('.ctf_option_ace_editor').each(function(i){
  62. var $this = jQuery(this);
  63. var $this_id = $this.attr('id');
  64. ace_editors[i] = ace.edit( $this_id + "_ace" );
  65. ace_editors[i].setTheme("ace/theme/monokai");
  66. ace_editors[i].setOptions({
  67. fontSize: "13pt"
  68. });
  69. });
  70. /** Ajax **/
  71. jQuery('.codetemp_settings_container').on({
  72. click : function(){
  73. var $this = jQuery(this);
  74. var $form = $this.parents('#codetemp_form');
  75. var $nonce = $form.find('#nonce').val();
  76. var $parent = $form.find('#codetemp_parent').val();
  77. var $group_id = $form.find('#codetemp_group_id').val();
  78. var $option_id = $form.find('#codetemp_option_id').val();
  79. var $wp_ajax_function = $form.find('#action').val();
  80. var $plugin_url = $form.find('#codetemp_plugin_url').val();
  81. var $data = "";
  82. // Set Loading Image
  83. var $html_ajax_img_load = $plugin_url + 'core/img/ajax-loader.gif';
  84. var $html_ajax_img_save = $plugin_url + 'core/img/success_icon.png';
  85. var $html_ajax_res = jQuery('.codetemp_ajax_response');
  86. $html_ajax_res.children('img').attr( 'src' , $html_ajax_img_load );
  87. $html_ajax_res.children('span').text('');
  88. // Solve Tinymce issue
  89. if( typeof tinyMCE !== "undefined" )
  90. tinyMCE.triggerSave();
  91. // Get Content From ACE Editors
  92. jQuery('.codetemp_pages_container').find('.ctf_option_ace_editor').each(function(i){
  93. jQuery(this).val( ace_editors[i].getSession().getValue() );
  94. });
  95. // Update or ADD Options ( all or by ID )
  96. if( $this.is('.codetemp_button_update_all') )
  97. {
  98. $html_ajax_res.show();
  99. // Added New Skins to "select tag"
  100. var $new_skin = jQuery('#suppa_skin_name').val();
  101. if( $new_skin != "" )
  102. {
  103. jQuery('select[name="skin_modify"]').append('<option value="'+$new_skin+'">'+$new_skin+'</option>');
  104. }
  105. // Search Groups
  106. var $data_string = "";
  107. var $op_count = 0;
  108. var $op_sep = "";
  109. // Add Options to their group
  110. $form.find('.codetemp_nav_pages_container').find('input[type="text"], input[type="hidden"], input[type="password"], input[type="radio"]:checked, input[type="checkbox"], textarea,select').each(function(){
  111. if( $op_count == 0 )
  112. {
  113. $op_sep = '__ctfand__';
  114. }
  115. $op_count = $op_count + 1;
  116. var $this = jQuery(this);
  117. var $name = $this.attr('name');
  118. $data_string = $data_string + $op_sep + $name + '__ctfequal__' + encodeURIComponent( $this.val() );
  119. });
  120. // Ajax Call
  121. jQuery.ajax({
  122. type : 'POST',
  123. url : ajaxurl,
  124. data : {
  125. action : $wp_ajax_function,
  126. ctf_request_type : 'update_all',
  127. nonce : $nonce,
  128. data_string : $data_string,
  129. skin_name : jQuery('#suppa_skin_name').val()
  130. },
  131. cache : false,
  132. success : function( response )
  133. {
  134. $html_ajax_res.children('img').remove();
  135. $html_ajax_res.children('span').html( response );
  136. setTimeout(function(){
  137. $html_ajax_res.fadeOut(200);
  138. }, 4000);
  139. },
  140. error : function( )
  141. {
  142. $request_response = 'ajax_error';
  143. }
  144. });
  145. return false;
  146. }
  147. // Reset All Options
  148. else if( $this.is('.codetemp_button_reset_all') )
  149. {
  150. var r=confirm("Yes , Reset!");
  151. if (r==false)
  152. {
  153. $html_ajax_res.fadeOut(200) ;
  154. return false;
  155. }
  156. $html_ajax_res.show();
  157. $all_data = 'nonce=' + $nonce + '&action=' + $wp_ajax_function + '&ctf_request_type=reset_all';
  158. jQuery.ajax({
  159. type : 'POST',
  160. url : ajaxurl,
  161. data : $all_data,
  162. cache : false,
  163. async : false,
  164. success : function( response )
  165. {
  166. $html_ajax_res.children('img').attr( 'src' , $html_ajax_img_save );
  167. $html_ajax_res.children('span').html(response);
  168. setTimeout( function(){
  169. location.reload( true );
  170. },4000);
  171. },
  172. error : function( response )
  173. {
  174. $html_ajax_res.children('img').attr( 'src' , $html_ajax_img_save );
  175. $html_ajax_res.children('span').text(response);
  176. setTimeout( function(){
  177. $html_ajax_res.fadeOut(200);
  178. }, 1000 );
  179. }
  180. });
  181. }
  182. return false;
  183. }
  184. }, '.codetemp_button_update_all, .codetemp_button_reset_all, .codetemp_button_delete_group, .codetemp_button_delete_option' );
  185. /** Hide Saving Box **/
  186. jQuery('.codetemp_ajax_response_close').click(function(event){
  187. jQuery('.codetemp_ajax_response').fadeOut(200);
  188. event.preventDefault();
  189. });
  190. /** Checkbox **/
  191. jQuery('.codetemp_pages_container').find('input[type="checkbox"]').each(function(){
  192. var $this = jQuery(this);
  193. var $this_id = $this.attr('id');
  194. if( $this.val().toLowerCase() == 'on' )
  195. {
  196. jQuery('.codetemp_pages_container label[for="'+$this_id+'"]').css({ 'background-position' : 'left center' });
  197. }
  198. else
  199. {
  200. jQuery('.codetemp_pages_container label[for="'+$this_id+'"]').css({ 'background-position' : 'right center' });
  201. }
  202. });
  203. jQuery('.codetemp_pages_container').on({
  204. click : function()
  205. {
  206. var $this = jQuery(this);
  207. var $this_id = $this.attr('id');
  208. if( $this.val().toLowerCase() == 'on' )
  209. {
  210. $this.val('off');
  211. jQuery('.codetemp_pages_container label[for="'+$this_id+'"]').css({ 'background-position' : 'right center' });
  212. }
  213. else
  214. {
  215. $this.val('on');
  216. jQuery('.codetemp_pages_container label[for="'+$this_id+'"]').css({ 'background-position' : 'left center' });
  217. }
  218. return false;
  219. }
  220. }, '.ctf_option_checkbox' );
  221. /** Colorpicker **/
  222. jQuery('input.ctf_option_colorpicker').ColorPicker({
  223. onSubmit: function(hsb, hex, rgb, el)
  224. {
  225. jQuery(el).val("#" + hex);
  226. jQuery(el).ColorPickerHide();
  227. jQuery(el).next().css({"background-color":"#"+hex});
  228. },
  229. onBeforeShow: function ()
  230. {
  231. jQuery(this).ColorPickerSetColor(this.value);
  232. }
  233. })
  234. .bind('keyup', function()
  235. {
  236. jQuery(this).ColorPickerSetColor(this.value);
  237. }
  238. );
  239. /** Upload Images with Wordpress **/
  240. // WP 3.5+
  241. // Enqueue Media uploader scripts and environment [ wp_enqueue_media() ].
  242. // Strongly suggest to use this function on the admin_enqueue_scripts action hook. Using it on admin_init hook breaks it
  243. // How To : http://stackoverflow.com/questions/13847714/wordpress-3-5-custom-media-upload-for-your-theme-options
  244. // Don't Foooooooooooooooooorget to array('jquery' , 'media-upload' , 'thickbox') to the enqueue
  245. jQuery( '.codetemp_pages_container' ).on({
  246. click : function()
  247. {
  248. var send_attachment_bkp = wp.media.editor.send.attachment;
  249. var $this = jQuery(this);
  250. wp.media.editor.send.attachment = function(props, attachment) {
  251. $this.prev().val(attachment.url);
  252. // back to first state
  253. wp.media.editor.send.attachment = send_attachment_bkp;
  254. };
  255. wp.media.editor.open();
  256. return false;
  257. }
  258. }, '.ctf_option_upload_button' );
  259. /** Font Style **/
  260. jQuery('.codetemp_pages_container').on({
  261. click : function()
  262. {
  263. var $this = jQuery(this).parents('.ctf_option_container_font');
  264. var $box = $this.find('.ctf_box_desc');
  265. var $font_size = $this.find('.ctf_option_font_size').val();
  266. var $font_family = $this.find('.ctf_option_font_family').val();
  267. var $font_style = $this.find('.ctf_option_font_family_style').val();
  268. var $font_color = $this.find('.ctf_option_font_color').val();
  269. WebFont.load({
  270. google: {
  271. families: [ $this.find('.ctf_option_font_family').find(':selected').text() ]
  272. }
  273. });
  274. $box.parents('.ctf_box').slideDown(200);
  275. $box.css({ 'line-height' : '1.5em' , 'font-size' : $font_size+'px' , 'font-family' : $font_family , 'color' : $font_color });
  276. $box.attr('style', $box.attr('style') + $font_style );
  277. return false;
  278. }
  279. }, '.ctf_option_font_demo' );
  280. /** BOX'S : Hide **/
  281. jQuery('.ctf_box').on({
  282. click : function(){
  283. jQuery(this).parents('.ctf_box').slideUp(200);
  284. return false;
  285. }
  286. }, '.ctf_box_close');
  287. });