| @@ -1,70 +1,106 @@ | ||
| 1 | -var progressbar={ | |
| 2 | - title:"Progressbar Shortcode", | |
| 3 | - id :'oscitas-form-progressbar', | |
| 4 | - pluginName: 'progressbar', | |
| 5 | - setRowColors: true | |
| 6 | -}; | |
| 7 | 1 | (function() { |
| 8 | - _create_tinyMCE_options(progressbar, 800); | |
| 2 | + tinymce.create('tinymce.plugins.oscitasProgressbar', { | |
| 3 | + init : function(ed, url) { | |
| 4 | + ed.addButton('oscitasprogressbar', { | |
| 5 | + title : 'Progressbar Shortcode', | |
| 6 | + image : url+'/icon.png', | |
| 7 | + onclick : function() { | |
| 8 | + create_oscitas_progressbar(); | |
| 9 | + jQuery.fancybox({ | |
| 10 | + 'autoSize':false, | |
| 11 | + 'autoWidth':false, | |
| 12 | + 'fitToView':false, | |
| 13 | + 'height':'auto', | |
| 14 | + 'topRatio':0.1, | |
| 15 | + 'width':800, | |
| 16 | + 'type' : 'inline', | |
| 17 | + 'title' : 'Progressbar Shortcode', | |
| 18 | + 'href' : '#oscitas-form-progressbar', | |
| 19 | + helpers: { | |
| 20 | + title : { | |
| 21 | + type : 'over', | |
| 22 | + position:'top' | |
| 23 | + } | |
| 24 | + } | |
| 25 | + }); | |
| 26 | + jQuery('#oscitas-form-progressbar table tr:visible:even').css('background', '#F0F0F0'); | |
| 27 | + jQuery('#oscitas-form-progressbar table tr:visible:odd').css('background', '#DADADD'); | |
| 28 | + } | |
| 29 | + }); | |
| 30 | + }, | |
| 31 | + createControl : function(n, cm) { | |
| 32 | + return null; | |
| 33 | + }, | |
| 34 | + getInfo : function() { | |
| 35 | + return { | |
| 36 | + longname : "Progressbar Shortcode", | |
| 37 | + author : 'Oscitas Themes', | |
| 38 | + authorurl : 'http://www.oscitasthemes.com/', | |
| 39 | + infourl : 'http://www.oscitasthemes.com/', | |
| 40 | + version : "2.0.0" | |
| 41 | + }; | |
| 42 | + } | |
| 43 | + }); | |
| 44 | + tinymce.PluginManager.add('oscitasprogressbar', tinymce.plugins.oscitasProgressbar); | |
| 9 | 45 | })(); |
| 10 | 46 | |
| 11 | -function ebs_return_html_progressbar(pluginObj){ | |
| 12 | - var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table ebs-default-options">\ | |
| 47 | +function create_oscitas_progressbar(){ | |
| 48 | + if(jQuery('#oscitas-form-progressbar').length){ | |
| 49 | + jQuery('#oscitas-form-progressbar').remove(); | |
| 50 | + } | |
| 51 | + // creates a form to be displayed everytime the button is clicked | |
| 52 | + // you should achieve this using AJAX instead of direct html code like this | |
| 53 | + var form = jQuery('<div id="oscitas-form-progressbar" class="oscitas-container"><table id="oscitas-table" class="form-table">\ | |
| 13 | 54 | <tr>\ |
| 14 | - <th><label for="oscitas-progressbar-style">'+ebsjstrans.progress+' '+ebsjstrans.bar+' '+ebsjstrans.type+':</label></th>\ | |
| 55 | + <th><label for="oscitas-progressbar-style">Progress Bar Type:</label></th>\ | |
| 15 | 56 | <td><select name="type" id="oscitas-progressbar-style">\ |
| 16 | - <option value="">'+ebsjstrans.default+'</option>\ | |
| 17 | - <option value="progress-bar-success">'+ebsjstrans.success+'</option>\ | |
| 18 | - <option value="progress-bar-info">'+ebsjstrans.information+'</option>\ | |
| 19 | - <option value="progress-bar-warning">'+ebsjstrans.warning+'</option>\ | |
| 20 | - <option value="progress-bar-danger">'+ebsjstrans.danger+'</option>\ | |
| 57 | + <option value="">Default</option>\ | |
| 58 | + <option value="progress-bar-success">Success</option>\ | |
| 59 | + <option value="progress-bar-info">Information</option>\ | |
| 60 | + <option value="progress-bar-warning">Warning</option>\ | |
| 61 | + <option value="progress-bar-danger">Danger</option>\ | |
| 21 | 62 | </select><br />\ |
| 22 | 63 | </td>\ |
| 23 | 64 | </tr>\ |
| 24 | 65 | <tr>\ |
| 25 | - <th><label for="oscitas-progressbar-label">'+ebsjstrans.progress+' '+ebsjstrans.bar+' '+ebsjstrans.label+':</label></th>\ | |
| 66 | + <th><label for="oscitas-progressbar-label">Progressbar Label:</label></th>\ | |
| 26 | 67 | <td><input type="text" name="title" id="oscitas-progressbar-label" value=""/><br />\ |
| 27 | 68 | </td>\ |
| 28 | 69 | </tr>\ |
| 29 | 70 | <tr>\ |
| 30 | - <th><label for="oscitas-progressbar-progress">'+ebsjstrans.progress+' '+ebsjstrans.bar+' '+ebsjstrans.value+':</label></th>\ | |
| 71 | + <th><label for="oscitas-progressbar-progress">Progress Value:</label></th>\ | |
| 31 | 72 | <td><input type="text" name="title" id="oscitas-progressbar-progress" value="50"/><br />\ |
| 32 | - <small>'+ebsjstrans.enterval0to100+'</small>\ | |
| 73 | + <small>Enter a numeric value between 0 to 100, Default value is 50</small>\ | |
| 33 | 74 | </td>\ |
| 34 | 75 | </tr>\ |
| 35 | 76 | <tr>\ |
| 36 | - <th><label for="oscitas-progressbar-stripped">'+ebsjstrans.stripped+' '+ebsjstrans.progress+' '+ebsjstrans.bar+':</label></th>\ | |
| 77 | + <th><label for="oscitas-progressbar-stripped">Stripped Progress Bar:</label></th>\ | |
| 37 | 78 | <td>\ |
| 38 | 79 | <input type="checkbox" id="oscitas-progressbar-stripped">\ |
| 39 | 80 | </td>\ |
| 40 | 81 | </tr>\ |
| 41 | 82 | <tr id="osc_progress_animate" style="display: none;">\ |
| 42 | - <th><label for="oscitas-progressbar-animated">'+ebsjstrans.animated+' '+ebsjstrans.progress+' '+ebsjstrans.bar+':</label></th>\ | |
| 83 | + <th><label for="oscitas-progressbar-animated">Animated Progress Bar:</label></th>\ | |
| 43 | 84 | <td>\ |
| 44 | 85 | <input type="checkbox" id="oscitas-progressbar-animated">\ |
| 45 | 86 | </td>\ |
| 46 | 87 | </tr>\ |
| 47 | 88 | <tr>\ |
| 48 | - <th><label for="oscitas-progressbar-class">'+ebsjstrans.customclass+':</label></th>\ | |
| 89 | + <th><label for="oscitas-progressbar-class">Custom Class:</label></th>\ | |
| 49 | 90 | <td><input type="text" name="line" id="oscitas-progressbar-class" value=""/><br />\ |
| 50 | 91 | </td>\ |
| 51 | 92 | </tr>\ |
| 52 | 93 | </table>\ |
| 53 | - <p class="submit ebs-default-options">\ | |
| 54 | - <input type="button" id="oscitas-progressbar-submit" class="button-primary" value="'+ebsjstrans.insert+' '+ebsjstrans.button+'" name="submit" />\ | |
| 94 | + <p class="submit">\ | |
| 95 | + <input type="button" id="oscitas-progressbar-submit" class="button-primary" value="Insert Button" name="submit" />\ | |
| 55 | 96 | </p>\ |
| 56 | - <div class="pro-version-image aligncenter" style="display: none;"><img src="'+ebs_url+'shortcode/progressbar/screenshot.jpg"/></div>\ | |
| 57 | 97 | </div>'); |
| 58 | - return form; | |
| 59 | -} | |
| 60 | -function create_oscitas_progressbar(pluginObj){ | |
| 61 | - var form=jQuery(pluginObj.hashId); | |
| 62 | - | |
| 98 | + | |
| 63 | 99 | var table = form.find('table'); |
| 64 | - | |
| 65 | - jQuery('#oscitas-form-progressbar table tr:visible:even').css('background', '#ffffff'); | |
| 66 | - jQuery('#oscitas-form-progressbar table tr:visible:odd').css('background', '#efefef'); | |
| 100 | + form.appendTo('body').hide(); | |
| 101 | + jQuery('#oscitas-form-progressbar table tr:visible:even').css('background', '#F0F0F0'); | |
| 102 | + jQuery('#oscitas-form-progressbar table tr:visible:odd').css('background', '#DADADD'); | |
| 67 | 103 | table.find('#oscitas-progressbar-stripped').click(function(){ |
| 68 | 104 | if(jQuery(this).prop('checked')){ |
| 69 | 105 | jQuery('#osc_progress_animate').show(); |
| 70 | 106 | } else{ |
| @@ -69,22 +105,22 @@ | ||
| 69 | 105 | jQuery('#osc_progress_animate').show(); |
| 70 | 106 | } else{ |
| 71 | 107 | jQuery('#osc_progress_animate').hide(); |
| 72 | 108 | } |
| 73 | - jQuery('#oscitas-form-progressbar table tr:visible:even').css('background', '#ffffff'); | |
| 74 | - jQuery('#oscitas-form-progressbar table tr:visible:odd').css('background', '#efefef'); | |
| 109 | + jQuery('#oscitas-form-progressbar table tr:visible:even').css('background', '#F0F0F0'); | |
| 110 | + jQuery('#oscitas-form-progressbar table tr:visible:odd').css('background', '#DADADD'); | |
| 75 | 111 | }) |
| 76 | 112 | |
| 113 | + | |
| 77 | 114 | |
| 78 | - | |
| 79 | - | |
| 80 | - | |
| 115 | + | |
| 116 | + | |
| 81 | 117 | // handles the click event of the submit button |
| 82 | 118 | form.find('#oscitas-progressbar-submit').click(function(){ |
| 83 | - | |
| 119 | + | |
| 84 | 120 | var cusclass='',type='',value='',stripped='',label=''; |
| 85 | 121 | if(jQuery('#oscitas-progressbar-stripped').prop('checked')){ |
| 86 | - stripped=' barstyle="progress-striped'; | |
| 122 | + stripped=' barstyle="progress-striped'; | |
| 87 | 123 | if(jQuery('#oscitas-progressbar-animated').prop('checked')){ |
| 88 | 124 | stripped +=' active'; |
| 89 | 125 | } |
| 90 | 126 | stripped +='"'; |
| @@ -100,16 +136,16 @@ | ||
| 100 | 136 | } |
| 101 | 137 | if(table.find('#oscitas-progressbar-label').val()!=''){ |
| 102 | 138 | label= ' label="'+table.find('#oscitas-progressbar-label').val()+'"'; |
| 103 | 139 | } |
| 104 | - var shortcode = '['+$ebs_prefix+'progressbar'+value+cusclass+type+stripped+label; | |
| 105 | - | |
| 140 | + var shortcode = '[progressbar'+value+cusclass+type+stripped+label; | |
| 141 | + | |
| 106 | 142 | shortcode += ']'; |
| 107 | - | |
| 143 | + | |
| 108 | 144 | // inserts the shortcode into the active editor |
| 109 | - ebsInsertShortcode(shortcode); | |
| 110 | - | |
| 145 | + tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode); | |
| 146 | + | |
| 111 | 147 | // closes fancybox |
| 112 | - close_dialogue(pluginObj.hashId); | |
| 148 | + jQuery.fancybox.close(); | |
| 113 | 149 | }); |
| 114 | 150 | } |
| 115 | 151 | |