| 1 |
var notifications={ |
| 2 |
title:"Notifications Shortcode", |
| 3 |
id :'oscitas-form-notifications', |
| 4 |
pluginName: 'notifications' |
| 5 |
}; |
| 6 |
(function() { |
| 7 |
_create_tinyMCE_options(notifications); |
| 8 |
})(); |
| 9 |
|
| 10 |
function ebs_return_html_notifications(pluginObj){ |
| 11 |
var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table ebs-default-options">\ |
| 12 |
<tr>\ |
| 13 |
<th><label for="oscitas-type">'+ebsjstrans.style+' :</label></th>\ |
| 14 |
<td><select name="type" id="oscitas-type">\ |
| 15 |
<option value="alert-success">'+ebsjstrans.success+'</option>\ |
| 16 |
<option value="alert-info">'+ebsjstrans.information+'</option>\ |
| 17 |
<option value="alert-warning">'+ebsjstrans.warning+'</option>\ |
| 18 |
<option value="alert-danger">'+ebsjstrans.danger+'</option>\ |
| 19 |
</select><br />\ |
| 20 |
</td>\ |
| 21 |
</tr>\ |
| 22 |
<tr>\ |
| 23 |
<th><label for="oscitas-line">'+ebsjstrans.close+' '+ebsjstrans.link+'</label></th>\ |
| 24 |
<td><input type="checkbox" id="oscitas-close"/><br />\ |
| 25 |
</td>\ |
| 26 |
</tr>\ |
| 27 |
<tr>\ |
| 28 |
<th><label for="oscitas-note-class">'+ebsjstrans.customclass+':</label></th>\ |
| 29 |
<td><input type="text" name="line" id="oscitas-note-class" value=""/><br />\ |
| 30 |
</td>\ |
| 31 |
</tr>\ |
| 32 |
</table>\ |
| 33 |
<p class="submit ebs-default-options">\ |
| 34 |
<input type="button" id="oscitas-submit" class="button-primary" value="'+ebsjstrans.insert+' '+ebsjstrans.notification+'" name="submit" />\ |
| 35 |
</p>\ |
| 36 |
<div class="pro-version-image aligncenter" style="display: none;"><img src="'+ebs_url+'shortcode/notifications/screenshot.jpg"/></div>\ |
| 37 |
</div>'); |
| 38 |
return form; |
| 39 |
} |
| 40 |
function create_oscitas_notifications(pluginObj){ |
| 41 |
var form=jQuery(pluginObj.hashId); |
| 42 |
var table = form.find('table'); |
| 43 |
|
| 44 |
|
| 45 |
// handles the click event of the submit button |
| 46 |
form.find('#oscitas-submit').click(function(){ |
| 47 |
// defines the options and their default values |
| 48 |
// again, this is not the most elegant way to do this |
| 49 |
// but well, this gets the job done nonetheless |
| 50 |
var options = { |
| 51 |
'type' : 'error' |
| 52 |
}; |
| 53 |
var cusclass=''; |
| 54 |
if(table.find('#oscitas-note-class').val()!=''){ |
| 55 |
cusclass= ' class="'+table.find('#oscitas-note-class').val()+'"'; |
| 56 |
} |
| 57 |
var shortcode = '['+$ebs_prefix+'notification'; |
| 58 |
|
| 59 |
for( var index in options) { |
| 60 |
var value = table.find('#oscitas-' + index).val(); |
| 61 |
|
| 62 |
// attaches the attribute to the shortcode only if it's different from the default value |
| 63 |
//if ( value !== options[index] ) |
| 64 |
shortcode += ' ' + index + '="' + value + '"'; |
| 65 |
} |
| 66 |
|
| 67 |
var selected_content = tinyMCE.activeEditor.selection.getContent(); |
| 68 |
if(!selected_content) var selected_content = ebsjstrans.your+' '+ebsjstrans.notification; //'Your notification'; |
| 69 |
shortcode += ' close="'+(table.find('#oscitas-close').prop('checked')? 'true': 'false')+ '" '; |
| 70 |
|
| 71 |
shortcode += cusclass+']'+selected_content+'[/'+$ebs_prefix+'notification]'; |
| 72 |
|
| 73 |
// inserts the shortcode into the active editor |
| 74 |
tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode); |
| 75 |
|
| 76 |
close_dialogue(pluginObj.hashId); |
| 77 |
}); |
| 78 |
} |
| 79 |
|
| 80 |
|