This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module IsOrderable | |
| extend ActiveRecord::Concern | |
| def change_position_to(n) | |
| safe_n = self.class.sanitize(n) | |
| current_position = self.class.sanitize(position) | |
| connection.execute(<<-SQL | |
| BEGIN; | |
| UPDATE #{self.class.table_name} SET position = position + 1 WHERE parent_id = #{parent_id} AND position < #{current_position} AND position >= #{safe_n}; | |
| UPDATE #{self.class.table_name} SET position = position - 1 WHERE parent_id = #{parent_id} AND position > #{current_position} AND position <= #{safe_n}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){ | |
| var copyToClipboard = str => { | |
| var el = document.createElement('textarea'); // Create a <textarea> element | |
| el.value = str; // Set its value to the string that you want copied | |
| el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof | |
| el.style.position = 'absolute'; | |
| el.style.left = '-9999px'; // Move outside the screen to make it invisible | |
| document.body.appendChild(el); // Append the <textarea> element to the HTML document | |
| var selected = | |
| document.getSelection().rangeCount > 0 // Check if there is any content selected previously |
OlderNewer