@@ -145,6 +145,8 @@ window.saveEditorContent = function(new_code = false) {
145145 return ;
146146 }
147147
148+
149+
148150 const snippetUid = document . querySelector ( "#snippet_uid" ) . textContent ;
149151 const codeHash = document . querySelector ( "#code_hash" ) . textContent ;
150152 const langId = document . querySelector ( "#lang_id" ) . textContent ;
@@ -166,7 +168,26 @@ window.saveEditorContent = function(new_code = false) {
166168 } )
167169 . then ( response => response . json ( ) )
168170 . then ( data => {
169- console . log ( 'Content saved successfully:' , data ) ;
171+ // console.log('Content saved successfully:', data);
172+
173+ Toastify ( {
174+ text : "Content saved successfully" ,
175+ duration : 3000 ,
176+ destination : "" ,
177+ newWindow : true ,
178+ close : true ,
179+ gravity : "bottom" , // `top` or `bottom`
180+ position : "center" , // `left`, `center` or `right`
181+ stopOnFocus : true , // Prevents dismissing of toast on hover
182+ style : {
183+ background : "linear-gradient(to right, #00b09b, #96c93d)" ,
184+ } ,
185+ offset : {
186+ y : 50 // vertical axis - can be a number or a string indicating unity. eg: '2em'
187+ } ,
188+ onClick : function ( ) { } // Callback after click
189+ } ) . showToast ( ) ;
190+
170191 if ( new_code === true ) {
171192 const buttonId = createAndAppendButton ( langId , data . codeEntry . hash ) ;
172193 document . getElementById ( buttonId ) . click ( ) ;
@@ -211,6 +232,24 @@ window.saveSnippetDetails = function(event) {
211232 . then ( response => response . json ( ) )
212233 . then ( data => {
213234 if ( data . success ) {
235+ Toastify ( {
236+ text : "Saved successfully!" ,
237+ duration : 3000 ,
238+ destination : "" ,
239+ newWindow : true ,
240+ close : true ,
241+ gravity : "bottom" , // `top` or `bottom`
242+ position : "center" , // `left`, `center` or `right`
243+ stopOnFocus : true , // Prevents dismissing of toast on hover
244+ style : {
245+ background : "linear-gradient(to right, #00b09b, #96c93d)" ,
246+ } ,
247+ offset : {
248+ y : 50 // vertical axis - can be a number or a string indicating unity. eg: '2em'
249+ } ,
250+ onClick : function ( ) { } // Callback after click
251+ } ) . showToast ( ) ;
252+
214253 // Update the name on the page
215254 document . getElementById ( "snippet-name" ) . innerText = newSnippetName ;
216255 closeSnippetDetailsEditModal ( ) ;
@@ -261,7 +300,24 @@ window.openCodeTab = function(btn) {
261300window . copyEmbedCode = function ( ) {
262301 const embedCode = `<iframe src="{{ url('embed/' . $snippet->uid) }}" width="100%" height="400px" style="border:0"></iframe>` ;
263302 navigator . clipboard . writeText ( embedCode ) . then ( ( ) => {
264- alert ( "Embed code copied to clipboard!" ) ;
303+ // alert("Embed code copied to clipboard!");
304+ Toastify ( {
305+ text : "Embed code copied to clipboard!" ,
306+ duration : 3000 ,
307+ destination : "" ,
308+ newWindow : true ,
309+ close : true ,
310+ gravity : "bottom" , // `top` or `bottom`
311+ position : "center" , // `left`, `center` or `right`
312+ stopOnFocus : true , // Prevents dismissing of toast on hover
313+ style : {
314+ background : "linear-gradient(to right, #00b09b, #96c93d)" ,
315+ } ,
316+ offset : {
317+ y : 50 // vertical axis - can be a number or a string indicating unity. eg: '2em'
318+ } ,
319+ onClick : function ( ) { } // Callback after click
320+ } ) . showToast ( ) ;
265321 } ) . catch ( err => {
266322 console . error ( "Failed to copy text: " , err ) ;
267323 } ) ;
@@ -289,6 +345,25 @@ window.copyCodeCode = function(button) {
289345
290346 // Show success image
291347 if ( successful ) {
348+
349+ Toastify ( {
350+ text : "Code copied to clipboard!" ,
351+ duration : 3000 ,
352+ destination : "" ,
353+ newWindow : true ,
354+ close : true ,
355+ gravity : "bottom" , // `top` or `bottom`
356+ position : "center" , // `left`, `center` or `right`
357+ stopOnFocus : true , // Prevents dismissing of toast on hover
358+ style : {
359+ background : "linear-gradient(to right, #00b09b, #96c93d)" ,
360+ } ,
361+ offset : {
362+ y : 50 // vertical axis - can be a number or a string indicating unity. eg: '2em'
363+ } ,
364+ onClick : function ( ) { } // Callback after click
365+ } ) . showToast ( ) ;
366+
292367 copyImg . style . display = 'none' ; // Hide copy icon
293368 successImg . style . display = 'block' ; // Show success icon
294369
0 commit comments