shortcoder
Last commit date
images
13 years ago
js
13 years ago
languages
13 years ago
readme.txt
13 years ago
sc-admin-css.css
13 years ago
sc-admin-js.js
13 years ago
sc-editor.php
13 years ago
screenshot-1.png
13 years ago
screenshot-2.png
13 years ago
screenshot-3.png
13 years ago
screenshot-4.png
13 years ago
shortcoder.php
13 years ago
sc-admin-js.js
103 lines
| 1 | $j = jQuery.noConflict(); |
| 2 | |
| 3 | $j(document).ready(function(){ |
| 4 | var sccontent; |
| 5 | |
| 6 | $j('#sc_list li').click(function(){ |
| 7 | $j('#sc_name_edit').val($j(this).text()); |
| 8 | $j('#sc_edit_form').submit(); |
| 9 | }); |
| 10 | |
| 11 | $j('#sc_list li').draggable({ |
| 12 | start: function(){ $j('#sc_delete').addClass('sc_trashHover'); }, |
| 13 | stop: function(){ $j('#sc_delete').removeClass('sc_trashHover'); } |
| 14 | }); |
| 15 | $j('#sc_delete').droppable({ |
| 16 | drop: function(e, ui){ |
| 17 | $j('#sc_list li').unbind('click'); |
| 18 | $j('#sc_name_edit').val(ui.draggable.text()); |
| 19 | $j('#sc_form_action').val('delete'); |
| 20 | $j('#sc_edit_form').submit(); |
| 21 | } |
| 22 | }); |
| 23 | |
| 24 | $j('#sc_name').bind('keyup focus change',function(){ |
| 25 | sc_triggerElements($j(this).val()); |
| 26 | }); |
| 27 | |
| 28 | $j('.sc_back').click(function(){ |
| 29 | location.reload(); |
| 30 | }); |
| 31 | |
| 32 | sc_triggerElements($j('#sc_name').val()); |
| 33 | |
| 34 | $j('.sc_switch_editor li:first').addClass('sc_editor_active'); |
| 35 | |
| 36 | $j('.sc_editor_html').click(function(){ |
| 37 | sccontent.removeInstance('sc_content'); |
| 38 | $j('.sc_switch_editor li').removeClass('sc_editor_active'); |
| 39 | $j(this).addClass('sc_editor_active'); |
| 40 | }); |
| 41 | |
| 42 | $j('.sc_editor_visual').click(function(){ |
| 43 | sccontent = new nicEditor({ |
| 44 | buttonList : ['bold','italic','underline','left','center','right','justify','ol','ul','subscript','superscript','strikethrough', 'fontFormat','removeformat','indent','outdent','hr','image','forecolor','bgcolor','link' ,'unlink'], |
| 45 | iconsPath : $j('.sc_hidden_text').text() |
| 46 | }).panelInstance('sc_content'); |
| 47 | $j('.sc_switch_editor li').removeClass('sc_editor_active'); |
| 48 | $j(this).addClass('sc_editor_active'); |
| 49 | }); |
| 50 | |
| 51 | // Video |
| 52 | $j('.sc_open_video').click(function(e){ |
| 53 | e.preventDefault(); |
| 54 | newwindow2=window.open('','name','height=340,width=585'); |
| 55 | var tmp = newwindow2.document; |
| 56 | tmp.write('<iframe width="560" height="315" src="http://www.youtube.com/embed/GrlRADfvjII" frameborder="0" allowfullscreen></iframe>'); |
| 57 | tmp.close(); |
| 58 | }); |
| 59 | |
| 60 | // Share bar |
| 61 | $j('.sc_share_wrap li').mouseenter(function(){ |
| 62 | $this = $j(this); |
| 63 | $j('.sc_share_iframe').remove(); |
| 64 | $j('body').append('<iframe class="sc_share_iframe"></iframe>'); |
| 65 | $j('.sc_share_iframe').css({ |
| 66 | position: 'absolute', |
| 67 | top: $this.offset()['top'], |
| 68 | left: $this.offset()['left'] + 55, |
| 69 | width: $this.attr('data-width'), |
| 70 | height: $this.attr('data-height'), |
| 71 | }).attr('src', $this.attr('data-url')).hide().fadeIn(); |
| 72 | }); |
| 73 | |
| 74 | $j('.sc_share_iframe').live('mouseout', function(){ |
| 75 | $j(this).remove(); |
| 76 | }); |
| 77 | |
| 78 | }); |
| 79 | |
| 80 | var sc_closeiframe = function(){ |
| 81 | $j('.sc_share_iframe').remove(); |
| 82 | } |
| 83 | |
| 84 | function sc_triggerElements(val){ |
| 85 | if(val != ''){ |
| 86 | if(sc_wsc(val)){ |
| 87 | code = '"' + val + '"'; |
| 88 | }else{ |
| 89 | code = val; |
| 90 | } |
| 91 | |
| 92 | $j('#sc_code').show(); |
| 93 | $j('#sc_code').html('Your shortcode is <b>[sc:' + code + ']</b>'); |
| 94 | $j('#sc_submit').removeClass('sc_btdisabled').removeAttr('disabled'); |
| 95 | }else{ |
| 96 | $j('#sc_code').hide(); |
| 97 | $j('#sc_submit').addClass('sc_btdisabled').attr('disabled', 'disabled'); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | function sc_wsc(s) { |
| 102 | return s.indexOf(' ') >= 0; |
| 103 | } |